Ejemplo n.º 1
0
        protected override void LoadContent()
        {
            // initialize sprite batching and the sprite sheet collection
            spriteBatch  = new SpriteBatch(GraphicsDevice);
            spriteSheets = SpriteSheetCollection.parseFrom(settings.spriteSheetFileName, content);
            if (spriteSheets == null)
            {
                Exit();
            }

            // initialize the game management systems
            projectileSystem = new ProjectileSystem(spriteSheets, settings, content);
            spaceShipSystem  = new SpaceShipSystem(spriteSheets, projectileSystem, settings, content);
            asteroidSystem   = new AsteroidSystem(spriteSheets, spaceShipSystem, settings);
            explosionSystem  = new ExplosionSystem(spriteSheets, content);
            scoreSystem      = new ScoreSystem(spaceShipSystem, content, settings);
            collisionSystem  = new CollisionSystem(projectileSystem, spaceShipSystem, asteroidSystem, explosionSystem, scoreSystem);

            // initialize the menu
            menu = new Menu(this, spaceShipSystem, settings, content);

            // load and start the background music (if appropriate)
            backgroundMusic         = content.Load <Song>("myg0t");
            MediaPlayer.IsRepeating = true;
            if (settings.musicEnabled)
            {
                MediaPlayer.Play(backgroundMusic);
            }
        }
Ejemplo n.º 2
0
        public SpaceShip(PlayerIndex playerNumber, Vector2 position, float rotation, SpriteSheet spriteSheet, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content)
        {
            // instantiate the player's number with a player index
            m_playerNumber = playerNumber;
                 if(m_playerNumber == PlayerIndex.One)   { m_colour = SpaceShipColour.Red; }
            else if(m_playerNumber == PlayerIndex.Two)   { m_colour = SpaceShipColour.Blue; }
            else if(m_playerNumber == PlayerIndex.Three) { m_colour = SpaceShipColour.Green; }
            else if(m_playerNumber == PlayerIndex.Four)  { m_colour = SpaceShipColour.Yellow; }

            // instantiate the player's input device type
            m_inputDevice = settings.getInputDevice(playerNumber);
                 if(m_inputDevice == InputDevice.Controller1) { m_controllerNumber = PlayerIndex.One; }
            else if(m_inputDevice == InputDevice.Controller2) { m_controllerNumber = PlayerIndex.Two; }
            else if(m_inputDevice == InputDevice.Controller3) { m_controllerNumber = PlayerIndex.Three; }
            else if(m_inputDevice == InputDevice.Controller4) { m_controllerNumber = PlayerIndex.Four; }
            else											  { m_controllerNumber = PlayerIndex.One; }

            // instantiate local variables
            this.position = position;
            this.rotation = rotation;
            m_scale = new Vector2(1, 1);

            m_maximumVelocity = 5.8f;
            m_acceleration = 0.048f;
            m_rotationSpeed = 3.1f;

            m_settings = settings;
            m_spriteSheet = spriteSheet;
            m_projectileSystem = projectileSystem;

            if(m_spriteSheet == null) { return; }

            // initialize sprite / sprite animation arrays
            m_idleSprite = new Sprite[3];
            m_movingAnimation = new SpriteAnimation[3];

            // set the space ship sprite sheet offset based on the space ship colour
            int spriteOffset = 0;
                 if(m_colour == SpaceShipColour.Red)    { spriteOffset = 0; }
            else if(m_colour == SpaceShipColour.Blue)   { spriteOffset = 18; }
            else if(m_colour == SpaceShipColour.Green)  { spriteOffset = 3; }
            else if(m_colour == SpaceShipColour.Yellow) { spriteOffset = 21; }

            // load the idle sprites for each colour
            for(int i=0;i<3;i++) {
                m_idleSprite[i] = m_spriteSheet.getSprite(i + spriteOffset);
            }
            // create and store the movement animations for each colour
            for(int i=0;i<3;i++) {
                m_movingAnimation[i] = new SpriteAnimation(0.16f, SpriteAnimationType.Loop);
                m_movingAnimation[i].addSprite(m_spriteSheet.getSprite(i + spriteOffset + 6));
                m_movingAnimation[i].addSprite(m_spriteSheet.getSprite(i + spriteOffset + 12));
            }

            m_offset = new Vector2(m_idleSprite[1].xOffset * 0.9f, m_idleSprite[1].yOffset * 0.9f);
            m_size = new Vector2(m_offset.X * 2.0f, m_offset.Y * 2.0f);

            updateInitialValues();
        }
