internal void PlaceMonsters(Random rand) { Coordinate center = Center(); int monsterCount = rand.Next(0, 3); for (int i = 0; i < monsterCount; i++) { Constants.Monsters choice = RandomChoiceMonsters(rand, MonsterChances); GameObject monster = null; if (choice == Constants.Monsters.Orc) { monster = new GameObject("Orc", Tiles.Enemy.OrcTile, center.X + rand.Next(-1, 2), center.Y + rand.Next(-1, 2)); monster.Fighter = new Fighter(monster, 8, 5, 2, 2, Constants.AI.BasicMonster, Constants.Death.GenericDeath); } else if (choice == Constants.Monsters.Troll) { monster = new GameObject("Troll", Tiles.Enemy.TrollTile, center.X + rand.Next(-1, 2), center.Y + rand.Next(-1, 2)); monster.Fighter = new Fighter(monster, 10, 6, 3, 3, Constants.AI.BasicMonster, Constants.Death.GenericDeath); } if (monster != null && !GameMap.Blocked(monster.X, monster.Y)) { Rogue.GameWorld.Objects.Add(monster); } } }
internal void Move(int dx, int dy) { if (this != Rogue.GameWorld.Player) { if (dx == 0 && dy == -1) { if (Fighter.Direction != 0) { Fighter.Direction = 0; return; } } if (dx == -1 && dy == 0) { if (Fighter.Direction != 90) { Fighter.Direction = 90; return; } } if (dx == 0 && dy == 1) { if (Fighter.Direction != 180) { Fighter.Direction = 180; return; } } if (dx == 1 && dy == 0) { if (Fighter.Direction != 270) { Fighter.Direction = 270; return; } } } if (!GameMap.Blocked(X + dx, Y + dy)) { if (this == Rogue.GameWorld.Player || FoV.InFov(Rogue.GameWorld.Player.X, Rogue.GameWorld.Player.Y, X, Y, Rogue.GameWorld.Player)) { if (dx == 1 || dx == -1) { for (int x = 0; x < 64 / Constants.MoveSmoothSteps; x++) { OffsetX += Constants.MoveSmoothSteps * dx; if (this != Rogue.GameWorld.Player) { Rendering.RenderAll(this); Draw("white", true); Terminal.Refresh(); } else { Rendering.RenderAll(); } } OffsetX = 0; } if (dy == 1 || dy == -1) { for (int x = 0; x < 64 / Constants.MoveSmoothSteps; x++) { OffsetY += Constants.MoveSmoothSteps * dy; if (this != Rogue.GameWorld.Player) { Rendering.RenderAll(this); Draw("white", true); Terminal.Refresh(); } else { Rendering.RenderAll(); } } OffsetY = 0; } if (this == Rogue.GameWorld.Player) { Camera.HandleMoveCamera(dx, dy); } } X += dx; Y += dy; } }