예제 #1
0
        /// <summary>
        /// Creates a new SpacewarScreen
        /// </summary>
        public EvolvedScreen(Game game)
            : base(game)
        {
            backdrop = new SceneItem(game, new EvolvedBackdrop(game));
            const float factor = 46;

            backdrop.Center   = new Vector3(.5f, .5f, 0);
            backdrop.Scale    = new Vector3(16f * factor, 9f * factor, 1f);
            backdrop.Position = new Vector3(-.5f, -.5f, 0);
            scene.Add(backdrop);

            bullets   = new Projectiles(game);
            particles = new Particles(game);

            ship1        = new Ship(game, PlayerIndex.One, SpacewarGame.Players[0].ShipClass, SpacewarGame.Players[0].Skin, new Vector3(SpacewarGame.Settings.Ships[0].StartPosition, 0.0f), bullets, particles);
            ship1.Paused = true;
            ship1.Radius = 15f;
            if (SpacewarGame.Players[0].ShipClass == ShipClass.Pencil)
            {
                ship1.ExtendedExtent[0] = new Vector3(0.0f, 25.0f, 0.0f);
                ship1.ExtendedExtent[1] = new Vector3(0.0f, -25.0f, 0.0f);
            }

            ship2        = new Ship(game, PlayerIndex.Two, SpacewarGame.Players[1].ShipClass, SpacewarGame.Players[1].Skin, new Vector3(SpacewarGame.Settings.Ships[1].StartPosition, 0.0f), bullets, particles);
            ship2.Paused = true;
            ship2.Radius = 15f;
            if (SpacewarGame.Players[1].ShipClass == ShipClass.Pencil)
            {
                ship2.ExtendedExtent[0] = new Vector3(0.0f, 25f, 0.0f);
                ship2.ExtendedExtent[1] = new Vector3(0.0f, -25f, 0.0f);
            }

            scene.Add(bullets);

            asteroids = new Asteroid[SpacewarGame.GameLevel + 2];

            for (int i = 0; i < SpacewarGame.GameLevel + 2; i++)
            {
                asteroids[i]          = new Asteroid(game, random.NextDouble() > .5 ? AsteroidType.Large : AsteroidType.Small, asteroidStarts[i]);
                asteroids[i].Scale    = new Vector3(SpacewarGame.Settings.AsteroidScale, SpacewarGame.Settings.AsteroidScale, SpacewarGame.Settings.AsteroidScale);
                asteroids[i].Paused   = true;
                asteroids[i].Velocity = (float)random.Next(100) * Vector3.Normalize(new Vector3((float)(random.NextDouble() - .5), (float)(random.NextDouble() - .5), 0));

                scene.Add(asteroids[i]);
            }

            scene.Add(ship1);
            scene.Add(ship2);
            //Added after other objects so they draw over the top
            scene.Add(particles);


            //Sun last so its on top
            sun = new Sun(game, new EvolvedSun(game), new Vector3(-.5f, -.5f, 0));
            scene.Add(sun);

            //Reset health meters.
            SpacewarGame.Players[0].Health = 5;
            SpacewarGame.Players[1].Health = 5;
        }
예제 #2
0
        /// <summary>
        /// Checks if there is a collision between the this and the passed in item
        /// </summary>
        /// <param name="item">A scene item to check</param>
        /// <returns>True if there is a collision</returns>
        public override bool Collide(SceneItem item)
        {
            // Until we get collision meshes sorted just do a simple sphere (well circle!) check
            float currentDistance = (Position - item.Position).Length();
            bool  colliding       = base.Collide(item);

            // For projectiles, do not allow them to destroy the ship that just fired them!
            Ship shipItem = item as Ship;

            if ((shipItem != null) && (shipItem.Player == player))
            {
                if (colliding && !projectileArmed)
                {
                    colliding = false;
                }
                else if (!colliding && !projectileArmed)
                {
                    // Once projectile is at least 2 ship radii away, it can arm!
                    // This is becuase the bolt launches with your velocity at the time
                    // and the ship can "catch up" to the bolt pretty easily if you are
                    // thrusting in the direction you are firing.
                    if (currentDistance > item.Radius * 2.0f)
                    {
                        projectileArmed = true;
                    }
                }
            }

            return(colliding);
        }
예제 #3
0
        public Screen(Game game)
        {
            this.game  = game;
            this.scene = new SceneItem(game);

            if (game != null)
            {
                IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)game.Services.GetService(typeof(IGraphicsDeviceService));
                batch = new SpriteBatch(graphicsService.GraphicsDevice);
            }
        }
예제 #4
0
        /// <summary>
        /// Creates the ShipUpgradeScreen
        /// </summary>
        public ShipUpgradeScreen(Game game)
            : base(game)
        {
            //Play the menu music
            menuMusic        = Sound.Play(Sounds.MenuMusic);
            weapons[0]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Weapon, PlayerIndex.One, (int)ProjectileType.Peashooter, LightingType.Menu), new Vector3(-170, -30, 0));
            weapons[0].Scale = new Vector3(.06f, .06f, .06f);
            scene.Add(weapons[0]);

            weapons[1]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Weapon, PlayerIndex.Two, (int)ProjectileType.Peashooter, LightingType.Menu), new Vector3(170, -30, 0));
            weapons[1].Scale = new Vector3(.06f, .06f, .06f);
            scene.Add(weapons[1]);
        }
