public static bool HandleMapSwitching(Creature creature) { if (creature is Player) { // set all visibile cells to nonvisible before switching maps RayCaster.SetAllInvis(creature.Position, creature.SightDist + 5, creature.WorldIndex, creature.CurrentFloor); } bool success = false; if (creature.Position.X == 0 && creature.WorldIndex.X != 0) { success = creature.MoveMaps(new Point(Program.WorldMap.TileWidth - 1, creature.Position.Y), -1, 0); } else if (creature.Position.Y == Program.WorldMap.TileHeight - 1 && creature.WorldIndex.Y != 3) { success = creature.MoveMaps(new Point(creature.Position.X, 0), 0, +1); } else if (creature.Position.X == Program.WorldMap.TileWidth - 1 && creature.WorldIndex.X != 3) { success = creature.MoveMaps(new Point(0, creature.Position.Y), +1, 0); } else if (creature.Position.Y == 0 && creature.WorldIndex.Y != 0) { success = creature.MoveMaps(new Point(creature.Position.X, Program.WorldMap[0, 0].Height - 1), 0, -1); } return(success); }
public static bool HandleMapSwitching(Creature creature) { // set all visibile cells to invisible so before switching maps RayCaster.SetAllInvis(creature.Position, creature.SightDist + 5); bool success = false; if (creature.Position.X == 0 && Program.WorldMap.WorldIndex.X != 0) { success = creature.MoveMaps(new Point(Program.WorldMap.LocalTile.Width - 1, creature.Position.Y), Program.WorldMap.LocalTile, Program.WorldMap[Program.WorldMap.WorldIndex.X - 1, Program.WorldMap.WorldIndex.Y]); if (success) { Program.WorldMap.WorldIndex.X -= 1; } } else if (creature.Position.Y == Program.WorldMap.LocalTile.Height - 1 && Program.WorldMap.WorldIndex.Y != 4) { success = creature.MoveMaps(new Point(creature.Position.X, 0), Program.WorldMap.LocalTile, Program.WorldMap[Program.WorldMap.WorldIndex.X, Program.WorldMap.WorldIndex.Y + 1]); if (success) { Program.WorldMap.WorldIndex.Y += 1; } } else if (creature.Position.X == Program.WorldMap.LocalTile.Width - 1 && Program.WorldMap.WorldIndex.X != 4) { success = creature.MoveMaps(new Point(0, creature.Position.Y), Program.WorldMap.LocalTile, Program.WorldMap[Program.WorldMap.WorldIndex.X + 1, Program.WorldMap.WorldIndex.Y]); if (success) { Program.WorldMap.WorldIndex.X += 1; } } else if (creature.Position.Y == 0 && Program.WorldMap.WorldIndex.Y != 0) { success = creature.MoveMaps(new Point(creature.Position.X, Program.WorldMap[0, 0].Height - 1), Program.WorldMap.LocalTile, Program.WorldMap[Program.WorldMap.WorldIndex.X, Program.WorldMap.WorldIndex.Y - 1]); if (success) { Program.WorldMap.WorldIndex.Y -= 1; } } return(success); }