private List <Data.MonsterData> _parseMonsters() { var monsters = new List <Data.MonsterData>(); for (uint r = 0; r < Height; ++r) { for (uint c = 0; c < Width; ++c) { var go = mLayerCollide[r, c]; if (go == null) { continue; } var tile = go.GetComponent <Tile>(); if (tile.TileType == Logic.Tile.EType.Monster) { var data = new Data.MonsterData(); data.Pos = new Logic.TilePosition(r, c); data.Id = (uint)tile.Properties["MonsterId"]; monsters.Add(data); } } } return(monsters); }
public Tile CreateMonster(Data.MonsterData data) { var monster = new Tile_Monster(data); monster.IsBlock = false; return(monster); }
public void Save(string file_path) { var tile_map_data = new Data.TileMapData(); tile_map_data.Level = Level; tile_map_data.Width = Width; tile_map_data.Height = Height; tile_map_data.FloorLayer = _parseFloorLayer(); tile_map_data.MonsterDatas = new List <Data.MonsterData>(); tile_map_data.PortalDatas = new List <Data.PortalData>(); tile_map_data.ItemDatas = new List <Data.ItemData>(); for (uint r = 0; r < Height; ++r) { for (uint c = 0; c < Width; ++c) { var go = mLayerCollide[r, c]; if (go == null) { continue; } var tile = go.GetComponent <Tile>(); switch (tile.TileType) { case Logic.Tile.EType.Monster: { var data = new Data.MonsterData(); data.Pos = new Logic.TilePosition(r, c); data.Id = (uint)tile.Properties["MonsterId"]; tile_map_data.MonsterDatas.Add(data); break; } case Logic.Tile.EType.Portal: { var data = new Data.PortalData(); data.Pos = new Logic.TilePosition(r, c); data.DestinationLevel = (uint)tile.Properties["DestLevel"]; data.DestinationPosition = (Logic.TilePosition)tile.Properties["DestPos"]; tile_map_data.PortalDatas.Add(data); break; } } } } using (var file = new FileStream(file_path, FileMode.Create)) { var formatter = new BinaryFormatter(); formatter.Serialize(file, tile_map_data); } }
public IEnumerator SaveToData() { foreach (Tile tile in LayerFloor) { if (tile != null) { Data.FloorLayer[tile.Position.Row, tile.Position.Col] = tile.Type; } } var monsters = new List <Data.MonsterData>(); var portals = new List <Data.PortalData>(); foreach (Tile tile in LayerCollide) { if (tile != null) { switch (tile.Type) { case Tile.EType.Monster: { var monster_data = new Data.MonsterData(); monster_data.Pos = tile.Position; monster_data.Id = (tile as Tile_Monster).Id; monsters.Add(monster_data); break; } case Tile.EType.Portal: { var portal_data = new Data.PortalData(); portal_data.Pos = tile.Position; portal_data.DestinationLevel = (tile as Tile_Portal).DestinationLevel; portal_data.DestinationPosition = (tile as Tile_Portal).DestinationPosition; portals.Add(portal_data); break; } } } } Data.MonsterDatas = monsters; Data.PortalDatas = portals; yield return(null); }
public Tile_Monster(Data.MonsterData data) : base(EType.Monster) { Data = data; mHp = CsvData.GetUIntValue("hp"); }