protected void FromDungeonGen(int seed, DungeonTemplate template) { Log.InfoFormat("Loading template for world {0}({1})...", Id, Name); var gen = new Generator(seed, template); gen.Generate(); var ras = new Rasterizer(seed, gen.ExportGraph()); ras.Rasterize(); var dTiles = ras.ExportMap(); if (Map == null) { Map = new Wmap(Manager.Resources.GameData); Interlocked.Add(ref _entityInc, Map.Load(dTiles, _entityInc)); if (Blocking == 3) { Sight.CalcRegionBlocks(Map); } } else { Map.ResetTiles(); } InitMap(); }
private unsafe void FromWorldMap(Stream dat, void *world, IntPoint *pos, void *wmap) { Wmap map = (GCHandle.FromIntPtr(new IntPtr(wmap)).Target as Wmap); map.Load(dat, 0); int w = map.Width, h = map.Height; pos->X = ((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Map.Width / 2) - (w / 2); pos->Y = ((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Map.Width / 2) - (w / 2); IEnumerable <Entity> ens = map.InstantiateEntities((GCHandle.FromIntPtr(new IntPtr(world)).Target as World).Manager); foreach (Entity i in ens) { i.Move(i.X + pos->X, i.Y + pos->Y); (GCHandle.FromIntPtr(new IntPtr(world)).Target as World).EnterWorld(i); } }
public static void RenderFromProto(World world, IntPoint pos, ProtoWorld proto) { var manager = world.Manager; // get map stream int map = 0; if (proto.maps != null && proto.maps.Length > 1) { var rnd = new Random(); map = rnd.Next(0, proto.maps.Length); } var ms = new MemoryStream(proto.wmap[map]); var sp = new Wmap(manager.Resources.GameData); sp.Load(ms, 0); sp.ProjectOntoWorld(world, pos); }
protected void FromWorldMap(System.IO.Stream dat) { Log.InfoFormat("Loading map for world {0}({1})...", Id, Name); if (Map == null) { Map = new Wmap(Manager.Resources.GameData); Interlocked.Add(ref _entityInc, Map.Load(dat, _entityInc)); if (Blocking == 3) { Sight.CalcRegionBlocks(Map); } } else { Map.ResetTiles(); } InitMap(); }
protected void FromWorldMap(System.IO.Stream dat) { 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()) { 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 void FromWorldMap(Stream dat) { log.InfoFormat("Loading map for world {0}({1})...", Id, Name); Map = new Wmap(Manager.GameData); entityInc = 0; entityInc += Map.Load(dat, 0); int w = Map.Width, h = Map.Height; EnemiesCollision = new CollisionMap<Entity>(0, w, h); PlayersCollision = new CollisionMap<Entity>(1, w, h); Projectiles.Clear(); StaticObjects.Clear(); Enemies.Clear(); Players.Clear(); foreach (Entity i in Map.InstantiateEntities(Manager)) { EnterWorld(i); } }