ScrollingShooter.GameObjectManager.CreatePowerup C# (CSharp) Method

CreatePowerup() public method

Factory method for spawning a projectile
public CreatePowerup ( PowerupType powerupType, Vector2 position ) : ScrollingShooter.Powerup
powerupType PowerupType
position Vector2 The position of the projectile in the game world
return ScrollingShooter.Powerup
        public Powerup CreatePowerup(PowerupType powerupType, Vector2 position)
        {
            Powerup powerup;
            uint id = NextID();

            switch (powerupType)
            {
                case PowerupType.Fireball:
                    powerup = new FireballPowerup(id, content, position);
                    break;

                case PowerupType.Frostball:
                    powerup = new FrostballPowerup(id, content, position);
                    break;

                case PowerupType.BubbleBeam:
                    powerup = new BubbleBeamPowerup(id, content, position);
                    break;

                case PowerupType.Freezewave:
                    powerup = new FreezewavePowerup(id, content, position);
                    break;

                case PowerupType.Blades:
                    powerup = new BladesPowerup(id, content, position);
                    break;

                case PowerupType.EightBallShield: //added EightBallShield
                    powerup = new EightBallShieldPowerup(id, content, position);
                    break;

                case PowerupType.TriShield:
                    powerup = new TriShieldPowerup(id, content, position);
                    break;

                case PowerupType.DroneWave:
                    powerup = new DroneWavePowerup(id, content, position);
                    break;

                case PowerupType.Birdcrap:
                    powerup = new BirdcrapPowerup(id, content, position);
                    break;

                case PowerupType.EnergyBlast:
                    powerup = new EnergyBlastPowerup(id, content, position);
                    break;

                case PowerupType.Bomb:
                    powerup = new BombPowerUp(id, content, position);
                    break;

                case PowerupType.Ale:
                    powerup = new AlePowerup(id, content, position);
                    break;

                case PowerupType.ShotgunPowerup:
                    powerup = new ShotgunPowerup(id, content, position);
                    break;

                case PowerupType.MeteorPowerup:
                    powerup = new MeteorPowerup(id, content, position);
                    break;

                case PowerupType.Railgun:
                    powerup = new Railgun(id, content, position);
                    break;

                case PowerupType.HomingMissiles:
                    powerup = new HomingMissilesPowerup(id, content, position);
                    break;

                default:
                    throw new NotImplementedException("The powerup type " + Enum.GetName(typeof(ProjectileType), powerupType) + " is not supported");
            }

            powerup.ObjectType = ObjectType.Powerup;
            QueueGameObjectForCreation(powerup);
            return powerup;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create our viewports
            gameViewport  = GraphicsDevice.Viewport;
            worldViewport = new Viewport(0, 0, 768, 720);   // Twice as wide as 16 tiles
            guiViewport   = new Viewport(768, 0, 512, 720); // Remaining space

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            GameObjectManager = new GameObjectManager(Content);

            // TODO: use this.Content to load your game content here
            Player = GameObjectManager.CreatePlayerShip(PlayerShipType.Shrike, new Vector2(300, 300));
            GameObjectManager.CreatePowerup(PowerupType.Fireball, new Vector2(100, 200));

            LevelManager.LoadContent();
            LevelManager.LoadLevel("LavaLevel2");
            GuiManager.LoadContent();
            GameState = GameState.Initializing;
        }
All Usage Examples Of ScrollingShooter.GameObjectManager::CreatePowerup