Beispiel #1
0
 private void ApplySelection(ShipSprite selectedShip)
 {
     Globals.SelectedShip     = LanderFunctions.LoadShipSprites(selectedShip);
     Globals.FormMain.Visible = true;
     this.Visible             = false;
     GameFunctions.RecordFeatures(Enum.RecordType.SelectedShip);
 }
Beispiel #2
0
        /// <summary>
        /// Initializes the game
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            ship = new ShipSprite(this);

            base.Initialize();
        }
 void Awake()
 {
     ss = this;
     control = GetComponent<dfControl>();
     sprite = GetComponent<dfSprite>();
     
 }
 public static void MoveShipSprites(ShipSprite ship)
 {
     Functions.MoveSprite(ship);
     Functions.MoveSprite(ship.DownSprite, (int)ship.X, (int)ship.Y + ship.PictureBoxMain.Size.Height);
     Functions.MoveSprite(ship.RightSprite, (int)ship.X + ship.PictureBoxMain.Size.Width, (int)ship.Y);
     Functions.MoveSprite(ship.LeftSprite, (int)ship.X - ship.PictureBoxMain.Size.Width, (int)ship.Y);
     Functions.MoveSprite(ship.UpSprite, (int)ship.X, (int)ship.Y - ship.PictureBoxMain.Size.Height);
 }
Beispiel #5
0
        /// <summary>
        /// This is a Sprite that can be controlled by a
        /// player using Rotate Left = A, Rotate Right = D,
        /// Forward = Space
        /// </summary>
        private void SetupSpaceShip()
        {
            Texture2D ship = Content.Load <Texture2D>(
                "Actors/GreenShip");

            shipSprite = new ShipSprite(ship, 200, 500)
            {
                Direction        = new Vector2(1, 0),
                Speed            = 200,
                DirectionControl = DirectionControl.Rotational
            };
        }
