public void Update(Minijam32 game) { //If player at point, then advance if (PlayerDataManager.tilePosition == this.TeleportPoint) { if (currentLevelId >= maxLevelId) { hasCompletedLastLevel = true; return; } currentLevelId++; this.ReInitializeLevelData(currentLevelId); game.screenPool.StartNewLevelDelay(game.musicPlayer); } //Update logic for colored plates RedPlatePressed = false; YellowPlatePressed = false; BluePlatePressed = false; for (int x = 0; x < tileGrid.GetLength(0); x++) { for (int y = 0; y < tileGrid.GetLength(1); y++) { if (tileGrid[x, y].type == TileData.Type.ButtonRed && new Point(x, y) == PlayerDataManager.tilePosition) { RedPlatePressed = true; tileGrid[x, y].PressPlate(); } if (tileGrid[x, y].type == TileData.Type.ButtonBlue && new Point(x, y) == PlayerDataManager.tilePosition) { BluePlatePressed = true; tileGrid[x, y].PressPlate(); } if (tileGrid[x, y].type == TileData.Type.ButtonYellow && new Point(x, y) == PlayerDataManager.tilePosition) { YellowPlatePressed = true; tileGrid[x, y].PressPlate(); } } } //Then it's walls: for (int x = 0; x < tileGrid.GetLength(0); x++) { for (int y = 0; y < tileGrid.GetLength(1); y++) { if (RedPlatePressed && tileGrid[x, y].type == TileData.Type.ColorWallRed) { tileGrid[x, y - 1].RemoveColoredWallTopping(); tileGrid[x, y].FlattenColoredWall(); } if (BluePlatePressed && tileGrid[x, y].type == TileData.Type.ColorWallBlue) { tileGrid[x, y - 1].RemoveColoredWallTopping(); tileGrid[x, y].FlattenColoredWall(); } if (YellowPlatePressed && tileGrid[x, y].type == TileData.Type.ColorWallYellow) { tileGrid[x, y - 1].RemoveColoredWallTopping(); tileGrid[x, y].FlattenColoredWall(); } } } //Bombs go boom var bombsDeleteLocations = new List <Point> { }; var iterCollection = new List <Point>(this.plantedBombs.Keys); foreach (var location in iterCollection) { this.plantedBombs[location] -= Minijam32.DeltaUpdate; if (this.plantedBombs[location] <= 0) { bombsDeleteLocations.Add(location); Animator.NewBombAnimation(location - new Point(1, 1)); SoundPlayer.PlaySound(SoundPlayer.Type.BombExplosion); //TODO: boooooom tiles this.tileGrid[location.X, location.Y].Destroy(); this.tileGrid[location.X - 1, location.Y].Destroy(); this.tileGrid[location.X + 1, location.Y].Destroy(); this.tileGrid[location.X, location.Y - 1].Destroy(); this.tileGrid[location.X, location.Y + 1].Destroy(); } } //Enemy go places var enemyDeadList = new List <EnemyAI> { }; foreach (var enemy in enemies) { //Update AI enemy.Update(game); //Check if enemy is at any exploding bombs foreach (var location in bombsDeleteLocations) { if ((enemy.currentPos - location).ToVector2().Length() <= 1) { enemy.Damage(); } } //If enemy is dead, mark it if (enemy.isDead) { enemyDeadList.Add(enemy); SoundPlayer.PlaySound(SoundPlayer.Type.BatDead); } //Check if enemy is touching the hero if (enemy.currentPos == PlayerDataManager.tilePosition) { PlayerDataManager.Damage(); } } //Heal point heals player. Then disapperear List <Point> removeHealDrops = new List <Point> { }; foreach (var healPoint in this.healDrops) { if (healPoint == PlayerDataManager.tilePosition) { PlayerDataManager.Heal(); removeHealDrops.Add(healPoint); Animator.RemoveHeart(healPoint); } } //After we've done the job, let's remove the old junk foreach (var location in bombsDeleteLocations) { //To save cycles, we're checking for self-harm there for each explosion if ((PlayerDataManager.tilePosition - location).ToVector2().Length() <= 1) { PlayerDataManager.Damage(); } this.plantedBombs.Remove(location); } foreach (var enemy in enemyDeadList) { //On each dying enemy, there's a slight chance of spawning heal pts if (Minijam32.Rand.Next(100) <= enemyHealthDropChance) { this.healDrops.Add(enemy.currentPos); Animator.AddHeartAnimation(enemy.currentPos); } this.enemies.Remove(enemy); } foreach (var point in removeHealDrops) { if (healDrops.Contains(point)) { healDrops.Remove(point); } } }