public void CheckForShipAward(StarShip starShip)
        {
            if (extrasList.Count == 0)
                return;

            Extra.ExtraType extra = CheckForHitExtra(starShip);

            switch (extra) {
                case Extra.ExtraType.PhotonAmmo: //A
                    starShip.PhotonAmmo += 25;
                    break;

                case Extra.ExtraType.Weapons: //W
                    if (starShip.MaxWeapon < Weapon.Photon3)
                        starShip.MaxWeapon++;

                    //starShip.Weapon = starShip.MaxWeapon; //now using StarShip.AutoSelectMaxWeapon()
                    break;

                case Extra.ExtraType.Hundred: //100
                    InvasionGame.Scoreboard.Score += 100;
                    break;

                case Extra.ExtraType.BlasterAmmo: //B
                    starShip.LaserAmmo += 40;
                    break;

                case Extra.ExtraType.Shield: //S
                    starShip.Shield += 10;
                    break;
            }

            if (extra != Extra.ExtraType.NotSet)
                SoundManager.Instance.Play(gotExtraSoundEffect);
        }
Exemple #2
0
        public static IGameScreen InitNextLevel(int level, StarShip ship)
        {
            InvasionGame.Scoreboard.Level = level;

            BulletsManager.Instance.Reset();
            UFOsManager.Instance.Reset();
            ExtrasManager.Instance.Reset();

            ship.InitLevel();

            UFOsManager.Instance.SetLevel(level);
            UFOsManager.Instance.InitLevel(level);

            return GameScreen.LevelScreen;
        }
Exemple #3
0
        public Invasion(Game game)
            : base(game)
        {
            GameInProgress = false;

            // Initialize the static Instance
            Game.Components.Add(new BulletsManager(Game));
            Game.Components.Add(new ExtrasManager(Game));
            Game.Components.Add(new UFOsManager(Game));

            StarShip = new StarShip(Game);
            Game.Components.Add(StarShip);

            ContentLoader.LoadContent(Game.Content);

            TouchPanel.EnabledGestures = GestureType.None;
        }
        /// <summary>
        /// check if the ship was hit by a bullet
        /// </summary>
        /// <returns>true if the ship was hit by a bullet
        /// else false</returns>
        public bool CheckForHitShip(StarShip starShip)
        {
            if (starShip.ShipState != ShipState.OK)
                return false;

            if (bulletList.Count > 0) {
                Rectangle shipBoundingBox = starShip.BoundingBox;

                for (int iBullet = bulletList.Count-1; iBullet >= 0; iBullet--) {
                    Bullet bullet = (Bullet)bulletList[iBullet];
                    Rectangle bulletBoundingBox = bullet.BoundingBox;

                    if (bulletBoundingBox.Intersects(shipBoundingBox) &&
                        bullet.BulletSource == BulletSource.UfoPhotonBlaster)
                    {
                        bulletList.Remove(bullet);
                        return true;
                    }
                }
            }
            return false;
        }
        /// <summary>
        /// Check if the ship got an extra
        /// </summary>
        /// <returns>the value of the extra that was hit</returns>
        Extra.ExtraType CheckForHitExtra(StarShip starShip)
        {
            Extra.ExtraType hitExtra = Extra.ExtraType.NotSet;

            Rectangle shipBoundingBox = starShip.BoundingBox;

            for (int iExtra = extrasList.Count-1; iExtra >= 0; iExtra--) {
                Extra extra = (Extra)extrasList[iExtra];
                Rectangle extraBoundingBox = extra.BoundingBox;

                if (extraBoundingBox.Intersects(shipBoundingBox)) {
                    hitExtra = extra.Type;
                    extrasList.Remove(extra);
                    return hitExtra;
                }
            }
            return hitExtra;
        }