Esempio n. 1
0
        public void Hit(Player p)
        {
            //Settings.SoundPowerUp.Play();

            switch (type) {
                case Type.REGULAR:
                    break;
                case Type.GRENADE:
                    p.BulletType = Projectile.Type.GRENADE;
                    break;
                case Type.DAMAGE:
                    //p.Size *= 1.3f;
                    break;
                case Type.SPEED:
                    p.Speed *= 1.3f;
                    break;
                case Type.FIRERATE:
                    p.ReloadTime =  (int)(p.ReloadTime *.7f);
                    break;
                case Type.HEALTH:
                    p.SetHealth(p.CurrentHealth + 50);
                    break;
                default:
                    break;
            }
        }
 public void LoadContent()
 {
     player1 = new Player(new Vector2(0, 0), 5f);
 }
Esempio n. 3
0
        private void TileCollision(Player p)
        {
            p.Position.X += p.Velocity.X;

            foreach (Wall t in wallList) {
                if (t.Intersects(p))
                    if (p.Velocity.X > 0) {
                        p.Position.X = t.Position.X - p.Size.X;
                        Vector2 temp = new Vector2(p.Direction.X, p.Direction.Y * 1.05f);
                        p.TurretTurn(Calc.AngleBetween(p.Direction, temp));
                        p.TurretDirection.Normalize();
                        p.Direction = temp;
                        p.Direction.Normalize();
                    }

                    else {
                        p.Position.X = t.Position.X + t.Size.X;
                        Vector2 temp = new Vector2(p.Direction.X, p.Direction.Y * 1.05f);
                        p.TurretTurn(Calc.AngleBetween(p.Direction, temp));
                        p.TurretDirection.Normalize();
                        p.Direction = temp;
                        p.Direction.Normalize();
                    }
            }

            p.Position.Y += p.Velocity.Y;

            foreach (Wall t in wallList) {
                if (t.Intersects(p))
                    if (p.Velocity.Y > 0) {
                        p.Position.Y = t.Position.Y - p.Size.Y;
                        Vector2 temp = new Vector2(p.Direction.X * 1.05f, p.Direction.Y);
                        p.TurretTurn(Calc.AngleBetween(p.Direction, temp));
                        p.TurretDirection.Normalize();
                        p.Direction = temp;
                        p.Direction.Normalize();
                    }
                    else {
                        p.Position.Y = t.Position.Y + t.Size.Y;
                        Vector2 temp = new Vector2(p.Direction.X * 1.05f, p.Direction.Y);
                        p.TurretTurn(Calc.AngleBetween(p.Direction, temp));
                        p.TurretDirection.Normalize();
                        p.Direction = temp;
                        p.Direction.Normalize();
                    }
            }
        }
Esempio n. 4
0
 private void ScreenBorderCollision(Player p)
 {
     if (p.Position.X + p.Size.X * Settings.Scale > Settings.ScreenWidth)
         p.Position.X = Settings.ScreenWidth - p.Size.X * Settings.Scale;
     if (p.Position.X < 0)
         p.Position.X = 0;
     if (p.Position.Y + p.Size.Y * Settings.Scale > Settings.ScreenHeight)
         p.Position.Y = Settings.ScreenHeight - p.Size.Y * Settings.Scale;
     if (p.Position.Y < 0)
         p.Position.Y = 0;
 }
Esempio n. 5
0
        private void PowerUpCollision(Player p)
        {
            foreach (PowerUp pu in powerUpList) {

                if (p.Intersects(pu)) {
                    pu.Hit(p);

                    powerUpList.Remove(pu);
                    break;
                }

            }
        }
Esempio n. 6
0
        private void LoadContent()
        {
            if (GamePad.GetState(PlayerIndex.One).IsConnected) {
                player1 = new Player(new Vector2(0, 0), Player.Controller.XBOX_ANALOG);
                player2 = new Player(new Vector2(Settings.ScreenWidth - Settings.TankSize.X, Settings.ScreenHeight - Settings.TankSize.Y), Player.Controller.PC_Full);
            }
            else {
                player1 = new Player(new Vector2(0, 0), Player.Controller.PC_Player1);
                player2 = new Player(new Vector2(Settings.ScreenWidth - Settings.TankSize.X, Settings.ScreenHeight - Settings.TankSize.Y), Player.Controller.PC_Player2);
            }

            players.Add(player1);
            player2.Direction = new Vector2(-1, 0);
            player2.TurretDirection = new Vector2(-1, 0);
            player2.Color = Color.Red;
            players.Add(player2);

            map = new Map();
            map.LoadMap();

            int[,] currentMap = map.Map1;

            for (int y = 0; y < currentMap.GetLength(0); y++)
                for (int x = 0; x < currentMap.GetLength(1); x++) {
                    if (currentMap[y, x] == 1) {
                        wallList.Add(new Wall(new Vector2(x * Settings.TileSize, y * Settings.TileSize), Wall.Type.INDESTRUCTABLE));
                    }
                    else if (currentMap[y, x] == 2) {
                        wallList.Add(new Wall(new Vector2(x * Settings.TileSize, y * Settings.TileSize), Wall.Type.DESTRUCTABLE));
                    }

                    floorList.Add(new Floor(new Vector2(x * Settings.TileSize, y * Settings.TileSize)));
                }
        }