Example #1
0
 public CobraMeter(PlayerAirplane player)
 {
     _player = player;
     Position = new Vector2(10, 300);
     _outlineRect = new Rectangle(9999, 9999, _width + _outline * 2, _height + _outline * 2);
     _meterRect = new Rectangle(9999, 9999, _width, _height);
 }
Example #2
0
 public void AdjustXMovespeed(PlayerAirplane p1)
 {
     if (_velocity.X > p1.Velocity.X) {
         _velocity.X -= 0.01f;
     }
     else if (_velocity.X < p1.Velocity.X) { _velocity.X += 0.01f; }
     _velocity.X = Math.Min(_velocity.X, _maxVelocity.X);
 }
Example #3
0
 public Instrument(string texName, Vector2 position, 
     float minVal, float maxVal, float scaleVal, 
     string sourceName, string titleString, PlayerAirplane player)
 {
     _titleString = titleString;
     _texName = texName;
     minValue = minVal;
     maxValue = maxVal;
     _player = player;
     pos = position;
     _sourceName = sourceName;
     scale = scaleVal;
     needleTexture = new Texture2D(EngineManager.Device, 1, 1, false, SurfaceFormat.Color);
     needleTexture.SetData(new[] { Color.White });
 }
Example #4
0
        public override void LoadContent()
        {
            base.LoadContent();

            LoadTextures();

            // Sounds
            SoundFxLibrary.AddToLibrary("SoundFX/bomb1", "bomb1");
            SoundFxLibrary.AddToLibrary("SoundFX/bomb2", "bomb2");
            SoundFxLibrary.AddToLibrary("SoundFX/bomb3", "bomb3");
            SoundFxLibrary.AddToLibrary("SoundFX/bomb4", "bomb4");
            SoundFxLibrary.AddToLibrary("SoundFX/huge_explosion", "huge_explosion");
            SoundFxLibrary.AddToLibrary("SoundFX/bombdrop", "bombdrop");
            SoundFxLibrary.AddToLibrary("SoundFX/bombwhistle", "bombwhistle");
            SoundFxLibrary.AddToLibrary("SoundFX/hitplane1", "hitplane1");
            SoundFxLibrary.AddToLibrary("SoundFX/hitplane2", "hitplane2");
            SoundFxLibrary.AddToLibrary("SoundFX/refill", "refill");

            player1 = new PlayerAirplane();
            // Add instruments
            throttleMeter = new Instrument("instrument", new Vector2(150, ScreenHeight), 0f, 7.5f, 0.6f, "throttle", "Throttle", player1);
            _instruments.Add("throttleMeter", throttleMeter);

            airspeedMeter = new Instrument("instrument", new Vector2(270, ScreenHeight), 0f, 13f, 0.6f, "linearvelocity", "Airspeed", player1);
            _instruments.Add("airspeedMeter", airspeedMeter);

            foreach (Instrument inst in _instruments.Values)
            {
                inst.LoadContent();
            }
            // !Add instruments

            SkyGradient skyGradient = new SkyGradient("skygradient");
            SceneGraphManager.AddObject(skyGradient);

            SceneGraphManager.AddObject(player1);
            _ammoDisplay = new AmmoDisplay((ProjectileWeapon)player1.ProjectileWeapon, (BombWeapon)player1.BombWeapon);
            _ammoDisplay.LoadContent();
            _cobraMeter = new CobraMeter(player1);

            SceneGraphManager.LoadContent();
            ParticleManager.LoadContent();
        }
Example #5
0
 public void MoveDown(PlayerAirplane p1)
 {
     if (p1.Velocity.Y > _velocity.Y)
     {
         _velocity.Y += 0.7f;
         _velocity.Y = Math.Min(_velocity.Y, p1.Velocity.Y);
     }
 }
Example #6
0
 public void AdjustYMovespeed(PlayerAirplane p1)
 {
     if (_velocity.Y > p1.Velocity.Y) { _velocity.Y -= 0.03f; }
     else if (_velocity.Y < p1.Velocity.Y) { _velocity.Y += 0.08f; }
     _velocity.Y = Math.Min(_velocity.Y, _maxVelocity.Y);
 }
