public void removeEnemy(Enemy enemy) { if (enemy != null) { enemy.Active = false; } }
public void createExplosion(Enemy enemy, GameTime time) { Explosion explosion = new Explosion(); explosion.Texture = explosionTexture; explosion.Width = explosion.Texture.Width / numFrames; explosion.Height = explosion.Texture.Height; explosion.Move(enemy.Position.X + (enemy.Width * 0.5f), enemy.Position.Y + (enemy.Width * 0.5f)); explosion.ScaleFactor = 4f + RandomHandler.GetRandomFloat(2); explosion.Rotation = RandomHandler.GetRandomFloat(360); explosion.Speed = animSpeed + RandomHandler.GetRandomFloat(2); explosion.LayerDepth = 0f; explosion.Color = Color.White; explosion.CreationTime = (long)time.TotalGameTime.TotalMilliseconds; explosion.Active = true; explosionSprites.Add(explosion); if (debug) { Console.WriteLine("Created new explosion at: " + enemy.Position.ToString()); } }
private void createEnemy() { if (enemyTextures.Count > 0) { Enemy enemy = new Enemy(); enemy.Texture = getRandomEnemyTexture(); enemy.Width = 100; enemy.Height = 100; if (enemy.Texture == enemyTextures.ElementAt(0)) { enemy.IsSheep = true; } else { enemy.IsSheep = false; } enemy.Speed = 0.5f; enemy.LayerDepth = 0f; enemy.ScaleFactor = 1f; enemy.Color = ColorHandler.getCurrentColor(); enemy.Active = true; if (enemy.IsSheep) { enemy.Move(enemyStartPosition.X, enemyStartPosition.Y + RandomHandler.GetRandomInt(-10, 10)); } else { enemy.Move(enemyStartPosition.X, enemyStartPosition.Y - 50 + RandomHandler.GetRandomInt(-10, 10)); } enemySprites.Add(enemy); } }
private void lateInit() { hero.createHero(); bg = new BackgroundHandler(); fg = new ForegroundHandler(); skyHandler = new SkyHandler(); obstacleHandler = new ObstacleHandler(); itemsHandler = new ItemsHandler(hero); enemy = new Enemy(); explosion = new Explosion(); osc = new OSCHandler(); RandomHandler.init(); ColorHandler.loadColors(); GameStateHandler.CurrentState = GameState.IDLE; handleSettingsInput(); }