Exemplo n.º 1
0
    public void turnManager()
    {
        if (turnIndex >= turnQueueLength)
        {
            turnIndex = 0;
        }

        /////////////////
        // VICTORY !!! //
        /////////////////
        if (state == BattleState.WON)
        {
            //////////////////////////////////////////
            // Configure the victory screen here... //
            //////////////////////////////////////////

            if (Input.GetKeyUp(KeyCode.Return))
            {
                player_properties.updateStats(true);
                SceneManager.LoadScene("SampleScene");
            }
            Debug.Log(victoryScreen.transform.position);
        }

        /// *** THIS BLOCK WILL DECIDE WHO WILL GO NEXT... ***
        /// *** THIS WILL CHANGE LATER ONCE OTHER PARTY MEMBERS ARE ADDED ***
        if (state == BattleState.DECIDETURN)
        {
            if (turnQueue[turnIndex].name == "Final_Jerry_Battle")
            {
                state = BattleState.PLAYERPARTYTURNSTART;
            }
            else
            {
                state = BattleState.ENEMYPARTYTURN;
            }
            if (enemy_properties.getSize() < 1)
            {
                state = BattleState.WON;
                Vector3 victoryScreenPos = new Vector3(player.transform.position.x + 13f, player.transform.position.y - 4f);

                victoryScreen            = Instantiate(victoryScreen, victoryScreenPos, Quaternion.identity);
                victoryScreen_properties = victoryScreen.GetComponent <VictoryScreen>();
                configureVictoryScreen();
            }
        }

        /***************************************************
         *******************#PLAYER TURN#********************
         ****************************************************/
        else if (state == BattleState.PLAYERPARTYTURNSTART)
        {
            Vector3 playerNamePos = new Vector3(playerName.transform.position.x + 3f, playerName.transform.position.y, 0f);
            cursor = UI_properties.insCursor(playerNamePos);
            state  = BattleState.PLAYERPARTYTURN;
        }
        else if (state == BattleState.PLAYERPARTYTURN)
        {
            if (Input.GetKeyUp(KeyCode.Return))
            {
                Vector3 abilityListPos = new Vector3(playerName.transform.position.x + 5.8f, playerName.transform.position.y - 1.38f, 0f);
                abilityList = UI_properties.insAbilityMenu(abilityListPos);
                cursor.transform.position = initButtons()[0];
                state     = BattleState.PARTYSELECTACTION;
                buttonArr = initButtons();
            }
        }
        else if (state == BattleState.PARTYSELECTACTION)
        {
            changeActionSelection(cursor, buttonArr, initEnemyArray()[0]);
        }
        else if (state == BattleState.PARTYSELECTENEMY)
        {
            changeEnemySelection(cursor, initEnemyArray(), BattleState.PARTYATTACKSTART);
            player_initial_start_time = Time.time;
            player_travel_length      = Vector3.Distance(player.transform.position, initEnemyArray()[buttonSelectIndex]);
        }
        else if (state == BattleState.PARTYATTACKSTART)
        {
            // ***PLAYER MOVES TOWARDS THE ENEMY***
            move(player, player_original_position, travel_to, player_initial_start_time, player_travel_length);
            player_properties.setAllAnimFalseBut("walk_right");
            if (player.transform.position == travel_to)
            {
                player_properties.setAllAnimFalseBut("attack");
                state = BattleState.PARTYATTACKING;
                enemyChosen_properties.takeDamage(player_properties.getAttack());
            }
        }
        else if (state == BattleState.PARTYATTACKING)
        {
            if (Math.Round(player_properties.getNormTime(), 2) > 0.55 && displayDamage)
            {
                floating_damage_number.insDam(enemyChosen, enemyChosen_properties.getDamageTaken());
                displayDamage = false;
                if (enemyChosen_properties.getHealth() <= 0)
                {
                    killEnemy(enemyChosen);
                }
            }

            if (!player_properties.getAnimState())
            {
                state = BattleState.PARTYATTACKEND;
                player_initial_start_time = Time.time;
                player_properties.setAllAnimFalseBut("walk_left");
            }
        }
        else if (state == BattleState.PARTYATTACKEND)
        {
            ///////////////////////////////////////
            // I HATE THAT I HAVE TO USE THIS... //
            ///////////////////////////////////////
            displayDamage = true;
            // ***PLAYER MOVES BACK TO ORIGINAL SPOT*** //
            move(player, travel_to, player_original_position, player_initial_start_time, player_travel_length);
            if (player.transform.position == player_original_position)
            {
                player_properties.setAllAnimFalseBut("idle");
                state = BattleState.DECIDETURN;
                turnIndex++;
            }
        }
        else if (state == BattleState.PARTYSELECTITEM)
        {
            if (Input.GetKeyUp(KeyCode.Return))
            {
                state = BattleState.DECIDETURN;
                Destroy(cursor);
                Destroy(abilityList);
                turnIndex++;
            }
        }

        /***************************************************
         ****************************************************
         ****************************************************/

        /***************************************************
        *******************#ENEMY TURN#********************
        ***************************************************/
        else if (state == BattleState.ENEMYPARTYTURN)
        {
            currentEnemy            = turnQueue[turnIndex];
            currentEnemy_properties = currentEnemy.GetComponent <BattleEnemy>();
            enemy_original_position = currentEnemy.transform.position;
            enemy_travel_length     = Vector3.Distance(currentEnemy.transform.position, player.transform.position);
            state = BattleState.ENEMYSELECTACTION;
        }
        else if (state == BattleState.ENEMYSELECTACTION)
        {
            // **I'll put enemy abilites here later... but for now...**
            state = BattleState.ENEMYATTACKSTART;
            Vector3 modPlayerPos = player.transform.position;
            enemy_attack_pos         = new Vector3(modPlayerPos.x + 0.2f, modPlayerPos.y - 2.8f);
            enemy_initial_start_time = Time.time;
        }
        else if (state == BattleState.ENEMYATTACKSTART)
        {
            move(currentEnemy, enemy_original_position, enemy_attack_pos, enemy_initial_start_time, enemy_travel_length);
            if (currentEnemy.transform.position == enemy_attack_pos)
            {
                player_properties.takeDamage(currentEnemy_properties.getAttack());
                floating_damage_number.insDam(player, player_properties.getDamageTaken());
                state = BattleState.ENEMYATTACKEND;
                enemy_initial_start_time = Time.time;
            }
        }
        else if (state == BattleState.ENEMYATTACKEND)
        {
            move(currentEnemy, enemy_attack_pos, enemy_original_position, enemy_initial_start_time, enemy_travel_length);
            if (currentEnemy.transform.position == enemy_original_position)
            {
                state = BattleState.DECIDETURN;
                turnIndex++;
            }
        }

        /***************************************************
         ****************************************************
         ****************************************************/
    }