コード例 #1
0
        public override BossState Update(WhiteBossController boss)
        {
            Debug.Log("attack");

            Vector3 vectorToPlayer = boss.VectorToAttackTarget();

            Vector3 dirToPlayer = vectorToPlayer.normalized;

            boss.transform.position += dirToPlayer * boss.speed * Time.deltaTime * 2;

            /*timeUntilNextShot -= Time.deltaTime;
             * if(timeUntilNextShot <=0)
             * {
             *  boss.ShootProjectile();
             *  timeUntilNextShot = timeBetweenShots;
             * }
             *
             * boss.ShootProjectile();*/

            //if (!boss.CanSeeAttackTarget()) return new BossStateIdle(); // if the player gets too far away from the enemy return the enemy to idle

            // switch to retreat state
            // once the boss has finished its attack, it retreats a short distance away from the player

            // switch to dead state

            return(null);
        }
コード例 #2
0
        public override BossState Update(WhiteBossController boss)
        {
            // move towards player:
            Vector3 vectorToPlayer = boss.VectorToAttackTarget();

            Vector3 dirToPlayer = vectorToPlayer.normalized;

            boss.transform.position += dirToPlayer * boss.speed * Time.deltaTime;

            /////////////////////////// TRANSITIONS:

            if (vectorToPlayer.sqrMagnitude < boss.pursueDistanceThreshold * boss.pursueDistanceThreshold)
            {
                return(new BossStateAttack());                                                                                          // if dis < threshold transition to attack
            }
            //if (!boss.CanSeeAttackTarget()) return new BossStateIdle(); // if we can't see the player transition to idle

            // switch to attack state

            // switch to dead state
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// This function updates the boss each frame.
        /// </summary>
        /// <param name="boss"> The boss that this state applies to. </param>
        /// <returns> A new state. </returns>
        public override BossState Update(WhiteBossController boss)
        {
            Debug.Log("attack");

            Vector3 vectorToPlayer = boss.VectorToAttackTarget();

            timeUntilNextShot -= Time.deltaTime;
            if(timeUntilNextShot <=0)
            {
                boss.ShootProjectile();
                timeUntilNextShot = timeBetweenShots;
            } // ends the if statement

            boss.ShootProjectile();

            if (!boss.CanSeeAttackTarget()) return new BossStateIdle(); // if the player gets too far away from the enemy return the enemy to idle

            // switch to retreat state
            // once the boss has finished its attack, it retreats a short distance away from the player

            // switch to dead state

            return null;
        } // ends the Update() function