// OnStateEnter is called before OnStateEnter is called on any state inside this state machine override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (animatorFSM == null) { animatorFSM = animator.GetComponent <AnimatorFSM>(); } switch (animatorFSM.GetRobotState()) { case AnimatorFSM.RobotStates.Idle: animator.SetTrigger(animator_IdleTrigger); break; case AnimatorFSM.RobotStates.Patrol: animator.SetTrigger(animator_PatrolTrigger); break; case AnimatorFSM.RobotStates.Chase: animator.SetTrigger(animator_ChaseTrigger); break; case AnimatorFSM.RobotStates.Attack: animator.SetTrigger(animator_AttackTrigger); break; } }
// OnStateEnter is called before OnStateEnter is called on any state inside this state machine override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (animatorFSM == null) { animatorFSM = animator.GetComponent <AnimatorFSM>(); } Debug.Log($"Entered <color=red>Agressive</color> Sub State"); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (animatorFSM == null) { animatorFSM = animator.GetComponent <AnimatorFSM>(); } Debug.Log($"New State: <color=green>IDLE</color>"); animatorFSM.SetRobotState(AnimatorFSM.RobotStates.Idle); }
private void CardPlayed(CardBoardPartView _playedCardBoardArea) { Debug.LogFormat("GameController::CardPlayed"); playerViewByNumber[CurrentPlayer].RemoveCard(_playedCardBoardArea.Card); playerViewByNumber[CurrentPlayer].Enable(false); turnResultByPhase = game.PlayCard(CurrentPlayer, _playedCardBoardArea.Card.Model, _playedCardBoardArea.BoardPosition); AnimatorFSM.SetTrigger(nextStateTriggerId); }
private void FightState() { Debug.LogFormat("GameController::FightState"); if (turnResultByPhase.TryGetValue(GamePhase.Normal, out currentPhaseResult)) { ProcessWonCardsList(currentPhaseResult.cardWonList); } else { AnimatorFSM.SetTrigger(nextStateTriggerId); } }
private void BetweenTurnState() { Debug.LogFormat("GameController::BetweenTurnState"); playerViewByNumber[PlayerNumber.One].CurrentPlayerScore = game.GetPlayerByNumber(PlayerNumber.One).Score; playerViewByNumber[PlayerNumber.Two].CurrentPlayerScore = game.GetPlayerByNumber(PlayerNumber.Two).Score; if (game.IsOver) { AnimatorFSM.SetTrigger(gameOverTriggerId); } else { AnimatorFSM.SetTrigger(nextStateTriggerId); } }
private void CardAnimationFinished(CardBoardPartView _cardTarget) { cardsRotationFinishedCount++; if (cardsRotationFinishedCount == cardsRotateCount) { cardsRotationFinishedCount = 0; cardsRotateCount = 0; if (currentPhaseResult.comboCardList != null && currentPhaseResult.comboCardList.Count > 0) { Debug.LogFormat("GameController::CardAnimationFinished -> COMBO"); SpecialRuleText comboRuleText = Instantiate(comboRuleTextPrefab, uiCanvas.transform); ProcessWonCardsList(currentPhaseResult.comboCardList.Dequeue()); } else { AnimatorFSM.SetTrigger(nextStateTriggerId); } } }
private void PlusRuleState() { Debug.LogFormat("GameController::PlusRuleState"); if (turnResultByPhase.TryGetValue(GamePhase.Plus, out currentPhaseResult)) { foreach (CardOnBoardWon cardWonItem in currentPhaseResult.cardWonList) { Vector2Int cardWonBoardPosition = cardWonItem.card.BoardPosition.Value; CardView targetCardViewItem = selectableAreasList[cardWonBoardPosition.x, cardWonBoardPosition.y].Card; targetCardViewItem.StartShinyAnimation(); } SpecialRuleText plusRuleText = Instantiate(plusRuleTextPrefab, uiCanvas.transform); plusRuleText.OnAnimationFinished += () => { ProcessWonCardsList(currentPhaseResult.cardWonList); }; } else { AnimatorFSM.SetTrigger(nextStateTriggerId); } }
private void Awake() { animator = new AnimatorFSM(GetComponent <Animator>()); }
private void BeginGame() { randomArrow.OnAnimationComplete -= BeginGame; AnimatorFSM.SetTrigger(nextStateTriggerId); }