public void MovePlayerBy(Point amount) { Point newPosition = Player.Position + amount; if (!new Rectangle(0, 0, Width, Height).Contains(newPosition) || !rogueMap.IsWalkable(newPosition.X, newPosition.Y)) { return; } if (Monsters.ContainsKey(newPosition)) { Game.CombatSystem.Attack(Player, Monsters[newPosition]); } else { Player.Position += amount; detailedMap.OpenDoor(Player, Player.Position.X, Player.Position.Y, ref mapData); // TODO: fix this possitioning horror TextSurface.RenderArea = new Rectangle(Player.Position.X - (TextSurface.RenderArea.Width / 2), Player.Position.Y - (TextSurface.RenderArea.Height / 2), TextSurface.RenderArea.Width, TextSurface.RenderArea.Height); // If he view area moved, we'll keep our entity in sync with it. Player.RenderOffset = Position - TextSurface.RenderArea.Location; // Update FoV foreach (var cell in previousFOV) { mapData[cell.X, cell.Y].RemoveCellFromView(this[cell.X, cell.Y]); } previousFOV = rogueFOV.ComputeFov(Player.Position.X, Player.Position.Y, 10, true); foreach (var cell in previousFOV) { rogueMap.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true); mapData[cell.X, cell.Y].RenderToCell(this[cell.X, cell.Y], true, rogueMap.GetCell(cell.X, cell.Y).IsExplored); } } GameWorld.DungeonScreen.StatsConsole.Clear(); GameWorld.DungeonScreen.StatsConsole.DrawPlayerStats(Player); int idx = 0; foreach (KeyValuePair <Point, Monster> monster in Monsters) { if (rogueFOV.IsInFov(monster.Value.Position.X, monster.Value.Position.Y)) { monster.Value.InFoV = true; GameWorld.DungeonScreen.StatsConsole.DrawMonsterStats(monster.Value, idx); idx++; } else { monster.Value.InFoV = false; } } }
public void TrackMonster(Monster monster) { GameLocation location = Game1.player.currentLocation; if (!Monsters.ContainsKey(location)) { Monsters[location] = new List <Monster>(); } Monsters[location].Add(monster); }
// produce or hint monsters public Monster CreateMonster(int x, int y, int playerLevel) { if (Monsters.ContainsKey(y * Width + x) && Monsters[y * Width + x] != null) { return(Monsters[y * Width + x]); } if (monDict.ContainsKey(y * Width + x) && monDict[y * Width + x] != null) { return(monDict[y * Width + x].Create(playerLevel)); } return(null); }
public void MoveMonster(Monster monster, Cell cell) { //if (detailedMap.SetActorPosition(monster, cell.X, cell.Y)) return; Point newLocation = new Point(cell.X, cell.Y); if (Player.Position.X == cell.X && Player.Position.Y == cell.Y) { Game.CombatSystem.Attack(monster, GameWorld.DungeonScreen.MapConsole.Player); } else if (rogueMap.IsWalkable(cell.X, cell.Y) && !Monsters.ContainsKey(newLocation)) { Monsters.Remove(new Point(monster.Position.X, monster.Position.Y)); monster.Position = newLocation; Monsters.Add(newLocation, monster); } }