Example #1
0
 public Camera(Player player, World world, Vector2 startPosition, Rectangle target, Rectangle hudPosition)
 {
     Hud = new HUD(player.Game, hudPosition);
     Player = player;
     World = world;
     Position = startPosition;
     Target = target;
     HudPosition = hudPosition;
 }
Example #2
0
 public override void Fire(World world, Player player, GameTime gameTime)
 {
     if (CooldownTimer <= 0 /*&& MagazineCount > 0*/)
     {
         world.AddProjectile(new HandGrenade(player, player.Position, Vector2.Normalize(player.getReticulePosition() - player.Position) * 200, 5f));
         CooldownTimer = Cooldown;
         //MagazineCount--;
     }
 }
Example #3
0
 public Projectile(String textureName, Rectangle collision, float airResistance, Vector2 gravity, float damage, float radius, bool destructive, Player owner, Vector2 spawnPosition, Vector2 spawnSpeed)
     : base(owner.Game)
 {
     Owner = owner;
     texture = new Sprite(Game, textureName);
     relativeCollision = collision;
     Position = spawnPosition;
     Speed = spawnSpeed;
     this.airResistance = airResistance;
     this.gravity = gravity;
     Damage = damage;
     this.radius = radius;
     this.destructive = destructive;
 }
Example #4
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime, Player player, Rectangle hudPosition, World world)
 {
     //Textures
     spriteBatch.Draw(backgroundTexture, hudPosition, Color.White);
     spriteBatch.Draw(healthIcon, healthIconPosition, Color.White);
     spriteBatch.Draw(healthBar, new Rectangle(healthBarPosition.X, healthBarPosition.Y, player.Health, healthBar.Height), Color.White);
     spriteBatch.Draw(player.Wepon.hudWeaponTexture, weaponPosition, Color.White);
     //Fonts
     spriteBatch.DrawString(HUDfont, player.PlayerName, nameTextPosition, Color.White);
     spriteBatch.DrawString(HUDfont, "Lives:  " + player.Life, lifeTextPosition, Color.OliveDrab);
     spriteBatch.DrawString(HUDfont, "Deaths: " + player.Deaths, deathsTextPosition, Color.Tomato);
     spriteBatch.DrawString(HUDfont, "Kills: " + player.Kills, killsTextPosition, Color.White);
     spriteBatch.DrawString(HUDfont, "Ammo: " + player.Wepon.MagazineCount + "/" + player.Wepon.MagazineSize, ammoTextPosition, Color.White);
 }
Example #5
0
        public InGame(Game game)
            : base(game)
        {
            player = new Player(game, PlayerIndex.One, new Vector2(100f, 100f));
            test = ((ContentLoader<SoundEffect>)Game.Services.GetService(typeof(ContentLoader<SoundEffect>))).get("test").CreateInstance();
            test2 = ((ContentLoader<SoundEffect>)Game.Services.GetService(typeof(ContentLoader<SoundEffect>))).get("test2").CreateInstance();
            test.Play();
            test2.IsLooped = false;
            pauseMenu = new InGameMenu(Game);
            particleEmitter = new TestParticleEmitterKenneth(game, "reticule", 200, player.getReticulePosition(), player.getReticulePositionNormalized(), 200, 200000, Color.White);
            rock = new Sprite(game, "Rock");

            mouseState = Mouse.GetState();
            mouseCollisionRectangle = new Rectangle(mouseState.X, mouseState.Y, 20, 20);

            //Testing av gridnett
            int gridWidth = game.Window.ClientBounds.Width / 100;   //Et rektangel i gridnettet er 100 * 100. Deler derfor på 100 for å få antall rektangler.
            int gridHeight = game.Window.ClientBounds.Height / 100; //Samme her. Tallet fra denne matten blir ikke riktig
            int gridSize = gridWidth * (gridHeight * 2);            //Derfor ganges høyden med 2. Merk at vi da får for mange rektangler totalt, dvs. rektanglene går utenfor skjermen(Bedre enn å ha for få da).
            int x = 0;  //brukes til å plassere rektangler på x-aksen i løkka nedenfor
            int y = 0;  //brukes til å plassere rektangler på y-aksen i løkka nedenfor
            Console.WriteLine(gridSize);    //Debug
            Console.WriteLine(gridWidth);
            Console.WriteLine(gridHeight);
            collisionGrid = new List<CollisionBox>();   //Listen initialiseres
            for (int i = 0; i < gridSize; i++)
            {
                collisionGrid.Add(new CollisionBox(new Rectangle(x, y, 100, 100)));
                x += 100;
                if (collisionGrid.ElementAt(i).rectangle.X > game.Window.ClientBounds.Width)
                {
                    x = 0;
                    y += 100;
                }
            }
        }
Example #6
0
 public abstract void Fire(World world, Player player, GameTime gameTime);
Example #7
0
 public HandGrenade(Player player, Vector2 spawnPosition, Vector2 spawnSpeed, float fuse)
     : base("RPG", new Rectangle(-5, -5, 10, 10), 0, Vector2.UnitY * 150, 15, 10, true, player, spawnPosition, spawnSpeed)
 {
     timer = fuse;
 }
 public Grenade_SimpleFrag(Player player, Vector2 spawnPosition, Vector2 spawnSpeed)
     : base("RPG", new Rectangle(-5, -5, 10, 10), 0, Vector2.UnitY * 150, 15, 10, true, player, spawnPosition, spawnSpeed)
 {
 }
Example #9
0
 public Bullet_Normal(Player player, Vector2 spawnPosition, Vector2 spawnSpeed)
     : base("RPG", new Rectangle(-5, -5, 10, 10), 0, Vector2.UnitY * 50, 15, 10, true, player, spawnPosition, spawnSpeed)
 {
 }