Beispiel #1
0
 /// <summary>
 /// Checks if the battle has been won or lost.
 /// </summary>
 public void EndBattle()
 {
     if (PlayerStats.stats.currHealth <= 0 && PlayerStats.stats.currHealth2 <= 0)
     {
         currentState = BattleTurns.LOSE;            //all fights start with P1
         endBattle    = true;
     }
     if (EnemyStats.stats.currentHealth <= 0)
     {
         currentState = BattleTurns.WIN;
         endBattle    = true;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Used to swap which player is active
 /// </summary>
 public void swapAction()
 {
     if (canSwap)
     {
         if (currentState.Equals(BattleTurns.P1))
         {
             currentState = BattleTurns.P2;
         }
         else if (currentState.Equals(BattleTurns.P2))
         {
             currentState = BattleTurns.P1;
         }
     }
 }
Beispiel #3
0
    void Update()
    {
        //Players can only swap places if neither have moved yet
        if (!p1HasMoved && !p2HasMoved)
        {
            canSwap = true;
        }
        else
        {
            canSwap = false;
        }

        //switch states depending on person's turn
        switch (currentState)
        {
        case (BattleTurns.P1):
            p2Menu.SetActive(false);
            p2TestAction.SetActive(false);

            if (!p1HasMoved)
            {
                p1TestAction.SetActive(true);
                p1Menu.SetActive(true);
                GPMovesAvailable();
            }
            //If p1 has done an action, switch to the new turn
            if (p1HasMoved && playerTurn)
            {
                EndBattle();
                if (!endBattle)
                {
                    playerTurn = false;
                    if (!p2HasMoved)
                    {
                        currentState = BattleTurns.P2;
                    }
                    else
                    {
                        frontPlayer  = "P2";                               //p2 moved already, so they went first
                        currentState = BattleTurns.ENEMY;
                    }
                }
            }

            break;

        case (BattleTurns.P2):
            p1Menu.SetActive(false);
            p1TestAction.SetActive(false);

            p2TestAction.SetActive(true);
            p2Menu.SetActive(true);

            if (p2HasMoved && playerTurn)
            {
                EndBattle();
                if (!endBattle)
                {
                    playerTurn = false;
                    if (!p1HasMoved)
                    {
                        currentState = BattleTurns.P1;
                    }
                    else
                    {
                        frontPlayer  = "P1";                               //p1 first to move
                        currentState = BattleTurns.ENEMY;
                    }
                }
            }

            break;

        case (BattleTurns.ENEMY):
            Debug.Log("Enemy turn now");
            p1Menu.SetActive(false);
            p2Menu.SetActive(false);
            p1TestAction.SetActive(false);
            p2TestAction.SetActive(false);

            CreateNotes.instance.EnemyAttack();

            //restart turn order after action
            p1HasMoved = false;
            p2HasMoved = false;
            playerTurn = false;
            EndBattle();
            if (!endBattle)                    //if not a win/loss, continue the battle
            {
                currentState = BattleTurns.P1;
            }

            break;

        case (BattleTurns.LOSE):
            p1Menu.SetActive(false);
            p2Menu.SetActive(false);
            loseText.SetActive(true);
            break;

        case (BattleTurns.WIN):
            p1Menu.SetActive(false);
            p2Menu.SetActive(false);
            winText.SetActive(true);

            Debug.Log("Last Scene " + LevelLoader.ThisIsTheOnlyOne.LastScene);
            LevelLoader.ThisIsTheOnlyOne.LoadScene(LevelLoader.ThisIsTheOnlyOne.LastScene, false);
            break;
        }
    }