|
Post by Legend on Apr 18, 2018 0:59:51 GMT
Done made it into a n event subscribed to onpointerenter and exit
|
|
|
Post by Admin on Apr 18, 2018 15:01:10 GMT
Haha, I like your enthusiasm, you aren't bothering me. Your solution isn't what I was thinking, but you made it work so I am happy for you. I would have created a separate script that existed at the top of the scene hierarchy so it could intercept events on any object, and you would only need a single instance of it in the scene instead of one per card object. It would still post notifications just like you did though, so in the end it may not seem much different.
Also I agree with your first option - you don't have to check for overlap in an update loop, since you can do so in the listeners of the "CardDraggingNotification" notification. This way you are only performing logic when it is potentially relevant.
|
|
|
Post by Legend on Apr 22, 2018 14:25:44 GMT
good glad to hear that i am not bothering you cause there is plenty more questions! just kidding - for the hierarchy shindig - i was thinking to do that but then i noticed that the clicktoattackcontroller script was actually higher above (boardview) and the clicktoplaycontroller script was drilled down further (ally player view) so i was like okay i dont know how unity works with firing and prioritizing scripts so im not going to leave it up to that - i thought the higher up the higher the priority but that i believe was not the case from the testing since the attackcontroller was never appeared to be called but who knows could have been something else.
also i added a box target system so the user can cancel their selection for no target cards i just created a battlefieldview - this is for hover but the same is true for click
var battlefieldView = (hover != null) ? hover.GetComponentInParent<BattlefieldView>() : null; var cardView = (hover != null) ? hover.GetComponentInParent<BattlefieldCardView>() : null;
and this
else { if (battlefieldView != null) owner.stateMachine.ChangeState<ConfirmState>(); else { owner.stateMachine.ChangeState<CancellingState>(); }
}
hope this helps others too - if you have any ideas on a better way to do it feel free to correct me too!
|
|
|
Post by Legend on Apr 22, 2018 18:03:51 GMT
o i have a sidebar question about rect transform movement
is this the standard way if i wanted to flip the icon over to the other side Vector2 GuardianStatLoc = new Vector2(taunt.GetComponent<RectTransform>().anchoredPosition.x * -1, taunt.GetComponent<RectTransform>().anchoredPosition.y);
basically its an image icon to denote taunt and when the minion is flipped to face the other direction it will flip too - it works just not sure if there is an actual better way to do it.
|
|
|
Post by Admin on Apr 23, 2018 15:47:32 GMT
I believe the way input is handled is child-first and then bubble up to the root. This allows specific objects to override general behavior.
I think flipping things by using a -1 is pretty common. Some may actually use a different sprite because lighting can be "baked in" to the image itself and flipping it would make the lighting look wrong.
|
|
|
Post by Legend on Apr 23, 2018 16:16:10 GMT
Ah okay cool - that makes sense - luckily being 2d for this one guess dont have to worry to much about lighting on it.
|
|