public SetTileAction(int x, int y, int z, int tilesetIndex, int tileIndex) { this.map = EditorEngine.Instance.CurrentMap; this.X = x; this.Y = y; this.Z = z; this.TileIndex = tileIndex; this.TilesetIndex = tilesetIndex; }
public List<WildPokemonInfo> getDataInfo(Map map) { bool ok = false; List<WildPokemonInfo> result = null; foreach (Tuple<Map, List<WildPokemonInfo>> t in infos) { if (map == t.Item1) { result = t.Item2; ok = true; } } //information does not exist for this map ... yet! if (!ok) { result = new List<WildPokemonInfo>(); infos.Add(new Tuple<Map, List<WildPokemonInfo>>(map, result)); } return result; }
public Map CreateMap(World world) { Map result = new Map(world.EntityFactory, Name, Author, Width, Height); result.Tilesets = this.Tilesets; foreach (MockupTileset tileset in result.Tilesets) { tileset.world = world; } result.Tiles = Tiles; for (int i = 0; i < result.Width; i++) for (int j = 0; j < result.Height; j++) for (int k = 0; k < Map.LayerCount; k++) Tiles[i][j][k].map = result; foreach (Tuple<Int32, Vector2> token in Entities) { MapEntity e = world.EntityContainer.Get(token.Item1).CreateEntity(world.EntityFactory); e.Position = token.Item2; result.Entities.Add(e); } return result; }
public void Encode(BinaryOutput stream, Map map) { stream.Write(map.Name); stream.Write(map.Author); stream.Write(map.Width); stream.Write(map.Height); stream.Write(map.Tilesets); for (int i = 0; i < map.Width; i++) { for (int j = 0; j < map.Height; j++) { for (int k = 0; k < Map.LayerCount; k++) { map.Tiles[i][j][k].Encode(stream); } } } stream.Write(map.Entities.Count); foreach (MapEntity e in map.Entities) { stream.Write(e.TemplateID); stream.Write(e.Position); } }
public MockupTile(Map map, int tileIndex, int tilesetIndex) { this.map = map; this.tileIndex = tileIndex; this.tilesetIndex = tilesetIndex; }
public void RenderMap(Map map) { List<MapEntity> entitiesToRender = new List<MapEntity>(); GameTime time = new GameTime(); map.Draw(time); foreach (MapEntity entity in map.Entities) { entitiesToRender.Add(entity); } entitiesToRender.Sort(delegate(MapEntity a, MapEntity b) { float positionA = a.Position.Y + a.Template.Texture.FrameHeight; float positionB = b.Position.Y + b.Template.Texture.FrameHeight; if (a.TopMost && !b.TopMost) return 1; if (!a.TopMost && b.TopMost) return -1; if (positionA > positionB) return 1; if (positionA < positionB) return -1; if (positionA == positionB) { if (a.Position.X > b.Position.X) return -1; if (a.Position.X < b.Position.X) return 1; } return 0; }); foreach (MapEntity entity in entitiesToRender) { entity.BeginDraw(time); entity.Draw(time); entity.EndDraw(time); } }
public void SwapMap(Map map) { this.CurrentMap = map; }
public Map CreateMap(string name, int w, int h, List<string> sheets) { Map result = new Map(World.EntityFactory, name, World.Author, w, h); CurrentMap = result; World.Maps.Add(result); foreach (string arg in sheets) { int tilesetIndex = GetTilesetIndexByName(arg); MockupTileset reference = new MockupTileset(World, tilesetIndex); CurrentMap.Tilesets.Add(reference); } ScreenInterface.Initialize(); return result; }
public ActionManager GetActionManager(Map map) { if (map != null) { if (ActionManagers.ContainsKey(map.Name)) { return ActionManagers[map.Name]; } else { ActionManager result = new ActionManager(); ActionManagers.Add(map.Name, result); return result; } } return null; }
public void addData(Map map, WildPokemonInfo info) { getDataInfo(map).Add(info); }
public MapEntity(IRegionEntityFactory factory, Map map, bool ScrollAffected) : this(factory, ScrollAffected) { this.Map = map; }
public IEncodable Decode(BinaryInput stream) { stream.GraphicsDevice = EditorEngine.Instance.GraphicsDevice; RegionName = stream.ReadString(); RegionAuthor = stream.ReadString(); World world = EditorEngine.Instance.CreateRegion(RegionName); world.TilesetContainer.Decode(stream); world.EntityContainer.Decode(stream); world.EntityTemplateFactory.Decode(stream); world.TilesetFactory.Decode(stream); world.UIContainer.Decode(stream); world.SpriteLibrary.Decode(stream); this.RootNode = new TreeNode(RegionName); TreeNode lastNode = null; TreeNode currentNode = RootNode; int c = stream.ReadInt32(); for (int i = 0; i < c; i++) { int code = stream.ReadInt32(); switch (code) { case 0x01: string text = stream.ReadString(); TreeNode node = new TreeNode(text); currentNode.Nodes.Add(node); lastNode = node; break; case 0x02: currentNode = lastNode; break; case 0x03: currentNode = currentNode.Parent; break; case 0x04: /*RECREATE FROM DETAILS*/ Map m = new Map(EditorEngine.Instance.World.EntityFactory); m.Name = stream.ReadString(); m.Author = stream.ReadString(); m.Width = stream.ReadInt32(); m.Height = stream.ReadInt32(); m.Tiles = new MockupTile[m.Width][][]; for (int x = 0; x < m.Width; x++) { m.Tiles[x] = new MockupTile[m.Height][]; for (int y = 0; y < m.Height; y++) { m.Tiles[x][y] = new MockupTile[Map.LayerCount]; } } /* READ ALL MOCKUP TILESETS */ int c1 = stream.ReadInt32(); for (int j = 0; j < c1; j++) { string name = stream.ReadString(); m.Tilesets.Add(new MockupTileset(world, EditorEngine.Instance.GetTilesetIndexByName(name))); } m.Fill(-1, 0); Map oldCurrentMap = EditorEngine.Instance.CurrentMap; EditorEngine.Instance.CurrentMap = m; List<byte> visited = new List<byte>(); /* READ MOCKUP TILE BEHAVIORS */ m.Behaviors = new MockupTileBehavior[m.Width,m.Height]; for (int j = 0; j < m.Width * m.Height; j++) { int x = j % m.Width; int y = j / m.Height; m.Behaviors[x, y] = stream.ReadObject<MockupTileBehavior>(); } /* READ ACTIONS/REBUILD MAP */ ActionManager actionmanager = EditorEngine.Instance.GetActionManager(); ActionIO reader = new ActionIO(stream); int c2 = stream.ReadInt32(); for (int j = 0; j < c2; j++) { IAction act = reader.Read(); actionmanager.Execute(act); } /*DATA TREE NODE*/ TreeNode node2 = new TreeNode(m.Name); node2.Tag = m; node2.ImageKey = "document.png"; node2.SelectedImageKey = "document.png"; if (currentNode != null) currentNode.Nodes.Add(node2); else Console.WriteLine("WARNING: CurrentNode is null (Project.Decode)"); EditorEngine.Instance.CurrentMap = oldCurrentMap; break; } } return this; }
public SetTileAction() { this.map = EditorEngine.Instance.CurrentMap; }