示例#1
0
    void ActionsUpdate()
    {
        if (currentWait < timeDelay)
        {
            currentWait += Time.deltaTime;
        }
        if (currentWait >= timeDelay)
        {
            if (FindObjectOfType <PlayerController>())
            {
                FindObjectOfType <PlayerController>().RefreshQuick();
            }
            // If no more States
            if (eventQueue.Count == 0 && currentState == null)
            {
                battleState = BattleState.IdleTime;
                return;
            }
            // Get new State
            if (eventQueue.Count > 0 && currentState == null)
            {
                currentState = PopTopEvent();
            }
            // Use State
            if (currentState != null)
            {
                currentState.Run();
                //Debug.Log(" => Ran Event " + currentState.ToString());
                // Clear State
                currentState = null;
            }


            currentWait = 0;
        }

        if (Input.GetButtonDown("Jump"))
        {
            currentWait = timeDelay;
        }
    }
示例#2
0
    void TurnUpdate()
    {
        switch (turnState)
        {
        case TurnState.Preturn:
            break;

        case TurnState.BeginTurn:

            currentTurn++;
            Debug.Log("Turn " + currentTurn + ".");

            foreach (Battler i in activeBattlers)
            {
                // Reset flags for battlers
                i.movedThisTurn = false;
            }

            turnState = TurnState.UpdateTurn;
            break;

        case TurnState.UpdateTurn:
            // Get new State
            if (eventQueue.Count > 0 && currentState == null)
            {
                currentState = PopTopEvent();
            }
            // Use State
            if (currentState != null)
            {
                currentState.Run();
                //Debug.Log(" => Ran Event " + currentState.ToString());
                // Clear State
                currentState = null;
            }
            // If no more States
            if (eventQueue.Count == 0 && currentState == null)
            {
                // Check for next Attacker
                Battler nextAttacker = GetNextMove();
                if (nextAttacker != null)
                {
                    // add next attackers Actions/Events to the Queue
                    // Add Attack!
                    RetargetCheck(nextAttacker);
                    //  eventQueue.Add(new BE_BattlerUseAttack(nextAttacker, nextAttacker.commandedAttack, Actives[nextAttacker.currentCommand.finalTarget]));
                    BattlerTakeTurn(nextAttacker, nextAttacker.commandedAttack);
                    // Set Flags
                    nextAttacker.movedThisTurn = true;
                    // Continue turn
                    turnState = TurnState.UpdateTurn;
                }
                else
                {
                    // If no more Attackers, end the turn
                    turnState = TurnState.EndTurn;
                }
            }

            //QueueDisplay();
            break;

        case TurnState.EndTurn:

            /*foreach (Battler i in Actives)
             * {
             *  i.currentCommand = null;
             * }*/
            timeDelay = 0;
            turnState = TurnState.Preturn;

            break;
        }
    }