Ejemplo n.º 3
0
 public CollisionSystem(ProjectileSystem projectileSystem, SpaceShipSystem spaceShipSystem, AsteroidSystem asteroidSystem, ExplosionSystem explosionSystem, ScoreSystem scoreSystem)
 {
     m_projectileSystem = projectileSystem;
     m_spaceShipSystem = spaceShipSystem;
     m_asteroidSystem = asteroidSystem;
     m_explosionSystem = explosionSystem;
     m_scoreSystem = scoreSystem;
 }
Ejemplo n.º 4
0
 public CollisionSystem(ProjectileSystem projectileSystem, SpaceShipSystem spaceShipSystem, AsteroidSystem asteroidSystem, ExplosionSystem explosionSystem, ScoreSystem scoreSystem)
 {
     m_projectileSystem = projectileSystem;
     m_spaceShipSystem  = spaceShipSystem;
     m_asteroidSystem   = asteroidSystem;
     m_explosionSystem  = explosionSystem;
     m_scoreSystem      = scoreSystem;
 }
Ejemplo n.º 5
0
        public SpaceShipSystem(int numberOfSpaceShips, SpriteSheetCollection spriteSheets, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content)
        {
            this.numberOfSpaceShips = numberOfSpaceShips;
            if(spriteSheets != null) {
                m_spaceShipSprites = spriteSheets.getSpriteSheet("SpaceShip");
            }
            m_projectileSystem = projectileSystem;
            m_settings = settings;

            // initialize all space ships
            if(m_settings == null || content == null || m_spaceShipSprites == null) { return; }
            m_spaceShips = new SpaceShip[m_maxSpaceShips];
            m_spaceShips[0] = new SpaceShip(PlayerIndex.One, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.2f), 135, m_spaceShipSprites, projectileSystem, settings, content);
            m_spaceShips[1] = new SpaceShip(PlayerIndex.Two, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.8f), -45, m_spaceShipSprites, projectileSystem, settings, content);
            m_spaceShips[2] = new SpaceShip(PlayerIndex.Three, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.8f), 45, m_spaceShipSprites, projectileSystem, settings, content);
            m_spaceShips[3] = new SpaceShip(PlayerIndex.Four, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.2f), -135, m_spaceShipSprites, projectileSystem, settings, content);
        }
Ejemplo n.º 6
0
        public SpaceShipSystem(int numberOfSpaceShips, SpriteSheetCollection spriteSheets, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content)
        {
            this.numberOfSpaceShips = numberOfSpaceShips;
            if (spriteSheets != null)
            {
                m_spaceShipSprites = spriteSheets.getSpriteSheet("SpaceShip");
            }
            m_projectileSystem = projectileSystem;
            m_settings         = settings;

            // initialize all space ships
            if (m_settings == null || content == null || m_spaceShipSprites == null)
            {
                return;
            }
            m_spaceShips    = new SpaceShip[m_maxSpaceShips];
            m_spaceShips[0] = new SpaceShip(PlayerIndex.One, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.2f), 135, m_spaceShipSprites, projectileSystem, settings, content);
            m_spaceShips[1] = new SpaceShip(PlayerIndex.Two, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.8f), -45, m_spaceShipSprites, projectileSystem, settings, content);
            m_spaceShips[2] = new SpaceShip(PlayerIndex.Three, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.8f), 45, m_spaceShipSprites, projectileSystem, settings, content);
            m_spaceShips[3] = new SpaceShip(PlayerIndex.Four, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.2f), -135, m_spaceShipSprites, projectileSystem, settings, content);
        }
