Пример #1
0
        public void SelectPlayerMove(int val)
        {
            if (currentPlayerAgent.MoveSet.Count < val)
            {
                return;
            }
            PlayerActionResult playerAction = new PlayerActionResult()
            {
                ActionType       = BattleEnums.ActionType.FIGHT,
                ChosenItem       = null,
                ChosenMove       = currentPlayerAgent.MoveSet[val],
                ChosenTeamMember = null
            };
            EnemyActionResult enemyAction = QueryEnemyAgentForAction();

            StartCoroutine(ExecuteActions(playerAction, enemyAction));
        }
Пример #2
0
 /// <summary>
 /// Think this would be cleaner using a priority tree for actions. attacks have the lowest priority,
 /// ai items and switching has the next priority, player items and switching have the highest priority.
 /// </summary>
 /// <param name="playerAction"></param>
 /// <param name="enemyAction"></param>
 /// <returns></returns>
 IEnumerator ExecuteActions(PlayerActionResult playerAction, EnemyActionResult enemyAction)
 {
     Debug.Log("ExecuteActions");
     Debug.Log($"Player: {playerAction.ActionType.ToString()}, {playerAction.ChosenMove.MoveName}.");
     Debug.Log($"AI: {enemyAction.ActionType.ToString()}, {enemyAction.ChosenMove.MoveName}.");
     uiManager.stateMachine.ChangeState(new ExecuteActionsState(uiManager, playerAction, enemyAction));
     if (playerAction.ActionType == BattleEnums.ActionType.FIGHT && enemyAction.ActionType == BattleEnums.ActionType.FIGHT)
     {
         int first_move = CompareSpeeds();
         if (first_move == 1)
         {
             executing = true;
             StartCoroutine(ExecuteMove(playerAction.ChosenMove, currentPlayerAgent, currentEnemyBattleAgent));
             while (executing)
             {
                 yield return(new WaitForEndOfFrame());
             }
             executing = true;
             StartCoroutine(ExecuteMove(enemyAction.ChosenMove, currentEnemyBattleAgent, currentPlayerAgent));
             while (executing)
             {
                 yield return(new WaitForEndOfFrame());
             }
         }
         else if (first_move <= 0)
         {
             executing = true;
             StartCoroutine(ExecuteMove(enemyAction.ChosenMove, currentEnemyBattleAgent, currentPlayerAgent));
             while (executing)
             {
                 yield return(new WaitForEndOfFrame());
             }
             executing = true;
             StartCoroutine(ExecuteMove(playerAction.ChosenMove, currentPlayerAgent, currentEnemyBattleAgent));
             while (executing)
             {
                 yield return(new WaitForEndOfFrame());
             }
         }
     }
     uiManager.stateMachine.ChangeState(new ChooseActionState(uiManager));
     yield return(new WaitForEndOfFrame());
 }