Dmarsh12fitch / CircutBoardTowerDefense

0 stars 1 forks source link

Implement "Slide-In from Bottom" Turret Shop #7

Open Dmarsh12fitch opened 2 years ago

Dmarsh12fitch commented 2 years ago

Change the Shop UI to include the Laser Turret, and then have the menu be partially hidden unless you hover your mouse within a bounds in the bottom right corner and the menu pops up, the bounds is extended with it and once your mouse leaves the bounds the menu goes back down. The energy will be visible the entire time, even when the shop is down. Ryan Pratt you can start on this if you have the time, but otherwise I can cover it.

andystopia commented 2 years ago

@Dmarsh12fitch I'm going to hopefully throw the components that you're going to need onto the turret shops so it should hopefully be a little easier to understand. The thing is that the turret shop entries (both shops) were made before I really solidified my design strategy. Now that the design strategy is more established, they need a little reworking.

andystopia commented 2 years ago

Vague Behavior Issues

People

Possibilities

Have The Mouse Event Collider on some object that is not a turret shop entry

The issue with this is that assuming that that collider receives the OnMouseLeave event, it will receive it the moment you hover a shop entry. However, the OnMouseLeave event, I assume, should hide the shop, so hovering a shop item will hide the shop.

You could say that perhaps we could also have listeners on all the turret shops and have them communicate back to the hiding element whether they're hovered, but this also probably won't work as expected, because the issue is that we could receive an OnMouseLeave event on the collider before we receive the OnMouseEnter on the shop, so the shop will hide.

Collider on all turret shop entries

Another issue, because the shop entries are not right next to each other, they will attempt to hide everytime you mouse from one shop to the other. There will be a MouseLeaveEvent and no MouseOverEvent to correspond (and I don't think the order is deterministic anyways), sot that also won't work, because this time, attempting to hover a shop entry, that you're not currently on, will hide the entire shop.

Solutions

I think event bubbling is how most software solves this issue. Does Unity have a way to do that? If not, bubbling would require reimplementing the entire mouse event system ourselves to work with a bubbling abstraction layout, and that seems outside the scope of this project.

@Dmarsh12fitch, What do you think is the solution to this problem?

Dmarsh12fitch commented 2 years ago

If there was a way to layer colliders for the mouse event that would be the easiest way to solve for the first way. I looked into it and can’t seem to find a way to do that, at least not easily.

The second option isn’t as easy a fix in my opinion, so I’ve been focusing on solving the first one.

I thought for a while on it and then realized this: Instead of a mouse enter check, couldn’t we just check if the cursor was within a certain bounds of x and z?

On Sun, Jan 9, 2022 at 9:47 PM andystopia @.***> wrote:

@Dmarsh12fitch https://github.com/Dmarsh12fitch I don't think is possible in the way I think you think it's possible.

There are two possibilities Have The Mouse Event Collider on some object that is not a turret shop entry

The issue with this is that assuming that that collider receives the OnMouseLeave event, it will receive it the moment you hover a shop entry. However, the OnMouseLeave event, I assume, should hide the shop, so hovering a shop item will hide the shop. Collider on all turret shop entries

Another issue, because the shop entries are not right next to each other, they will attempt to hide everytime you mouse from one shop to the other. There will be a MouseLeaveEvent and no MouseOverEvent to correspond (and I don't think the order is deterministic anyways), sot that also won't work, because this time, attempting to hover a shop entry, that you're not currently on, will hide the entire shop.

— Reply to this email directly, view it on GitHub https://github.com/Dmarsh12fitch/CircutBoardTowerDefense/issues/7#issuecomment-1008500692, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASQXHMHPSHZWFW5MOEOFARLUVJCFRANCNFSM5LQZXIHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

andystopia commented 2 years ago

AFAIK, you're first method is essentially a rudimentary event bubbler, which I'm pretty sure that Unity doesn't for arbritary objects. If we are just hard checking coordinates it's going to be a several step process.

Assuming the size of the shop changes, we'll need to define two bounds that the cursor could be inside.

Then we need to define what it means for the cursor to be inside those bounds, because cursors don't have an inherent world space (cursors are an OS level abstraction), then we're going to need to check where the cursor is on every single frame, check which bounds are active (well this one isn't technically necessary, just simplest, you can avoid this check using polymorphism, and that may be the way to go), and then have an empty move based on the psuedo-cursor events.

Admittedly this is a bit hackish, but, in theory, it would work, assuming you can reliably cast the cursor coordinates into world space. You could also check in the screen space coordinate system, admittedly with a little fussiness, because not all windows are the same size, so what will be a small hard to hit menu on my system, will be a massive screen space on itch.

I'm not great at geometry, but I assume that for any point, on the screen, there is a deterministic way to draw a 3d line whose set of points is disjoint for all other lines generated from all other camera points. So in theory there must be a way to a screen space coordinate into a 3D line in world space.

andystopia commented 2 years ago
image

this belongs here

andystopia commented 2 years ago

Whoever grabs this issue, which may be me, don't forget to modify the shop logic to interact with the game state machine, because we only want the shop to be visible when we are playing the game, and for no other state.