예제 #5
0
        /// <summary>
        /// Creates a new selection screen. Plays the music and initializes the models
        /// </summary>
        public SelectionScreen(Game game)
            : base(game)
        {
            //Start menu music
            menuMusic = Sound.Play(Sounds.MenuMusic);

            ships[0]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, PlayerIndex.One, selectedShip[0], selectedSkin[0], LightingType.Menu), new Vector3(-120, 0, 0));
            ships[0].Scale = new Vector3(.05f, .05f, .05f);
            scene.Add(ships[0]);

            ships[1]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, PlayerIndex.Two, selectedShip[1], selectedSkin[1], LightingType.Menu), new Vector3(120, 0, 0));
            ships[1].Scale = new Vector3(.05f, .05f, .05f);
            scene.Add(ships[1]);
        }
예제 #6
0
        /// <summary>
        /// Makes a new splash screen with the right texture, no timeout and will move to the logo screen
        /// </summary>
        public VictoryScreen(Game game)
            : base(game, victoryScreen, TimeSpan.Zero, GameState.LogoSplash)
        {
            Sound.PlayCue(Sounds.TitleMusic);

            //Whoever won we need to render their ship.
            winningPlayerNumber = (SpacewarGame.Players[0].Score > SpacewarGame.Players[1].Score) ? 0 : 1;

            Player winningPlayer = SpacewarGame.Players[winningPlayerNumber];

            ship       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, (winningPlayerNumber == 0) ? PlayerIndex.One : PlayerIndex.Two, (int)winningPlayer.ShipClass, winningPlayer.Skin, LightingType.Menu), new Vector3(-90, -30, 0));
            ship.Scale = new Vector3(.07f, .07f, .07f);
            scene.Add(ship);
        }
예제 #7
0
        /// <summary>
        /// Creates the ShipUpgradeScreen
        /// </summary>
        public ShipUpgradeScreen(Game game)
            : base(game)
        {
            mainTexture = SpacewarGame.ContentManager.Load <Texture2D>(SpacewarGame.Settings.MediaPath + upgradeTexture);

            //Play the menu music
            menuMusic        = Sound.Play(Sounds.MenuMusic);
            weapons[0]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Weapon, PlayerIndex.One, (int)ProjectileType.Peashooter, LightingType.Menu), new Vector3(-170, -30, 0));
            weapons[0].Scale = new Vector3(.06f, .06f, .06f);
            scene.Add(weapons[0]);

            weapons[1]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Weapon, PlayerIndex.Two, (int)ProjectileType.Peashooter, LightingType.Menu), new Vector3(170, -30, 0));
            weapons[1].Scale = new Vector3(.06f, .06f, .06f);
            scene.Add(weapons[1]);
        }
        /// <summary>
        /// Creates a new selection screen. Plays the music and initializes the models
        /// </summary>
        public SelectionScreen(Game game)
            : base(game)
        {
            mainTexture = SpacewarGame.ContentManager.Load <Texture2D>(SpacewarGame.Settings.MediaPath + selectionTexture);

            //Start menu music
            menuMusic = Sound.Play(Sounds.MenuMusic);

            ships[0]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, PlayerIndex.One, selectedShip[0], selectedSkin[0], LightingType.Menu), new Vector3(-120, 0, 0));
            ships[0].Scale = new Vector3(.05f, .05f, .05f);
            scene.Add(ships[0]);

            ships[1]       = new SceneItem(game, new EvolvedShape(game, EvolvedShapes.Ship, PlayerIndex.Two, selectedShip[1], selectedSkin[1], LightingType.Menu), new Vector3(120, 0, 0));
            ships[1].Scale = new Vector3(.05f, .05f, .05f);
            scene.Add(ships[1]);
        }
예제 #9
0
        /// <summary>
        /// Creates a new SpacewarScreen
        /// </summary>
        public RetroScreen(Game game)
            : base(game)
        {
            //Retro
            backdrop = new SceneItem(game, new RetroStarfield(game));
            scene.Add(backdrop);

            bullets      = new RetroProjectiles(game);
            ship1        = new Ship(game, PlayerIndex.One, new Vector3(-250, 0, 0), bullets);
            ship1.Radius = 10f;
            scene.Add(ship1);

            ship2        = new Ship(game, PlayerIndex.Two, new Vector3(250, 0, 0), bullets);
            ship2.Radius = 10f;
            scene.Add(ship2);

            sun = new Sun(game, new RetroSun(game), new Vector3(SpacewarGame.Settings.SunPosition, 0.0f));
            scene.Add(sun);

            scene.Add(bullets);

            paused = false;
        }