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--; } }
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; } } }