ScrollingShooter.GameObjectManager.CreatePlayerShip C# (CSharp) Method

CreatePlayerShip() public method

Factory method to create a Player ship
public CreatePlayerShip ( PlayerShipType PlayerShipType, Vector2 position ) : PlayerShip
PlayerShipType PlayerShipType The type of Player ship to create
position Vector2 The position of the Player ship in the game world
return PlayerShip
        public PlayerShip CreatePlayerShip(PlayerShipType PlayerShipType, Vector2 position)
        {
            PlayerShip PlayerShip;
            uint id = NextID();

            switch (PlayerShipType)
            {
                case PlayerShipType.Shrike:
                    PlayerShip = new ShrikeShip(id, content, position);
                    break;

                default:
                    throw new NotImplementedException("The Player ship type " + Enum.GetName(typeof(PlayerShipType), PlayerShipType) + " is not supported");
            }

            PlayerShip.ObjectType = ObjectType.Player;
            QueueGameObjectForCreation(PlayerShip);
            return PlayerShip;
        }

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::CreatePlayerShip