Exemplo n.º 1
0
        public ScoreCard(Player player, Point displayPosition)
        {
            this.player = player;

            this.displayPosition = displayPosition;

            this.kills = 0;
            this.defeats = 0;
            this.suicides = 0;

            this.font = new Font(Configuration.InfoBar.PlayerStatusDisplayFontFilename, Configuration.InfoBar.PlayerStatusDisplayFontSize);

            Surface scoreCardSurface = new Surface(Configuration.InfoBar.PlayerStatusDisplayImageFilename);

            Point position = new Point(Configuration.InfoBar.XBuffer, Configuration.InfoBar.YBuffer);

            // Show the ship's picture.
            scoreCardSurface.Blit(this.player.Ship.ShipPhotoSurface, position);

            position.X += this.player.Ship.ShipPhotoSurface.Width + Configuration.InfoBar.XBuffer;

            using (Surface text = font.Render(string.Format("Player {0}", player.Number), Configuration.Ships.Shields.InfoDisplayPlayerFontColor))
            {
                text.Transparent = true;
                scoreCardSurface.Blit(text, position);
            }

            int xPosition = position.X + Configuration.InfoBar.FirstColumn_PixelsToIndent;

            this.shieldsText = font.Render("Shields:", Configuration.Ships.Shields.InfoDisplayStrongColor, true);
            this.shieldsText.Transparent = true;
            scoreCardSurface.Blit(shieldsText, new Point(xPosition, position.Y + this.font.LineSize + 1));

            this.bulletsText = font.Render("Bullets:", Configuration.Ships.Cannon.InfoDisplayStrongBulletCountColor, true);
            this.bulletsText.Transparent = true;
            scoreCardSurface.Blit(bulletsText, new Point(xPosition, position.Y + this.font.LineSize * 2 + 1));

            xPosition = position.X + Configuration.InfoBar.SecondColumn_PixelsToIndent;

            this.killsText = font.Render("Kills:", Configuration.InfoBar.CounterTextColor, true);
            this.killsText.Transparent = true;
            scoreCardSurface.Blit(killsText, new Point(xPosition, position.Y));

            this.defeatsText = font.Render("Defeats:", Configuration.InfoBar.CounterTextColor, true);
            this.defeatsText.Transparent = true;
            scoreCardSurface.Blit(defeatsText, new Point(xPosition, position.Y + this.font.LineSize + 1));

            this.suicidesText = font.Render("Suicides:", Configuration.InfoBar.CounterTextColor, true);
            this.suicidesText.Transparent = true;
            scoreCardSurface.Blit(suicidesText, new Point(xPosition, position.Y + this.font.LineSize * 2 + 1));

            this.scoreCard = scoreCardSurface.Convert(Video.Screen, true, false);
        }
