protected void FromWorldMap(System.IO.Stream dat) { log.InfoFormat("Loading map for world {0}({1})...", Id, Name); Wmap map = new Wmap(); this.Map = map; entityInc = 0; entityInc += Map.Load(dat, 0); int w = Map.Width, h = Map.Height; Obstacles = new byte[w, h]; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { var tile = Map[x, y]; ObjectDesc desc; if (XmlDatas.TileDescs[tile.TileId].NoWalk) { Obstacles[x, y] = 3; } if (XmlDatas.ObjectDescs.TryGetValue(tile.ObjType, out desc)) { if (desc.Class == "Wall" || desc.Class == "ConnectedWall" || desc.Class == "CaveWall") { Obstacles[x, y] = 2; } else if (desc.OccupySquare || desc.EnemyOccupySquare) { Obstacles[x, y] = 1; } } } } EnemiesCollision = new CollisionMap <Entity>(0, w, h); PlayersCollision = new CollisionMap <Entity>(1, w, h); Projectiles.Clear(); StaticObjects.Clear(); Enemies.Clear(); Players.Clear(); foreach (var i in Map.InstantiateEntities(Manager)) { if (i.ObjectDesc != null && (i.ObjectDesc.OccupySquare || i.ObjectDesc.EnemyOccupySquare)) { Obstacles[(int)(i.X - 0.5), (int)(i.Y - 0.5)] = 2; } EnterWorld(i); } }
protected World() { Players = new ConcurrentDictionary<int, Player>(); Enemies = new ConcurrentDictionary<int, Enemy>(); Quests = new ConcurrentDictionary<int, Enemy>(); Pets = new ConcurrentDictionary<int, Entity>(); Projectiles = new ConcurrentDictionary<Tuple<int, byte>, Projectile>(); StaticObjects = new ConcurrentDictionary<int, StaticObject>(); Timers = new List<WorldTimer>(); ClientXML = ExtraXML = Empty<string>.Array; Map = new Wmap(); AllowTeleport = true; ShowDisplays = true; ExtraXML = XmlDatas.ExtraXml.ToArray(); }
protected World() { Players = new ConcurrentDictionary <int, Player>(); Enemies = new ConcurrentDictionary <int, Enemy>(); Quests = new ConcurrentDictionary <int, Enemy>(); Pets = new ConcurrentDictionary <int, Entity>(); Projectiles = new ConcurrentDictionary <Tuple <int, byte>, Projectile>(); StaticObjects = new ConcurrentDictionary <int, StaticObject>(); Timers = new List <WorldTimer>(); ClientXML = ExtraXML = Empty <string> .Array; Map = new Wmap(); AllowTeleport = true; ShowDisplays = true; ExtraXML = XmlDatas.ExtraXml.ToArray(); }
public bool Delete() { lock (this) { if (Players.Count > 0) { return(false); } Id = 0; } Map = null; Players = null; Enemies = null; Projectiles = null; StaticObjects = null; return(true); }
protected void FromWorldMap(System.IO.Stream dat) { log.InfoFormat("Loading map for world {0}({1})...", Id, Name); Wmap map = new Wmap(); this.Map = map; entityInc = 0; entityInc += Map.Load(dat, 0); int w = Map.Width, h = Map.Height; Obstacles = new byte[w, h]; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { var tile = Map[x, y]; ObjectDesc desc; if (XmlDatas.TileDescs[tile.TileId].NoWalk) Obstacles[x, y] = 3; if (XmlDatas.ObjectDescs.TryGetValue(tile.ObjType, out desc)) { if (desc.Class == "Wall" || desc.Class == "ConnectedWall" || desc.Class == "CaveWall") Obstacles[x, y] = 2; else if (desc.OccupySquare || desc.EnemyOccupySquare) Obstacles[x, y] = 1; } } EnemiesCollision = new CollisionMap<Entity>(0, w, h); PlayersCollision = new CollisionMap<Entity>(1, w, h); Projectiles.Clear(); StaticObjects.Clear(); Enemies.Clear(); Players.Clear(); foreach (var i in Map.InstantiateEntities(Manager)) { if (i.ObjectDesc != null && (i.ObjectDesc.OccupySquare || i.ObjectDesc.EnemyOccupySquare)) Obstacles[(int)(i.X - 0.5), (int)(i.Y - 0.5)] = 2; EnterWorld(i); } }