Example #1
0
 //=======================================================================================
 //                              >  Update Functions <
 //=======================================================================================
 //-----------------------------------Attack-----------------------------------------
 //Attack enemy
 private void attack()
 {
     if (_enemyCombat.currentAction == EnemyCombat.FIGHTACTION.NOTHING)
     {
         _enemyStats.hp--;
         _combatSounds.playSound(0);
         lastAttack = timer;
     }
     else
     {
     }
 }
    //-----------------------------------ÇoncludeAction------------------------------------------
    //Concludes the action of the monster, whether it damages or not
    public void concludeAction()
    {
        float randomBuffer = UnityEngine.Random.Range(0f, maxRandomBuffer);

        _currentBuffer += Time.deltaTime;

        if (_tutorialEnemy == null)
        {
            if (_currentBuffer > bufferTime + randomBuffer)
            {
                _currentBuffer = 0f;
                playerHasActed = false;
                if (currentAction != FIGHTACTION.NOTHING)
                {
                    if (!attackFailed)
                    {
                        _playerStats.hp--;
                        CombatSounds playerSounds = _player.GetComponent <CombatSounds>();

                        if (_playerStats.hp <= 0)
                        {
                            playerSounds.playSound(4);
                        }
                        else
                        {
                            playerSounds.playSound(3);
                        }
                    }
                }
                goToNextAction();
            }
        }

        //TUTORIAL ENEMY CONCLUDE ACTION

        //Tutorial, tutorial, Left, Tutorial, Right, Tutorial, Slash, Tutorial, Right, Bash, Left, Tutorial, Attack
        else if (_currentBuffer > bufferTime + randomBuffer)
        {
            _currentBuffer = 0f;
            playerHasActed = false;
            if (currentAction != FIGHTACTION.NOTHING && currentAction != FIGHTACTION.TUTORIAL)
            {
                if (!attackFailed)
                {
                    CombatSounds playerSounds = _player.GetComponent <CombatSounds>();

                    if (_playerStats.hp <= 0)
                    {
                        playerSounds.playSound(4);
                    }
                    else
                    {
                        playerSounds.playSound(3);
                    }
                }
            }

            if (!attackFailed && (_actionIndex == 2 || _actionIndex == 4 || _actionIndex == 6))
            {
                if (_actionIndex == 2)
                {
                    goToNextAction(1);
                }
                if (_actionIndex == 4)
                {
                    goToNextAction(3);
                }
                if (_actionIndex == 6)
                {
                    goToNextAction(5);
                }
            }

            else
            {
                goToNextAction();
            }
        }
    }