Exemplo n.º 2
0
        public OrbitClash()
        {
            Video.WindowIcon();

            Video.SetVideoMode(Configuration.DisplaySize.Width, Configuration.DisplaySize.Height, false);

            Video.WindowCaption = Configuration.Title;

            Mixer.ChannelsAllocated = Configuration.MaxSoundChannels;

            this.theGameHasBegun = false;

            this.particleSystem = new ParticleSystem();

            this.mainTitle = new MainTitle();

            Surface infoBarSurface = new Surface(Configuration.InfoBar.ImageFilename);
            this.infoBar = infoBarSurface.Convert(Video.Screen, true, false);

            // Player 1.
            this.player1 = new Player(1);
            this.player1.LeftKey = Configuration.Controls.Player1.Left;
            this.player1.RightKey = Configuration.Controls.Player1.Right;
            this.player1.UpKey = Configuration.Controls.Player1.Up;
            this.player1.DownKey = Configuration.Controls.Player1.Down;
            this.player1.FireKey = Configuration.Controls.Player1.Fire;

            // Player 2.
            this.player2 = new Player(2);
            this.player2.LeftKey = Configuration.Controls.Player2.Left;
            this.player2.RightKey = Configuration.Controls.Player2.Right;
            this.player2.UpKey = Configuration.Controls.Player2.Up;
            this.player2.DownKey = Configuration.Controls.Player2.Down;
            this.player2.FireKey = Configuration.Controls.Player2.Fire;

            this.bulletShipImpactSound = new Sound(Configuration.Bullets.BulletShipImpactSoundFilename);
            this.bulletShipImpactSound.Volume = Configuration.SoundVolume;

            this.bulletShipImpactBounceSound = new Sound(Configuration.Bullets.BulletShipImpactBounceSoundFilename);
            this.bulletShipImpactBounceSound.Volume = Configuration.SoundVolume;

            this.bulletPlanetImpactSound = new Sound(Configuration.Bullets.BulletPlanetImpactSoundFilename);
            this.bulletPlanetImpactSound.Volume = Configuration.SoundVolume;

            this.shipShipImpactSound = new Sound(Configuration.Ships.ShipShipImpactSoundFilename);
            this.shipShipImpactSound.Volume = Configuration.SoundVolume;

            // Setup screen bounce-boundary manipulator.
            this.boundaryManipulator = new ParticleBoundary(new Rectangle(Configuration.PlayArea.Location, Configuration.PlayArea.Size));
            this.particleSystem.Manipulators.Add(this.boundaryManipulator);

            // Set up star-background.
            Surface backgroundSurface = new Surface(Configuration.PlayAreaBackgroundImageFilename);
            this.background = backgroundSurface.Convert(Video.Screen, true, false);

            // Setup the planet.
            Point planetLocation = new Point(Configuration.PlayArea.Width / 2, Configuration.PlayArea.Height / 2);
            this.planet = new Planet(Configuration.Planet.ImageFilename, Configuration.Planet.ImageTransparentColor, planetLocation, Configuration.Planet.ImageScale);
            this.particleSystem.Add(this.planet);

            // Draw the planetary halo onto the background.
            if (Configuration.Planet.ShowPlanetaryHalo)
            {
                Point haloPosition = new Point(this.planet.Center.X - Configuration.Planet.GravityWellRadius, this.planet.Center.Y - Configuration.Planet.GravityWellRadius);
                this.background.Blit(this.planet.HaloSurface, haloPosition);
            }

            // Setup the gravity manipulator.
            this.gravityManipulator = new GravityWell(this.planet.Center, Configuration.Planet.GravityWellRadius, Configuration.Planet.GravityPower);
            this.particleSystem.Manipulators.Add(this.gravityManipulator);

            // Setup speed limit manipulator.
            this.speedLimitManipulator = new SpeedLimit(Configuration.UniversalSpeedLimit);
            //this.particleSystem.Manipulators.Add(this.speedLimitManipulator);

            Events.KeyboardDown += new EventHandler<KeyboardEventArgs>(this.KeyboardDown);
            Events.KeyboardUp += new EventHandler<KeyboardEventArgs>(this.KeyboardUp);

            Events.Fps = Configuration.Fps;

            Events.Tick += new EventHandler<TickEventArgs>(this.Tick);
            Events.Quit += new EventHandler<QuitEventArgs>(this.Quit);
        }
Exemplo n.º 3
0
 public Bullet(Player owner, Surface bulletSurface, Point bulletPosition, Vector bulletVector, float power, int bulletLife)
     : base(GetBulletSprite(bulletSurface, bulletPosition), bulletPosition.X, bulletPosition.Y, bulletVector, bulletLife)
 {
     this.owner = owner;
     this.power = power;
 }
