Пример #1
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (BattleStates.START):
            battleStateStart.PrepareBattle();
            break;

        case (BattleStates.PLAYER_TURN):
            currentTurnOwner = BattleStates.PLAYER_TURN;
            break;

        case (BattleStates.ENEMY_TURN):

            if (!_hasStun && !_hasSleep)
            {
                currentTurnOwner = BattleStates.ENEMY_TURN;
                battleStateEnemyTurn.TakeTurn();
            }
            else
            {
                CheckForStatusEffect();
            }
            //enemyCompletedTurn = true;
            //CheckTurnOwner ();
            break;

        case (BattleStates.CALCULATE_DAMAGE):
            sm.PlaySingleEfx(1);
            if (currentTurnOwner == BattleStates.PLAYER_TURN)
            {
                if (battleCalculations.GetPlayerAbilityCost(playerAbility) <= battleScreenManager._playerAmbition)
                {
                    ApplyStatusEffect(playerAbility.AbilityStatusEffect);

                    playerAnimator.SetTrigger("isAttacking");
                    battleScreenManager._enemyHealth    -= battleCalculations.CalculateTotalPlayerDamage(playerAbility);
                    battleScreenManager._playerAmbition -= battleCalculations.GetPlayerAbilityCost(playerAbility);
                }

                if (_hasStun || _hasSleep)
                {
                    enemyCompletedTurn = true;
                }

                if (battleScreenManager._enemyHealth <= 0)
                {
                    currentState = BattleStates.WIN;
                    Debug.Log("Won the battle!");
                    break;
                }
            }
            if (currentTurnOwner == BattleStates.ENEMY_TURN)
            {
                if (!_hasStun && !_hasSleep)
                {
                    enemyAnimator.SetTrigger("isAttacking");
                    battleScreenManager._playerHealth  -= battleCalculations.CalculateTotalEnemyDamage(enemyAbility);
                    battleScreenManager._enemyAmbition -= battleCalculations.GetEnemyAbilityCost(enemyAbility);
                }
                else
                {
                    break;
                }

                if (battleScreenManager._playerHealth <= 0)
                {
                    currentState = BattleStates.LOSE;
                    battleScreenManager.LoseDebate();
                    break;
                }
            }
            CheckTurnOwner();
            break;

        // case (BattleStates.ADD_STATUS_EFFECTS):
        //  battleStateAddStatusEffectsScript.CheckAbilityForStatusEffect (playerUsedAbility);
        //  break;
        case (BattleStates.END_TURN):
            totalTurnCount = totalTurnCount + 1;
            Debug.Log(totalTurnCount);
            playerCompletedTurn = false;
            enemyCompletedTurn  = false;

            if (battleStateStart._playerEloquence > battleStateStart._enemyEloquence)
            {
                currentState = BattleStates.PLAYER_TURN;
            }
            else
            {
                currentState = BattleStates.ENEMY_TURN;
            }
            break;

        case (BattleStates.LOSE):
            //battleScreenManager.LoseBattle();
            break;

        case (BattleStates.WIN):
            Debug.Log(BattleScreenManager.isQuest);
            if (BattleScreenManager.isQuest)
            {
                battleScreenManager.WinBattleFromQuest();
            }
            else
            {
                battleScreenManager.WinBattleFromEvent();
            }
            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        Debug.Log(currentState);
        switch (currentState)
        {
        case (BattleStates.START):
            //setup battle function
            //create enemy
            battleStateStartScript.PrepareBattle();
            break;

        case (BattleStates.PLAYER_TURN):
            currentTurnOwner = BattleStates.PLAYER_TURN;
            break;

        case (BattleStates.ENEMY_TURN):
            currentTurnOwner = BattleStates.ENEMY_TURN;
            battleStateEnemyTurnScript.EnemyTakeTurn();
            //enemyCompletedTurn = true;
            //CheckTurnOwner ();
            break;

        case (BattleStates.CALCULATE_DAMAGE):
            if (currentTurnOwner == BattleStates.PLAYER_TURN)
            {
                battleFunctionsScript.enemyCurrentHealth  -= battleCalculationsScript.CalculateTotalPlayerDamage(playerUsedAbility);
                battleFunctionsScript.playerCurrentEnergy -= battleCalculationsScript.GetEnergyCost(playerUsedAbility);

                if (battleFunctionsScript.enemyCurrentHealth <= 0)
                {
                    currentState = BattleStates.WIN;
                    Debug.Log("Won the battle!");
                    break;
                }
            }
            if (currentTurnOwner == BattleStates.ENEMY_TURN)
            {
                battleFunctionsScript.playerCurrentHealth -= battleCalculationsScript.CalculateTotalEnemyDamage(enemyUsedAbility);

                if (battleFunctionsScript.playerCurrentHealth <= 0)
                {
                    currentState = BattleStates.LOSE;
                    Debug.Log("Lost the battle!");
                    break;
                }
            }
            CheckTurnOwner();
            break;

        case (BattleStates.ADD_STATUS_EFFECTS):
            battleStateAddStatusEffectsScript.CheckAbilityForStatusEffect(playerUsedAbility);
            break;

        case (BattleStates.END_TURN):
            totalTurnCount++;
            playerCompletedTurn = false;
            enemyCompletedTurn  = false;

            currentState = BattleStates.PLAYER_TURN;
            break;

        case (BattleStates.LOSE):
            GameOver();
            break;

        case (BattleStates.WIN):
            GameInformation.WonFight = true;
            ReturnToMap();
            break;
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log(currentState);
        switch (currentState)
        {
        case (BattleStates.START):
            //set up battle function??
            //create enemy
            battleStateStartScript.PrepareBattle();
            //choose who goes first based on luck
            break;

        case (BattleStates.PLAYERCHOICE):               //player chooses ability they wanna use
            currentUser = BattleStates.PLAYERCHOICE;
            break;

        case (BattleStates.ENEMYCHOICE):
            //Coded AI goes here.
            currentUser = BattleStates.ENEMYCHOICE;
            battleStateEnemyChoiceScript.EnemyCompleteTurn();
            //enemyDidCompleteTurn = true;
            //CheckWhoGoesNext();
            break;

        case (BattleStates.CALCDAMAGE):                 // we calc damage done by player, look for existing status effects and add that damage
            if (currentUser == BattleStates.PLAYERCHOICE)
            {
                battleCalcScript.CalculateTotalPlayerDamage(playerUsedAbility);
            }

            if (currentUser == BattleStates.ENEMYCHOICE)
            {
                battleCalcScript.CalculateTotalEnemyDamage(enemyUsedAbility);
            }
            //Debug.Log ("CALCULATING DAMAGE");
            CheckWhoGoesNext();
            break;

        case (BattleStates.ADDSTATUSEFFECTS):                   // we try to add a status effect, if it exists.
            battleStateAddStatusEffectsScript.CheckAbilityForStatusEffects(playerUsedAbility);
            break;

        case (BattleStates.ENDTURN):
            totalTurnCount       += 1;
            playerDidCompleteTurn = false;
            enemyDidCompleteTurn  = false;

            Debug.Log(totalTurnCount);

            currentState = firstTurn;             //switch back to whoever went first.
            break;

        case (BattleStates.LOSE):
            break;

        case (BattleStates.WIN):
            Debug.Log("WON!!!!");
            if (!hasAddedXP)
            {
                IncreaseExperience.AddExperience();
                hasAddedXP = true;
            }
            GameInformation.BattleWon = true;
            SceneManager.LoadScene(GameInformation.PreviousScene);
            SaveInformation.SaveAllInformation();
            break;
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            thetext.text = logMessages [i];
            if (i < logMessages.Count - 1)
            {
                i++;
            }
            else
            {
                //box.SetActive(false);
            }
        }

        switch (currentState)
        {
        case (BattleStates.start):
            BattleStateStartScript.PrepareBattle();
            break;

        case (BattleStates.playerChoice):
            showLogMessage("Your Health is " + GameInformation.PlayerHealth);
            showLogMessage("The Enemy Health is " + GameInformation.EnemyHealth);
            currentUser = BattleStates.playerChoice;
            break;

        case (BattleStates.enemyChoice):
            //enemyDidCOmpleteTurn = true;
            showLogMessage("Enemy Turn");

            currentUser = BattleStates.enemyChoice;
            battleStateEnemyChoiceScript.EnemyCompleteTurn();
            break;

        case (BattleStates.calcDamage):
            if (currentUser == BattleStates.playerChoice)
            {
                battleCalcScript.CalculateTotalPlayerDamage(playerUsedAbility);
                showLogMessage("Enemy has taken " + battleCalcScript.totalPlayerDamage + " Damage!");

                GameInformation.EnemyHealth = (int)(GameInformation.EnemyHealth - battleCalcScript.totalPlayerDamage);
                showLogMessage("Enemy health now is " + GameInformation.EnemyHealth);
            }
            if (currentUser == BattleStates.enemyChoice)
            {
                battleCalcScript.CalculateTotalEnemyDamage(enemyUsedAbility);
                showLogMessage("You have taken " + battleCalcScript.totalEnemyDamage + " Damage!");

                GameInformation.PlayerHealth = (int)(GameInformation.PlayerHealth - battleCalcScript.totalEnemyDamage);
                showLogMessage("Your health now is " + GameInformation.PlayerHealth);
            }
            //battleCalcScript.CalculateTotalPlayerDamage (playerUsedAbility);
            CheckWhoGoesNext();
            break;

        case (BattleStates.addStatusEffects):
            //Debug.Log ("Checking for Status Effects");
            battleStateAddStatusEffectsScript.CheckAbilityForStatusEffects(playerUsedAbility);
            break;

        case (BattleStates.lose):
            showLogMessage("You lose");
            break;

        case (BattleStates.endturn):
            //GameInformation.DebugLogText = " ";
            totalTurnCount       += 1;
            playerDidCompleteTurn = false;
            enemyDidCOmpleteTurn  = false;
            if (GameInformation.EnemyHealth > 0 && GameInformation.PlayerHealth > 0)
            {
                showLogMessage("Your Turn!");
                currentState = CombatController.BattleStates.playerChoice;
            }
            else if (GameInformation.EnemyHealth <= 0)
            {
                currentState = CombatController.BattleStates.win;
            }
            else if (GameInformation.PlayerHealth <= 0)
            {
                currentState = CombatController.BattleStates.lose;
            }
            break;

        case (BattleStates.win):
            showLogMessage("You won!");
            break;
        }
    }