public void SpawnBomb(Vetbol vetbol, Vector2 direction) { FatBomb bomb = this.BombPool.New(); direction.Y *= -1; bomb.Velocity = direction * 1200; bomb.Position = vetbol.Position; bomb.Activate(vetbol); }
public GameState() { this.BigText = new Label("Player 1 is out", Controller.FontController.GetFont("bigFont")); this.BigText.HorizontalAlign = HorizontalAlign.CENTER; this.BigText.Visable = false; this.BigText.Width = 1800; this.BigText.Height = 1000; Controller.LayerController.AddLayer("bombLayer"); FatBomb.state = this; Vetbol.state = this; CapturePoint.state = this; TiledSprite bg = new TiledSprite(2000, 2000); bg.LoadTexture("background"); bg.Depth = 0f; tilemap = new Tilemap(); tilemap.LoadMap("Content/testmap.tmx", 32, 32); this.AddChild(bg); this.AddChild(tilemap); this.players = new List<Vetbol>(); playerSpawn = tilemap.RemoveTiles(7); int playerRespawn = rnd.Next(playerSpawn.Count); List<Tile> capturePointTiles = tilemap.RemoveTiles(3); foreach (Tile tile in capturePointTiles) { CapturePoint capturepoint = new CapturePoint(); capturepoint.Position = tile.Position + ( new Vector2(-27, -61)); capturePoints.Add(capturepoint); AddChild(capturepoint); } NotUsedSpawnPoints = new List<Tile>(); NotUsedSpawnPoints.AddRange(playerSpawn); for (int i = 0; i < Controller.Input.getPadStateList.Where(c => c.IsConnected).Count(); i++) { this.players.Add(new Vetbol((PlayerIndex)i)); } for (int j = 0; j < players.Count; j++) { this.players[j].score = playerStartScore; this.players[j].Position = this.getAvailablePosition(); this.AddChild(this.players[j]); } lastPlayerAlive = players[0]; this.BombPool = new Pool<FatBomb>(50, false, FatBomb.IsValid, this.NewBomb); soundEffectBomb = Controller.Content.Load<SoundEffect>("sounds/explode"); this.AddChild(this.BigText); this.hud = new HUD(this.players, respawnTime); this.AddChild(hud); deadSound = Controller.Content.Load<SoundEffect>("sounds/dead"); ECGsound = Controller.Content.Load<SoundEffect>("sounds/ecg"); }
private void RespawnPlayer(Vetbol player) { hud.PlayerSpawned(player); player.Activate(); player.IsFlickering = true; }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { if (this.BigText.Visable) { this.BigTextTimer -= (int)gameTime.ElapsedGameTime.TotalMilliseconds; if (this.BigTextTimer < 0) { this.BigText.Visable = false; } } if (isPlayable) { updateScoreTime -= gameTime.ElapsedGameTime.Milliseconds; if (updateScoreTime <= 0) { updateScoreTime = 5000; int playersAlive = 0; totalScore = 0; foreach (Vetbol player in this.players) { int pointsOwned = 0; foreach (CapturePoint point in capturePoints) { if (point.owner == player) pointsOwned++; } totalScore += player.score; player.score -= (capturePoints.Count - pointsOwned); if (player.score <= 0) { player.score = 0; if (player.Active) { player.Deactivate(); this.ShowText("Player " + (int)(player.index + 1) + " is out!"); deadSound.Play(0.1f, 0, 0); //TODO feedback of dead player in HUD } } else { playersAlive++; } //TODO: update HUD score int minBeat = 1000; int maxBeat = 270; int minPoints = capturePoints.Count; int maxPoints = playerStartScore * players.Count; int score = ((minBeat - maxBeat) / (maxPoints - minPoints)) * totalScore; tilemap.beatRate = score - 50; System.Diagnostics.Debug.WriteLine(score); //TODO: adjust beatrate of the map } if (playersAlive <= 1) { isPlayable = false; } } for (int i = 0; i < players.Count; i++) { if (respawnTimers.ContainsKey(players[i])) { respawnTimers[players[i]] -= gameTime.ElapsedGameTime; if (respawnTimers[players[i]].TotalMilliseconds <= 0) { this.RespawnPlayer(players[i]); this.players[i].Position = this.playerSpawn[i].Position; respawnTimers.Remove(players[i]); } } } } else { tilemap.heartIsBeating = false; if (countDownToEndscreen == 3000) ECGsound.Play(0.15f, 0, 0); countDownToEndscreen -= gameTime.ElapsedGameTime.Milliseconds; //TODO: play beepsound if (countDownToEndscreen <= 0) { lastPlayerAlive = players[0]; foreach (Vetbol player in players) { if (player.score >= lastPlayerAlive.score) { lastPlayerAlive = player; } } Controller.SwitchState(new EndScreen(lastPlayerAlive.index, lastPlayerAlive.image.Color)); } else if (countDownToEndscreen <= 1000) { //TODO: fade black in Alpha -= 0.1f; } } base.Update(gameTime); }
public GameState() { this.BigText = new Label("Player 1 is out", Controller.FontController.GetFont("bigFont")); this.BigText.HorizontalAlign = HorizontalAlign.CENTER; this.BigText.Visable = false; this.BigText.Width = 1800; this.BigText.Height = 1000; Controller.LayerController.AddLayer("bombLayer"); FatBomb.state = this; Vetbol.state = this; CapturePoint.state = this; TiledSprite bg = new TiledSprite(2000, 2000); bg.LoadTexture("background"); bg.Depth = 0f; tilemap = new Tilemap(); tilemap.LoadMap("Content/testmap.tmx", 32, 32); this.AddChild(bg); this.AddChild(tilemap); this.players = new List <Vetbol>(); playerSpawn = tilemap.RemoveTiles(7); int playerRespawn = rnd.Next(playerSpawn.Count); List <Tile> capturePointTiles = tilemap.RemoveTiles(3); foreach (Tile tile in capturePointTiles) { CapturePoint capturepoint = new CapturePoint(); capturepoint.Position = tile.Position + (new Vector2(-27, -61)); capturePoints.Add(capturepoint); AddChild(capturepoint); } NotUsedSpawnPoints = new List <Tile>(); NotUsedSpawnPoints.AddRange(playerSpawn); for (int i = 0; i < Controller.Input.getPadStateList.Where(c => c.IsConnected).Count(); i++) { this.players.Add(new Vetbol((PlayerIndex)i)); } for (int j = 0; j < players.Count; j++) { this.players[j].score = playerStartScore; this.players[j].Position = this.getAvailablePosition(); this.AddChild(this.players[j]); } lastPlayerAlive = players[0]; this.BombPool = new Pool <FatBomb>(50, false, FatBomb.IsValid, this.NewBomb); soundEffectBomb = Controller.Content.Load <SoundEffect>("sounds/explode"); this.AddChild(this.BigText); this.hud = new HUD(this.players, respawnTime); this.AddChild(hud); deadSound = Controller.Content.Load <SoundEffect>("sounds/dead"); ECGsound = Controller.Content.Load <SoundEffect>("sounds/ecg"); }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { if (this.BigText.Visable) { this.BigTextTimer -= (int)gameTime.ElapsedGameTime.TotalMilliseconds; if (this.BigTextTimer < 0) { this.BigText.Visable = false; } } if (isPlayable) { updateScoreTime -= gameTime.ElapsedGameTime.Milliseconds; if (updateScoreTime <= 0) { updateScoreTime = 5000; int playersAlive = 0; totalScore = 0; foreach (Vetbol player in this.players) { int pointsOwned = 0; foreach (CapturePoint point in capturePoints) { if (point.owner == player) { pointsOwned++; } } totalScore += player.score; player.score -= (capturePoints.Count - pointsOwned); if (player.score <= 0) { player.score = 0; if (player.Active) { player.Deactivate(); this.ShowText("Player " + (int)(player.index + 1) + " is out!"); deadSound.Play(0.1f, 0, 0); //TODO feedback of dead player in HUD } } else { playersAlive++; } //TODO: update HUD score int minBeat = 1000; int maxBeat = 270; int minPoints = capturePoints.Count; int maxPoints = playerStartScore * players.Count; int score = ((minBeat - maxBeat) / (maxPoints - minPoints)) * totalScore; tilemap.beatRate = score - 50; System.Diagnostics.Debug.WriteLine(score); //TODO: adjust beatrate of the map } if (playersAlive <= 1) { isPlayable = false; } } for (int i = 0; i < players.Count; i++) { if (respawnTimers.ContainsKey(players[i])) { respawnTimers[players[i]] -= gameTime.ElapsedGameTime; if (respawnTimers[players[i]].TotalMilliseconds <= 0) { this.RespawnPlayer(players[i]); this.players[i].Position = this.playerSpawn[i].Position; respawnTimers.Remove(players[i]); } } } } else { tilemap.heartIsBeating = false; if (countDownToEndscreen == 3000) { ECGsound.Play(0.15f, 0, 0); } countDownToEndscreen -= gameTime.ElapsedGameTime.Milliseconds; //TODO: play beepsound if (countDownToEndscreen <= 0) { lastPlayerAlive = players[0]; foreach (Vetbol player in players) { if (player.score >= lastPlayerAlive.score) { lastPlayerAlive = player; } } Controller.SwitchState(new EndScreen(lastPlayerAlive.index, lastPlayerAlive.image.Color)); } else if (countDownToEndscreen <= 1000) { //TODO: fade black in Alpha -= 0.1f; } } base.Update(gameTime); }