public Player(int x, int y, KeyControls controls, Texture2D texture, SoundEffect hitSound, Game1 game) : base(x, y, texture, hitSound) { this.controls = controls; oldKb = Keyboard.GetState(); bodyDirecton = Direction.Up; health = BASE_HEALTH; speed = BASE_SPEED; Width = BASE_WIDTH; Height = BASE_HEIGHT; hitDurationMS = BASE_HIT_DURATION_MS; bounds = new Rectangle(x, y, Width, Height); srcRect = new Rectangle(0, Height, Width, Height); this.game = game; }
private void RestartGame() { endRainLoop.Stop(); this.IsMouseVisible = false; fadeTimer = 0; fadeRatio = 0; KeyControls controls = new KeyControls(Keys.W, Keys.S, Keys.A, Keys.D, Keys.Up, Keys.Down, Keys.Left, Keys.Right, Keys.F); player = new Player(400, 400, controls, Content.Load <Texture2D>("player"), Content.Load <SoundEffect>("grunt"), this); RangedStats rangedStats = BasicWeapon.BASE_RANGED_STATS; MeleeStats meleeStats = new MeleeStats(ZombieWeapon.BASE_M_KNOCK_BACK_AMOUNT, ZombieWeapon.BASE_M_KNOCK_BACK_SPEED, ZombieWeapon.BASE_M_RELOAD_TIME_MS, ZombieWeapon.BASE_M_RANGE + 25); player.Weapon = new BasicWeapon(player, rangedStats, meleeStats, Content.Load <Texture2D>("bullet"), whiteTexture, Content.Load <SoundEffect>("BasicGunshot")); //player.Weapon = new Shotgun(player, rangedStats, meleeStats, Content.Load<Texture2D>("bullet"), whiteTexture, Content.Load<SoundEffect>("BasicGunshot")); shotgun = new Shotgun(player, Shotgun.BASE_RANGED_STATS, null, Content.Load <Texture2D>("bullet"), whiteTexture, Content.Load <SoundEffect>("shotgun")); Arena_Bounds = new Rectangle(50, 50, 800, 800); projectiles = new List <Projectile>(); monsters = new List <Monster>(); projectileRemoveList = new List <Projectile>(); monsterRemoveList = new List <Monster>(); meleeAttacks = new List <MeleeAttack>(); powerups = new List <Powerup>(); powerupRemoveList = new List <Powerup>(); spawner = new Spawner(player, Content.ServiceProvider); spawner.AddSpawners(new Vector2(Arena_Bounds.X + Arena_Bounds.Width / 4, Arena_Bounds.Y), new Vector2(Arena_Bounds.X + (3 * Arena_Bounds.Width) / 4, Arena_Bounds.Y), new Vector2(Arena_Bounds.X + Arena_Bounds.Width / 4, Arena_Bounds.Y + Arena_Bounds.Height), new Vector2(Arena_Bounds.X + (3 * Arena_Bounds.Width) / 4, Arena_Bounds.Y + Arena_Bounds.Height) ); if (firstTime) { UpdateApp = UpdateTutorial; DrawApp = DrawTutorial; IsMouseVisible = true; firstTime = false; } else { UpdateApp = UpdateGame; DrawApp = DrawGame; spawner.StartWave(); } }