Example #1
0
        /// <summary>
        /// boss's A.I. function.
        /// attacks when the attack objective is within the shooting range.
        /// Otherwise, it searches for an attack object again.
        /// </summary>
        /// <param name="aiBase">current A.I.</param>
        /// <param name="gameTime"></param>
        public override void OnAIAttackEvent(AIBase aiBase, GameTime gameTime)
        {
            bool fired = false;

            MoveStop();

            //  The enmey weapon reloading
            if (CurrentWeapon.CurrentAmmo == 0 && !IsFiring && !IsReloading)
            {
                ActionReload(CurrentWeapon);
            }
            else if (CurrentWeapon.IsPossibleToFire())
            {
                //  Attack action
                if (currentAction == Action.Melee)
                {
                    //  Waiting for ready to first fire
                    if (this.actionElapsedTime >=
                        CurrentWeapon.SpecData.FireDelayTimeTillFirst)
                    {
                        this.actionElapsedTime = 0.0f;

                        WeaponFire();

                        fired = true;
                    }
                    else
                    {
                        this.actionElapsedTime +=
                            (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                }
                else
                {
                    ActionMelee();

                    CurrentWeapon.StopFireSound();
                }
            }

            if (!aiBase.IsActive && fired)
            {
                SetNextAI(AIType.Search, 0.2f);
            }
        }
Example #2
0
        /// <summary>
        /// tank's A.I. function.
        /// attacks when the attack objective is within the shooting range.
        /// Otherwise, it searches for an attack object again.
        /// </summary>
        /// <param name="aiBase">current A.I.</param>
        /// <param name="gameTime"></param>
        public override void OnAIAttackEvent(AIBase aiBase, GameTime gameTime)
        {
            MoveStop();

            //  The enmey weapon reloading
            if (CurrentWeapon.CurrentAmmo == 0 && !IsFiring && !IsReloading)
            {
                ActionReload(CurrentWeapon);
            }
            else if (CurrentWeapon.IsPossibleToFire())
            {
                //  If weapon fired, just action fire
                ActionFire();

                WeaponFire();
            }

            turretAngleSpeed = 0.0f;
            SetNextAI(AIType.Search, HelperMath.RandomNormal());
        }
Example #3
0
        /// <summary>
        /// mech's A.I. function.
        /// attacks an attack objective if it is within shooting range.
        /// If not, searches for an attack objective again.
        /// </summary>
        /// <param name="aiBase">current A.I.</param>
        /// <param name="gameTime"></param>
        public override void OnAIAttackEvent(AIBase aiBase, GameTime gameTime)
        {
            MoveStop();

            //  The enmey weapon reloading
            if (CurrentWeapon.CurrentAmmo == 0 && !IsFiring && !IsReloading)
            {
                ActionReload(CurrentWeapon);
            }
            else if (CurrentWeapon.IsPossibleToFire())
            {
                //  Attack action
                if (currentAction == Action.Fire)
                {
                    //  Waiting for ready to first fire
                    if (this.fireDelayElapsedTime >=
                        CurrentWeapon.SpecData.FireDelayTimeTillFirst)
                    {
                        this.fireDelayElapsedTime = 0.0f;

                        WeaponFire();
                    }
                    else
                    {
                        this.fireDelayElapsedTime +=
                            (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                }
                else
                {
                    ActionFire();
                }
            }

            if (!aiBase.IsActive && currentAction != Action.Fire)
            {
                SetNextAI(AIType.Search, HelperMath.RandomNormal());
            }
        }