/// <summary> /// Initializes the game world by creating a new map, player and enemy. /// </summary> public void Create(Size size) { Size = size; Map = new Map(size.Width / GridSize + 1, size.Height / GridSize + 1); player = new Player(Map.CellCenter(new Point(0, 0))); enemy = new Enemy(Map.RandomFreePosition(), new MoveLogicRandom()); Entities.Add(enemy); Entities.Add(player); Created = true; }
public void Create(Size size, int NumberOfEnemies, string AI) { Entities.Clear(); Size = size; Map = new Map(size.Width / GridSize + 1, size.Height / GridSize + 1); player = new Player(Map.CellCenter(new Point(0, 0))); Entities.Add(player); if (AI == "LogicRandom") { for (int i = 0; i < NumberOfEnemies; i++) { enemy = new Enemy(Map.RandomFreePosition(), new MoveLogicRandom()); Entities.Add(enemy); } } if (AI == "AiMoveSpeedy") { for (int i = 0; i < NumberOfEnemies; i++) { enemy = new Enemy(Map.RandomFreePosition(), new AIMove()); Entities.Add(enemy); } } if(AI == "Random") { for (int i = 0; i < NumberOfEnemies; i++) { if (random.Next(0, 1) == 0) { enemy = new Enemy(Map.RandomFreePosition(), new MoveLogicRandom()); } else { enemy = new Enemy(Map.RandomFreePosition(), new AIMove()); } Entities.Add(enemy); } } Created = true; }
public int Hit(Enemy hitBy) { int damageDealt = Math.Min(Hitpoints, hitBy.DamagePerHit); Hitpoints -= damageDealt; return damageDealt; }