Пример #1
0
        public override void Update(GameTime gameTime)
        {
            switch (SpaceMineState)
            {
                default:
                case CoreTypes.SpaceMineState.Stowed:
                    //Mine is stowed on board the ship, ready to be deployed

                    break;

                case CoreTypes.SpaceMineState.Deploying:
                    //Mine is deploying - set position, rotation, etc
                    if (StateManager.Options.SFXEnabled)
                    {
                        DeploySound.Play();
                    }
                    Position = ParentShip.WorldCoords;
                    UseCenterAsOrigin = true;

                    SpaceMineState = CoreTypes.SpaceMineState.Deployed;

                    break;

                case CoreTypes.SpaceMineState.Deployed:
                    //Mine is deployed; start countdown to arm the mine

                    RemainingArmTime -= gameTime.ElapsedGameTime;
                    if (RemainingArmTime.Milliseconds <= 0)
                    {
                        SpaceMineState = CoreTypes.SpaceMineState.Armed;
                    }

                    break;

                case CoreTypes.SpaceMineState.Armed:
                    //Mine is armed; Wait for enemy
                    Rotation.Radians += .2f;
                    foreach (Ship ship in StateManager.EnemyShips)
                    {
                        checkIfShipHitMine(ship);
                    }

                    //Ally and player ships can also be hurt by the mine
                    foreach (Ship ship in StateManager.AllyShips)
                    {
                        checkIfShipHitMine(ship);
                    }

                    break;

                case CoreTypes.SpaceMineState.RIP:

                    FireKilledEvent();
                    break;

            }

            base.Update();
        }
Пример #2
0
        private void checkIfShipHitMine(Ship ship)
        {
            if (ship is Drone)
            {
                if (ship.Cast<Drone>().DroneState == DroneState.Stowed || ship.Cast<Drone>().DroneState == DroneState.RIP)
                {
                    return;
                }
            }

            if (Intersects(ship.WCrectangle))
            {
                ship.CurrentHealth -= this.Damage;
                if(StateManager.Options.SFXEnabled)
                {
                    ExplosionSound.Play();
                }
                SpaceMineState = CoreTypes.SpaceMineState.RIP;
            }
        }