Beispiel #6
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     S.Draw(target, states);
     ShipSprite.Draw(target, states);
     bullets.Draw(target, states);
     //Lifebar zeichnen
     hud.Draw(target, states);
     if (explosions != null)
     {
         foreach (Explosion exp in explosions)
         {
             exp.Draw(target, states);
         }
     }
 }
        public static int GetShipIndex(ShipSprite sprite)
        {
            int shipIndex = -1;

            if (Globals.SelectedShip.Ship == Enum.Ships.Type01)
            {
                shipIndex = 0;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type02)
            {
                shipIndex = 1;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type03)
            {
                shipIndex = 2;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type04)
            {
                shipIndex = 3;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type05)
            {
                shipIndex = 4;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type06)
            {
                shipIndex = 5;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type07)
            {
                shipIndex = 6;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type08)
            {
                shipIndex = 7;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.Type09)
            {
                shipIndex = 8;
            }
            else if (Globals.SelectedShip.Ship == Enum.Ships.TypeX1)
            {
                shipIndex = 9;
            }

            return(shipIndex);
        }
        public static void DecreaseFuel(ShipSprite sprite, ProgressBar progressBarFuel)
        {
            if (Globals.UpKeyPressed || Globals.DownKeyPressed || Globals.LeftKeyPressed || Globals.RightKeyPressed)
            {
                sprite.Fuel -= sprite.FuelConsumptionRate;
            }

            if (Globals.SpaceKeyPressed && sprite.UseFuelWhenSpecialKeyPressed)
            {
                sprite.Fuel -= sprite.SpecialFuelConsumptionRate;
            }

            if (sprite.Fuel < 0)
            {
                sprite.Fuel = 0;
            }

            if (sprite.Fuel > sprite.MaxFuel)
            {
                sprite.Fuel = sprite.MaxFuel;
            }

            progressBarFuel.Value = (int)sprite.Fuel;

            if (sprite.Fuel < progressBarFuel.Maximum / 5)
            {
                if (progressBarFuel.ForeColor == Color.SpringGreen || progressBarFuel.ForeColor == Color.Purple)
                {
                    progressBarFuel.ForeColor = Color.Red;
                }
                else if (progressBarFuel.ForeColor == Color.Red)
                {
                    progressBarFuel.ForeColor = Color.White;
                }
                else if (progressBarFuel.ForeColor == Color.White)
                {
                    progressBarFuel.ForeColor = Color.Red;
                }
            }
            else if (progressBarFuel.ForeColor != Color.Purple)
            {
                progressBarFuel.ForeColor = Color.SpringGreen;
            }
        }
        /// <summary>
        /// Initializes the game
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            System.Random rand = new System.Random();
            asteroids = new AsteroidSprite[]
            {
                new AsteroidSprite(new Vector2((float)rand.NextDouble() * GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * GraphicsDevice.Viewport.Height)),
                new AsteroidSprite(new Vector2((float)rand.NextDouble() * GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * GraphicsDevice.Viewport.Height)),
                new AsteroidSprite(new Vector2((float)rand.NextDouble() * GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * GraphicsDevice.Viewport.Height)),
                new AsteroidSprite(new Vector2((float)rand.NextDouble() * GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * GraphicsDevice.Viewport.Height)),
                new AsteroidSprite(new Vector2((float)rand.NextDouble() * GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * GraphicsDevice.Viewport.Height)),
                new AsteroidSprite(new Vector2((float)rand.NextDouble() * GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * GraphicsDevice.Viewport.Height)),
                new AsteroidSprite(new Vector2((float)rand.NextDouble() * GraphicsDevice.Viewport.Width, (float)rand.NextDouble() * GraphicsDevice.Viewport.Height))
            };
            livesLeft = 3;
            ship      = new ShipSprite();

            base.Initialize();
        }
        public static void ApplyControls(ShipSprite sprite, Timer timer)
        {
            if (Globals.LeftKeyPressed)
            {
                sprite.HorizontalVelocity -= sprite.Accel;
            }
            else if (Globals.RightKeyPressed)
            {
                sprite.HorizontalVelocity += sprite.Accel;
            }

            if (Globals.UpKeyPressed)
            {
                sprite.VerticalVelocity -= sprite.Accel;
            }
            else if (Globals.DownKeyPressed)
            {
                sprite.VerticalVelocity += sprite.Accel;
            }
        }
        public static bool VerifyCollision(ShipSprite sprite, Sprite lz, ref bool landed)
        {
            Globals.CollidedUp    = false;
            Globals.CollidedDown  = false;
            Globals.CollidedLeft  = false;
            Globals.CollidedRight = false;

            if (Globals.CurrentStage != 0)
            {
                Globals.CollidedGround = GameFunctions.CollidedGround();
            }

            if (Globals.CurrentStage != 0)
            {
                Globals.CollidedLZ = GameFunctions.CollidedLZ(ref landed);
            }
            else if (Globals.StageFreeCollision)
            {
                Globals.CollidedLZ = GameFunctions.CollidedLZ(ref landed);
            }


            if (Globals.CollidedGround || Globals.CollidedLZ)
            {
                Globals.Collided = true;

                Globals.SelectedShip.VerticalVelocity   = 0;
                Globals.SelectedShip.HorizontalVelocity = 0;

                Globals.Stage.pictureBox2.Visible = false;
                Globals.Stage.pictureBox3.Visible = false;
                Globals.Stage.pictureBox4.Visible = false;
                Globals.Stage.pictureBox5.Visible = false;
            }
            else
            {
                Globals.Collided = false;
            }

            return(Globals.Collided);
        }
        public void HasCollided(ShipSprite player)
        {
            foreach (Sprite asteroid in asteroids)
            {
                if (asteroid.HasCollided(player) && asteroid.IsAlive)
                {
                    asteroidEffect.Play();

                    asteroid.IsActive  = false;
                    asteroid.IsAlive   = false;
                    asteroid.IsVisible = false;

                    player.Health -= 10;
                }

                if (asteroid.Position.X < 0)
                {
                    player.Score += 10;
                }
            }
            asteroids.RemoveAll(i => i.Position.X < 0);
        }
Beispiel #13
0
        public static ShipSprite LoadShipSprites(ShipSprite sprite)
        {
            sprite.Accel = Functions.ConvertMpSToForce(sprite.AccelMpS, Globals.TimerInterval);

            PictureBox left = new PictureBox();

            left.Size = new Size(32, 32);
            PictureBox right = new PictureBox();

            right.Size = new Size(32, 32);
            PictureBox up = new PictureBox();

            up.Size = new Size(32, 32);
            PictureBox down = new PictureBox();

            down.Size = new Size(32, 32);

            sprite.LeftSprite  = new Sprite(left);
            sprite.RightSprite = new Sprite(right);
            sprite.UpSprite    = new Sprite(up);
            sprite.DownSprite  = new Sprite(down);

            sprite.LeftSprite.ImageDefault  = WinFormsLander.Properties.Resources.LeftBoost;
            sprite.RightSprite.ImageDefault = WinFormsLander.Properties.Resources.RightBoost;
            sprite.UpSprite.ImageDefault    = WinFormsLander.Properties.Resources.UpBoost;
            sprite.DownSprite.ImageDefault  = WinFormsLander.Properties.Resources.RocketBoost;

            left.BackgroundImage  = sprite.LeftSprite.ImageDefault;
            right.BackgroundImage = sprite.RightSprite.ImageDefault;
            up.BackgroundImage    = sprite.UpSprite.ImageDefault;
            down.BackgroundImage  = sprite.DownSprite.ImageDefault;

            left.BackColor  = Color.Transparent;
            right.BackColor = Color.Transparent;
            up.BackColor    = Color.Transparent;
            down.BackColor  = Color.Transparent;

            sprite.PictureBoxMain.BackgroundImage = sprite.ImageDefault;

            if (sprite.Ship == Enum.Ships.Type01)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander01);
            }
            else if (sprite.Ship == Enum.Ships.Type02)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander02);
            }
            else if (sprite.Ship == Enum.Ships.Type03)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander03);
            }
            else if (sprite.Ship == Enum.Ships.Type04)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander04);
            }
            else if (sprite.Ship == Enum.Ships.Type05)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander05);
            }
            else if (sprite.Ship == Enum.Ships.Type06)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander06);
            }
            else if (sprite.Ship == Enum.Ships.Type07)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander07);
            }
            else if (sprite.Ship == Enum.Ships.Type08)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander08);
            }
            else if (sprite.Ship == Enum.Ships.Type09)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLander09);
            }
            else if (sprite.Ship == Enum.Ships.TypeX1)
            {
                Globals.UpdateLander = new WinFormsLander.Forms.FormBase.UpdateForLander(LanderFunctions.UpdateForLanderX1);
            }

            return(sprite);
        }