Example #7
0
        public void UpdateY(PlayerAirplane player1)
        {
            int borderSize = (int)(0.25 * GameHelper.ScreenHeight);

            // if player is on top of the screen and not facing upwards

            if (player1.Position.Y <= Pos.Y + borderSize)
            {
                MoveUp(player1);
            }
            else if (player1.Position.Y > Pos.Y + (borderSize))
            {
                MoveDown(player1);
            }
            else
            {
                _velocity.Y = 0.0f;
                Pos = new Vector2(Pos.X, 0.0f);
            }

            return;
        }
Example #8
0
 public void Update(PlayerAirplane player1)
 {
     //if (!player1.ReadyToRender) return;
     if (!_stopped)
     {
         UpdateX(player1);
         UpdateY(player1);
     }
     else if (!_isCruising)
     {
         AdjustToTarget();
     }
     else
     {
         SlowDownY();
         if (_velocity.X < 2.0f)
         {
             _velocity.X += 0.2f;
         } else {
             SlowDownX();
         }
     }
     changePos(_velocity);
     if (Pos.Y > 0)
         Pos = new Vector2(Pos.X, 0);
 }
Example #9
0
        public void UpdateX(PlayerAirplane player1)
        {
            int borderSize = (int)(0.156 * GameHelper.ScreenWidth);

            // Guinness World Record If-statement
            if (player1.Position.X < (Pos.X + borderSize) && !player1.HeadingRight)
            {
                MoveLeft(player1);
            }

            else if (player1.Position.X < (Pos.X + borderSize) && player1.HeadingRight)
            {
                SlowDownX(player1);
            }

            else if (player1.Position.X > Pos.X + (GameHelper.ScreenWidth - borderSize * 0.25f) && player1.HeadingRight)
            {
                MoveRightMegaMax(player1);
            }

            else if (player1.Position.X > Pos.X + (GameHelper.ScreenWidth - borderSize * 2f) && player1.HeadingRight)
            {
                MoveRightMax(player1);
            }

            else if (player1.Position.X > Pos.X + (GameHelper.ScreenWidth - borderSize * 5f) && player1.HeadingRight)
            {
                MoveRight(player1);
            }

            else
            {
                AdjustXMovespeed(player1);
            }
        }
Example #10
0
 public void SlowDownX(PlayerAirplane p1)
 {
     if (_velocity.X > 0) {
         _velocity.X -= Math.Max(0.03f, Math.Abs(SpeedDifference(p1).X * 0.05f));
     }
     else if (_velocity.X < 0) {
         _velocity.X += Math.Max(0.03f, Math.Abs(SpeedDifference(p1).X * 0.05f));
     }
 }
Example #11
0
 public Vector2 SpeedDifference(PlayerAirplane p1)
 {
     return p1.Velocity - Velocity;
 }
Example #12
0
 public void MoveUp(PlayerAirplane p1)
 {
     if (p1.Velocity.Y < _velocity.Y)
     {
         _velocity.Y -= 0.7f;
         _velocity.Y = Math.Max(_velocity.Y, p1.Velocity.Y);
     }
 }
Example #13
0
 public void MoveRightMegaMax(PlayerAirplane p1)
 {
     if (p1.Velocity.X > _velocity.X)
     {
         _velocity.X = Math.Max(_velocity.X, p1.Velocity.X);
     }
 }
Example #14
0
 public void MoveRightMax(PlayerAirplane p1)
 {
     if (p1.Velocity.X > _velocity.X)
     {
         _velocity.X += 0.01f;
         _velocity.X = Math.Min(_velocity.X, p1.Velocity.X);
     }
 }
Example #15
0
 public void MoveRight(PlayerAirplane p1)
 {
     if (p1.Velocity.X > _velocity.X)
     {
         _velocity.X += 0.07f;
         _velocity.X = Math.Min(_velocity.X, p1.Velocity.X);
     }
     _velocity.X = Math.Min(_velocity.X, _maxVelocity.X);
 }
Example #16
0
 public void MoveLeft(PlayerAirplane p1)
 {
     _velocity.X -= Math.Max(0.5f, Math.Abs(SpeedDifference(p1).X * 0.13f));
     _velocity.X = Math.Max(_velocity.X, p1.Velocity.X);
 }