예제 #1
0
    void Update()
    {
        //controls for the monster -------------------------------------------
        if (_enemyControllerScript.WhatShouldSpawn.Equals("Monster"))
        {
            //monster is dead
            if (EnemyHealth <= 0)
            {
                EnemyIsDead();
                _enemyControllerScript.PlayerVictorious = true;
            }

            //check if monster is walking (used for animation)
            if (_enemyIsSpawned && (_enemyIsAttacking == false) && EnemyHealth > 0)
            {
                _offset = transform.position - _lastPos;
                if (_offset.x > _threshold)
                {
                    _lastPos = transform.position;
                    _animator.SetBool("Swims Left", false);
                    _animator.SetBool("Swims Right", true);
                }
                else if (_offset.x < _threshold)
                {
                    _lastPos = transform.position;
                    _animator.SetBool("Swims Right", false);
                    _animator.SetBool("Swims Left", true);
                }
                else
                {
                    _animator.SetBool("Swims Right", false);
                    _animator.SetBool("Swims Left", false);
                }
            }

            //monster begins with his movement
            if (_enemyIsSpawned && !_enemyIsAttacking && EnemyHealth > 0)
            {
                _pathfinderScript.ChooseWhichWaypointToGo();
            }

            //monster move to start position after it spawned
            if (!_enemyIsSpawned && !_enemyIsAttacking && EnemyHealth > 0)
            {
                MoveToSpawnPosition();
            }

            //monster attack
            if (_enemyIsSpawned && EnemyHealth > 0)
            {
                if (_attackTime < TimeUntilAttack)
                {
                    StartAttackTimer();
                    FillAttackBar();
                }
                else if (_attackTime >= TimeUntilAttack)
                {
                    _animator.SetBool("isAttacking", true);
                    _enemyIsAttacking = true;
                    _animator.SetBool("Attacks", true);
                }
            }
        }


        //controls for the eel ---------------------------------------
        if (_enemyControllerScript.WhatShouldSpawn.Equals("Eel"))
        {
            //monster is dead
            if (EnemyHealth <= 0)
            {
                EnemyIsDead();
                _enemyControllerScript.PlayerVictorious = true;
            }

            //monster attack
            if (_enemyIsSpawned && EnemyHealth > 0)
            {
                if (_attackTime < TimeUntilAttack)
                {
                    StartAttackTimer();
                    FillAttackBar();
                }
                else if (_attackTime >= TimeUntilAttack)
                {
                    _enemyIsAttacking = true;
                    _animator.SetBool("Attacks", true);
                }
            }
        }

        //controls for the kraken ---------------------------------------
        if (_enemyControllerScript.WhatShouldSpawn.Equals("Kraken"))
        {
            //monster is dead
            if (EnemyHealth <= 0)
            {
                EnemyIsDead();
                _enemyControllerScript.PlayerVictorious = true;
            }

            //monster attack
            if (_enemyIsSpawned && EnemyHealth > 0)
            {
                if (_attackTime < TimeUntilAttack)
                {
                    StartAttackTimer();
                    FillAttackBar();
                }
                else if (_attackTime >= TimeUntilAttack)
                {
                    _enemyIsAttacking = true;
                    _animator.SetBool("Attacks", true);
                }
            }
        }
    }