Esempio n. 1
0
    // Update is called once per frame
    private void Update()
    {
        if (PerformersList.Count == charactersCount)
        {
            ExecutePerformersList = new List <HandleTurn>(PerformersList);
            SortTurnOrder(ExecutePerformersList);
            PerformersList.Clear();
        }//*/

        switch (BattleState)
        {
        case (ActionState.WAIT):
        {
            winLoseCheck();

            // if at least one character has
            // pushed action data to turn list
            if (ExecutePerformersList.Count > 0)
            {
                BattleState = ActionState.TAKEACTION;
                Debug.Log("TAKEACTION Started");
            }
            break;
        }

        case (ActionState.TAKEACTION):
        {
            GameObject performer = GameObject.Find(ExecutePerformersList[0].AttackersName);

            if (ExecutePerformersList[0].Type == "Enemy")
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();

                // Check if target is still alive
                if (HeroesInBattle.Count > 0)
                {
                    esm.CheckTargetDead(ExecutePerformersList[0]);
                }

                // Set Enemy's current target
                esm.HeroToAttack = ExecutePerformersList[0].AttackersTarget;

                // Attack Target
                esm.CurrentState = EnemyStateMachine.TurnState.ACTION;
            }
            if (ExecutePerformersList[0].Type == "Hero")
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();

                hsm.Action = ExecutePerformersList[0].Action;

                //if (EnemiesInBattle.Count > 0 && hsm.EnemyToAttack != null) { hsm.CheckTargetDead(ExecutePerformersList[0]); }

                if (hsm.Action != ActionType.GUARD)
                {
                    hsm.EnemyToAttack = ExecutePerformersList[0].AttackersTarget;
                }                                                                                                               // review this code when more actions become developed

                hsm.CurrentState = HeroStateMachine.TurnState.ACTION;
            }

            BattleState = ActionState.PERFORMACTION;

            break;
        }

        case (ActionState.PERFORMACTION):
        {
            // placeholder state while
            // characters perform action
            // Resets to WAIT
            // when action is completed
            break;
        }
        }   // switch (BattleState)

        switch (PlayerInput)
        {
        case (HeroGUI.ACTIVATE):
        {
            if (HeroesToManage.Count > 0 && ExecutePerformersList.Count == 0)
            {
                HeroesToManage.Sort(SortHeroesByTurnPriority);
                HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                herosChoice = new HandleTurn();
                AttackPanel.SetActive(true);
                PlayerInput = HeroGUI.WAITING;
            }
            break;
        }

        case (HeroGUI.WAITING):
        {
            // idle state

            break;
        }

        case (HeroGUI.INPUT1):
        {
            // not used yet
            break;
        }

        case (HeroGUI.INPUT2):
        {
            // not used yet
            break;
        }

        case (HeroGUI.DONE):
        {
            HeroInputDone();
            break;
        }
        } // switch (HeroInput)
    }     // void Update()