|
Post by Legend on Dec 22, 2021 19:50:37 GMT
Hello I am trying to implement click to attack like click to play card controller and not sure why i am having issues and thought maybe you could help me understand why its happening:
basically i have 2 states into the drag to attack controller that are running into eachother in away- the WaitingForInputState and the FinishInputState
the minions are clickable ICreatureBeginClickAttackHandler and have this handler and i see that the handler works which this resides in waiting for inputstate but strangely when i have this in owner.stateMachine.ChangeState<FinishInputState>(); it seems to call that state's OnCreatureEndClickAttackNotification notification and continue on instead of waiting for the input as in the clickto play controller
in teh beginclick method i have
owner.gameStateMachine.ChangeState<PlayerInputState>();
owner.stateMachine.ChangeState<FinishInputState>();
I am expecting it the player to click then process through the beging click in the waiing for input state then goto the finish input state then wait for the next click
thanks for any help you may have to point me in the right direction
|
|
|
Post by Legend on Dec 22, 2021 19:55:23 GMT
I should say that when i remove the finish input state that the OnCreatureEndClickAttackNotification doesnt get called which makes sense cause it would or should never be in that state unless sent to that state from the waitforinput
|
|
|
Post by Legend on Dec 22, 2021 20:23:41 GMT
ya seems to be piggy backing off the other notification so far I added a check to make sure if its the same minion clicked that it will return if (view.card == owner.attacker) return; this seems to work so far
|
|
|
Post by Admin on Dec 23, 2021 14:30:46 GMT
It sounds like you may have gotten it working a bit, but if there are still problems, here is a potential implementation that might work for you. I would refer to the "Playing Cards" and "Attack" lessons to base the following off of.
WaitingForInputState -> OnClickNotification - should early exit if: -- the game's state machine is not in PlayerIdleState -- the clickable object was not the current player's minion, and is able to attack - If we got this far: -- change the game state to PlayerInputState -- track the `attacker` in a local field, then move to the next local state, ConfirmOrCancelState (or optional ShowPreviewState)
Optional: ShowPreviewState - could highlight the attacker in some way to show that you have started a new process - should then advance to ConfirmOrCancelState
CompleteOrCancelState -> OnClickNotification - upon clicking a minion owned by the opponent, should track the `defender` in a local field, then move on to CompleteState - upon clicking anything else, should advance to CompleteState (or optional CancellingState)
Optional: CancellingState - if you had been showing a preview of the highlighted attacker, you can undo that kind of stuff here - move on to CompleteState
CompleteState - if we have both a tracked attacker and defender, create an AttackAction and perform it - clear the local tracking of an attacker and defender - go back to WaitingForInputState - change game state back to PlayerIdleState
|
|
|
Post by Admin on Dec 23, 2021 14:37:58 GMT
The only other issue I would check is regarding the triggering of `OnBeginDrag` vs `OnClickNotification`. You should have to press and move rather than just press and release to be having a conflict with the other system.
|
|
|
Post by Legend on Dec 25, 2021 0:22:24 GMT
Ya somehow both are working - didnt really have to do much for it ---- not sure why i was expecting to it being a headache trying to get it both working but seemed to work no issue - not questioning it just moving on to the next thing haha - if it isn't broke dont fix it kind of thing. thanks for the help!
Ever think of starting up a discord if you ever find the time to start this back up kind of thing ?
|
|
|
Post by Admin on Dec 28, 2021 14:59:35 GMT
Glad you have it working now. I haven't given a lot of thought to discord and do not currently use it. It could be useful though. Is there a particular feature you love that you feel you are missing via a forum?
|
|