/// <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); } }