Ejemplo n.º 7
0
        public SpaceShip(PlayerIndex playerNumber, Vector2 position, float rotation, SpriteSheet spriteSheet, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content)
        {
            // instantiate the player's number with a player index
            m_playerNumber = playerNumber;
            if (m_playerNumber == PlayerIndex.One)
            {
                m_colour = SpaceShipColour.Red;
            }
            else if (m_playerNumber == PlayerIndex.Two)
            {
                m_colour = SpaceShipColour.Blue;
            }
            else if (m_playerNumber == PlayerIndex.Three)
            {
                m_colour = SpaceShipColour.Green;
            }
            else if (m_playerNumber == PlayerIndex.Four)
            {
                m_colour = SpaceShipColour.Yellow;
            }

            // instantiate the player's input device type
            m_inputDevice = settings.getInputDevice(playerNumber);
            if (m_inputDevice == InputDevice.Controller1)
            {
                m_controllerNumber = PlayerIndex.One;
            }
            else if (m_inputDevice == InputDevice.Controller2)
            {
                m_controllerNumber = PlayerIndex.Two;
            }
            else if (m_inputDevice == InputDevice.Controller3)
            {
                m_controllerNumber = PlayerIndex.Three;
            }
            else if (m_inputDevice == InputDevice.Controller4)
            {
                m_controllerNumber = PlayerIndex.Four;
            }
            else
            {
                m_controllerNumber = PlayerIndex.One;
            }

            // instantiate local variables
            this.position = position;
            this.rotation = rotation;
            m_scale       = new Vector2(1, 1);

            m_maximumVelocity = 5.8f;
            m_acceleration    = 0.048f;
            m_rotationSpeed   = 3.1f;

            m_settings         = settings;
            m_spriteSheet      = spriteSheet;
            m_projectileSystem = projectileSystem;

            if (m_spriteSheet == null)
            {
                return;
            }

            // initialize sprite / sprite animation arrays
            m_idleSprite      = new Sprite[3];
            m_movingAnimation = new SpriteAnimation[3];

            // set the space ship sprite sheet offset based on the space ship colour
            int spriteOffset = 0;

            if (m_colour == SpaceShipColour.Red)
            {
                spriteOffset = 0;
            }
            else if (m_colour == SpaceShipColour.Blue)
            {
                spriteOffset = 18;
            }
            else if (m_colour == SpaceShipColour.Green)
            {
                spriteOffset = 3;
            }
            else if (m_colour == SpaceShipColour.Yellow)
            {
                spriteOffset = 21;
            }

            // load the idle sprites for each colour
            for (int i = 0; i < 3; i++)
            {
                m_idleSprite[i] = m_spriteSheet.getSprite(i + spriteOffset);
            }
            // create and store the movement animations for each colour
            for (int i = 0; i < 3; i++)
            {
                m_movingAnimation[i] = new SpriteAnimation(0.16f, SpriteAnimationType.Loop);
                m_movingAnimation[i].addSprite(m_spriteSheet.getSprite(i + spriteOffset + 6));
                m_movingAnimation[i].addSprite(m_spriteSheet.getSprite(i + spriteOffset + 12));
            }

            m_offset = new Vector2(m_idleSprite[1].xOffset * 0.9f, m_idleSprite[1].yOffset * 0.9f);
            m_size   = new Vector2(m_offset.X * 2.0f, m_offset.Y * 2.0f);

            updateInitialValues();
        }
Ejemplo n.º 8
0
        protected override void LoadContent()
        {
            // initialize sprite batching and the sprite sheet collection
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteSheets = SpriteSheetCollection.parseFrom(settings.spriteSheetFileName, content);
            if(spriteSheets == null) { Exit(); }

            // initialize the game management systems
            projectileSystem = new ProjectileSystem(spriteSheets, settings, content);
            spaceShipSystem = new SpaceShipSystem(spriteSheets, projectileSystem, settings, content);
            asteroidSystem = new AsteroidSystem(spriteSheets, spaceShipSystem, settings);
            explosionSystem = new ExplosionSystem(spriteSheets, content);
            scoreSystem = new ScoreSystem(spaceShipSystem, content, settings);
            collisionSystem = new CollisionSystem(projectileSystem, spaceShipSystem, asteroidSystem, explosionSystem, scoreSystem);

            // initialize the menu
            menu = new Menu(this, spaceShipSystem, settings, content);

            // load and start the background music (if appropriate)
            backgroundMusic = content.Load<Song>("myg0t");
            MediaPlayer.IsRepeating = true;
            if(settings.musicEnabled) {
                MediaPlayer.Play(backgroundMusic);
            }
        }
Ejemplo n.º 9
0
 public SpaceShipSystem(SpriteSheetCollection spriteSheets, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content)
     : this(0, spriteSheets, projectileSystem, settings, content)
 {
 }
Ejemplo n.º 10
0
 public SpaceShipSystem(SpriteSheetCollection spriteSheets, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content) :
     this(0, spriteSheets, projectileSystem, settings, content)
 {
 }