Beispiel #14
0
        private void FormShips_Load(object sender, EventArgs e)
        {
            this.landerSprite01 = new ShipSprite(Enum.Ships.Type01, this.pictureBox01);
            this.landerSprite02 = new ShipSprite(Enum.Ships.Type02, this.pictureBox02);
            this.landerSprite03 = new ShipSprite(Enum.Ships.Type03, this.pictureBox03);
            this.landerSprite04 = new ShipSprite(Enum.Ships.Type04, this.pictureBox04);
            this.landerSprite05 = new ShipSprite(Enum.Ships.Type05, this.pictureBox05);
            this.landerSprite06 = new ShipSprite(Enum.Ships.Type06, this.pictureBox06);
            this.landerSprite07 = new ShipSprite(Enum.Ships.Type07, this.pictureBox07);
            this.landerSprite08 = new ShipSprite(Enum.Ships.Type08, this.pictureBox08);
            this.landerSprite09 = new ShipSprite(Enum.Ships.Type09, this.pictureBox09);
            this.landerSpriteX1 = new ShipSprite(Enum.Ships.TypeX1, this.pictureBoxX1);

            this.labelID01.Text         = this.landerSprite01.ID;
            this.labelName01.Text       = string.Format(this.labelName01.Text, this.landerSprite01.Name);
            this.labelAccel01.Text      = string.Format(this.labelAccel01.Text, this.landerSprite01.AccelMpS);
            this.labelFuel01.Text       = string.Format(this.labelFuel01.Text, this.landerSprite01.MaxFuel * fuelMultiplier);
            this.labelResistance01.Text = string.Format(this.labelResistance01.Text, Convert.ToDouble(this.landerSprite01.Resistance).ToString("0.00"));
            this.labelSpecial01.Text    = string.Format(this.labelSpecial01.Text, this.landerSprite01.Special);

            this.labelID02.Text         = this.landerSprite02.ID;
            this.labelName02.Text       = string.Format(this.labelName02.Text, this.landerSprite02.Name);
            this.labelAccel02.Text      = string.Format(this.labelAccel02.Text, this.landerSprite02.AccelMpS, 2);
            this.labelFuel02.Text       = string.Format(this.labelFuel02.Text, this.landerSprite02.MaxFuel * fuelMultiplier);
            this.labelResistance02.Text = string.Format(this.labelResistance02.Text, Convert.ToDouble(this.landerSprite02.Resistance).ToString("0.00"));
            this.labelSpecial02.Text    = string.Format(this.labelSpecial02.Text, this.landerSprite02.Special);

            this.labelID03.Text         = this.landerSprite03.ID;
            this.labelName03.Text       = string.Format(this.labelName03.Text, this.landerSprite03.Name);
            this.labelAccel03.Text      = string.Format(this.labelAccel03.Text, this.landerSprite03.AccelMpS, 2);
            this.labelFuel03.Text       = string.Format(this.labelFuel03.Text, this.landerSprite03.MaxFuel * fuelMultiplier);
            this.labelResistance03.Text = string.Format(this.labelResistance03.Text, Convert.ToDouble(this.landerSprite03.Resistance).ToString("0.00"));
            this.labelSpecial03.Text    = string.Format(this.labelSpecial03.Text, this.landerSprite03.Special);

            this.labelID04.Text         = this.landerSprite04.ID;
            this.labelName04.Text       = string.Format(this.labelName04.Text, this.landerSprite04.Name);
            this.labelAccel04.Text      = string.Format(this.labelAccel04.Text, this.landerSprite04.AccelMpS, 2);
            this.labelFuel04.Text       = string.Format(this.labelFuel04.Text, this.landerSprite04.MaxFuel * fuelMultiplier);
            this.labelResistance04.Text = string.Format(this.labelResistance04.Text, Convert.ToDouble(this.landerSprite04.Resistance).ToString("0.00"));
            this.labelSpecial04.Text    = string.Format(this.labelSpecial04.Text, this.landerSprite04.Special);

            this.labelID05.Text         = this.landerSprite05.ID;
            this.labelName05.Text       = string.Format(this.labelName05.Text, this.landerSprite05.Name);
            this.labelAccel05.Text      = string.Format(this.labelAccel05.Text, this.landerSprite05.AccelMpS, 2);
            this.labelFuel05.Text       = string.Format(this.labelFuel05.Text, this.landerSprite05.MaxFuel * fuelMultiplier);
            this.labelResistance05.Text = string.Format(this.labelResistance05.Text, Convert.ToDouble(this.landerSprite05.Resistance).ToString("0.00"));
            this.labelSpecial05.Text    = string.Format(this.labelSpecial05.Text, this.landerSprite05.Special);

            this.labelID06.Text         = this.landerSprite06.ID;
            this.labelName06.Text       = string.Format(this.labelName06.Text, this.landerSprite06.Name);
            this.labelAccel06.Text      = string.Format(this.labelAccel06.Text, this.landerSprite06.AccelMpS, 2);
            this.labelFuel06.Text       = string.Format(this.labelFuel06.Text, this.landerSprite06.MaxFuel * fuelMultiplier);
            this.labelResistance06.Text = string.Format(this.labelResistance06.Text, Convert.ToDouble(this.landerSprite06.Resistance).ToString("0.00"));
            this.labelSpecial06.Text    = string.Format(this.labelSpecial06.Text, this.landerSprite06.Special);

            this.labelID07.Text         = this.landerSprite07.ID;
            this.labelName07.Text       = string.Format(this.labelName07.Text, this.landerSprite07.Name);
            this.labelAccel07.Text      = string.Format(this.labelAccel07.Text, this.landerSprite07.AccelMpS, 2);
            this.labelFuel07.Text       = string.Format(this.labelFuel07.Text, this.landerSprite07.MaxFuel * fuelMultiplier);
            this.labelResistance07.Text = string.Format(this.labelResistance07.Text, Convert.ToDouble(this.landerSprite07.Resistance).ToString("0.00"));
            this.labelSpecial07.Text    = string.Format(this.labelSpecial07.Text, this.landerSprite07.Special);

            this.labelID08.Text         = this.landerSprite08.ID;
            this.labelName08.Text       = string.Format(this.labelName08.Text, this.landerSprite08.Name);
            this.labelAccel08.Text      = string.Format(this.labelAccel08.Text, this.landerSprite08.AccelMpS, 2);
            this.labelFuel08.Text       = string.Format(this.labelFuel08.Text, this.landerSprite08.MaxFuel * fuelMultiplier);
            this.labelResistance08.Text = string.Format(this.labelResistance08.Text, Convert.ToDouble(this.landerSprite08.Resistance).ToString("0.00"));
            this.labelSpecial08.Text    = string.Format(this.labelSpecial08.Text, this.landerSprite08.Special);

            this.labelID09.Text         = this.landerSprite09.ID;
            this.labelName09.Text       = string.Format(this.labelName09.Text, this.landerSprite09.Name);
            this.labelAccel09.Text      = string.Format(this.labelAccel09.Text, this.landerSprite09.AccelMpS, 2);
            this.labelFuel09.Text       = string.Format(this.labelFuel09.Text, this.landerSprite09.MaxFuel * fuelMultiplier);
            this.labelResistance09.Text = string.Format(this.labelResistance09.Text, Convert.ToDouble(this.landerSprite09.Resistance).ToString("0.00"));
            this.labelSpecial09.Text    = string.Format(this.labelSpecial09.Text, this.landerSprite09.Special);

            this.labelIDX1.Text         = this.landerSpriteX1.ID;
            this.labelNameX1.Text       = string.Format(this.labelNameX1.Text, this.landerSpriteX1.Name);
            this.labelAccelX1.Text      = string.Format(this.labelAccelX1.Text, this.landerSpriteX1.AccelMpS, 2);
            this.labelFuelX1.Text       = string.Format(this.labelFuelX1.Text, this.landerSpriteX1.MaxFuel * fuelMultiplier);
            this.labelResistanceX1.Text = string.Format(this.labelResistanceX1.Text, Convert.ToDouble(this.landerSpriteX1.Resistance).ToString("0.00"));
            this.labelSpecialX1.Text    = string.Format(this.labelSpecialX1.Text, this.landerSpriteX1.Special);
        }
Beispiel #15
0
 public abstract void Apply(ShipgenState state, ShipSprite sprite);