Esempio n. 1
0
    void Update()
    {
        switch (currentState)
        {
        case BattleStates.START:
            //setup Combat
            //Choix de celui qui commence
            cooldownStart = false;

            if (battleStartState.PlayerGoesFirst(OmniEnemy.Instance.agility, OmniPlayer.Instance.agility))
            {
                if (start)
                {
                    CombatFlow.cl.cUI.animTurn = CombatUI.AnimationTurn.PlayerTurn;
                    start = false;
                }
                goto case BattleStates.PLAYERCHOICE;
            }
            else
            {
                if (start)
                {
                    CombatFlow.cl.cUI.animTurn = CombatUI.AnimationTurn.EnnemiTurn;
                    CombatFlow.cl.cUI.Show_HideActionContainer();
                    start = false;
                }
                goto case BattleStates.ENEMYCHOICE;
            }

        case BattleStates.PLAYERCHOICE:
            //choix de l'action du joueur
            if (OmniPlayer.Instance.currentHP <= 0)
            {
                if (!cooldownStart)
                {
                    CombatFlow.cl.cUI.DieAnimation(CombatUI.AnimationTurn.PlayerTurn);
                    cooldownStart = true;
                    StartCoroutine(EndBattle(BattleStates.LOSE));
                }
            }
            else if (OmniEnemy.Instance.currentHP <= 0)    // si vie de l'ennemi a 0 win state
            {
                if (!cooldownStart)
                {
                    CombatFlow.cl.cUI.DieAnimation(CombatUI.AnimationTurn.EnnemiTurn);
                    cooldownStart = true;
                    goto case BattleStates.LVLUPCHECK;
                }
            }
            break;

        case BattleStates.ENEMYCHOICE:
            //choix de l'action de l'ennemi
            cooldown -= Time.deltaTime;    // timer so animation can take place
            if (cooldown < 0)
            {
                damage = (int)CombatLogics.Attack(CombatFlow.cl.EnemyCharacter, CombatFlow.cl.PlayerCharacter);
                GetDamageFromEnemy(OmniPlayer.Instance, damage);
                CombatFlow.cl.cUI.AttackAnimation();
                cooldown = 2;
            }

            if (OmniPlayer.Instance.currentHP <= 0)
            {
                if (!cooldownStart)
                {
                    CombatFlow.cl.cUI.DieAnimation(CombatUI.AnimationTurn.PlayerTurn);
                    cooldownStart = true;
                    StartCoroutine(EndBattle(BattleStates.LOSE));
                }
            }
            else if (OmniEnemy.Instance.currentHP <= 0)    // si vie de l'ennemi a 0 win state
            {
                if (!cooldownStart)
                {
                    CombatFlow.cl.cUI.DieAnimation(CombatUI.AnimationTurn.EnnemiTurn);
                    cooldownStart = true;
                    goto case BattleStates.LVLUPCHECK;
                }
            }
            break;

        case BattleStates.LOSE:
            OmniPlayer.Instance.characterLevel = 0;
            SceneManager.LoadScene("GameOver");
            break;

        case BattleStates.WIN:
            SceneManager.LoadScene("GameScene");
            break;

        case BattleStates.ESCAPE:
            SceneManager.LoadScene("GameScene");
            break;

        case BattleStates.LVLUPCHECK:
            if (!hasAddedXP)
            {
                OmniPlayer.Instance.experience += OmniEnemy.Instance.experience;
                hasAddedXP = true;
                if (OmniPlayer.Instance.experience >= OmniPlayer.Instance.maxExperience)
                {
                    GetNewLvl();
                }
                StartCoroutine(EndBattle(BattleStates.WIN));
            }
            break;

        default:
            break;
        }

        Debug.Log(currentState);
    }