Exemplo n.º 4
0
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                // We haven't been disposed yet.

                if (disposing)
                {
                    /* The method has been called directly or indirectly by a
                     * user's code.  Dispose of managed resources here.
                     */
                    if (this.mainTitle != null)
                    {
                        this.mainTitle.Dispose();
                        this.mainTitle = null;
                    }

                    if (this.background != null)
                    {
                        this.background.Dispose();
                        this.background = null;
                    }

                    if (this.planet != null)
                    {
                        this.planet.Dispose();
                        this.planet = null;
                    }

                    if (this.player1.Ship != null)
                    {
                        this.player1.Ship.Dispose();
                        this.player1.Ship = null;
                    }

                    if (this.player2.Ship != null)
                    {
                        this.player2.Ship.Dispose();
                        this.player2.Ship = null;
                    }

                    if (this.player1 != null)
                    {
                        this.player1.Dispose();
                        this.player1 = null;
                    }

                    if (this.player2 != null)
                    {
                        this.player2.Dispose();
                        this.player2 = null;
                    }

                    if (this.bulletShipImpactBounceSound != null)
                    {
                        this.bulletShipImpactBounceSound.Dispose();
                        this.bulletShipImpactBounceSound = null;
                    }

                    if (this.bulletPlanetImpactSound != null)
                    {
                        this.bulletPlanetImpactSound.Dispose();
                        this.bulletPlanetImpactSound = null;
                    }

                    if (this.bulletShipImpactSound != null)
                    {
                        this.bulletShipImpactSound.Dispose();
                        this.bulletShipImpactSound = null;
                    }

                    if (this.shipShipImpactSound != null)
                    {
                        this.shipShipImpactSound.Dispose();
                        this.shipShipImpactSound = null;
                    }
                }

                // Dispose of unmanaged resources _only_ out here.

                this.disposed = true;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new Ship instance.
        /// </summary>
        /// <param name="player">
        /// The player who owns the ship.
        /// </param>
        /// <param name="spriteSheet">
        /// The Ship's rotational sprite sheet.
        /// </param>
        /// <param name="startingScreenPosition">
        /// The Ship's starting screen position.
        /// </param>
        /// <param name="bulletSurface">
        /// The surface for bullets fired by this ship.
        /// </param>
        /// <param name="infoBarShipSurface">
        /// The surface that is displayed as the identifying icon in the
        /// InfoBar.
        /// </param>
        public Ship(Player player, SpriteSheet spriteSheet, Point startingScreenPosition, Surface bulletSurface, Surface infoBarShipSurface)
            : base(spriteSheet.AnimatedSprite)
        {
            this.player = player;
            this.spriteSheet = spriteSheet;

            // This is for the ship picture in the InfoBar.
            this.shipPhotoSurface = infoBarShipSurface;

            this.topSpeed = Configuration.Ships.TopSpeed;
            this.shields = Configuration.Ships.Shields.Power;

            this.X = startingScreenPosition.X;
            this.Y = startingScreenPosition.Y;
            this.Velocity = new Vector();
            this.Life = -1; // Infinite life span.

            // Our next scheduled respawn time (i.e. never).
            this.respawnTime = DateTime.MinValue;

            this.speedLimiter = new SpeedLimit(this.topSpeed);

            this.forwardThruster = new Thruster(this, false, Configuration.Ships.Thrusters.Forward.SoundFilename, Configuration.Ships.Thrusters.Forward.Power, spriteSheet.ForwardThrusterEngineLength, Configuration.Ships.Thrusters.Forward.ExhaustConeDeg, Configuration.Ships.Thrusters.Forward.ParticleMinColor, Configuration.Ships.Thrusters.Forward.ParticleMaxColor);

            this.reverseThruster = new Thruster(this, true, Configuration.Ships.Thrusters.Reverse.SoundFilename, Configuration.Ships.Thrusters.Reverse.Power, spriteSheet.ReverseThrusterEngineLength, Configuration.Ships.Thrusters.Reverse.ExhaustConeDeg, Configuration.Ships.Thrusters.Reverse.ParticleMinColor, Configuration.Ships.Thrusters.Reverse.ParticleMaxColor);

            this.cannon = new Cannon(this, spriteSheet.CannonBarrelLength, bulletSurface, Configuration.Ships.Cannon.Power, Configuration.Ships.Cannon.Cooldown, Configuration.Ships.Cannon.MuzzleSpeed, Configuration.Bullets.Life);

            this.spawnTime = DateTime.Now;
        }