public Map(string JSONFileName) { dynamic mapInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(File.ReadAllText(JSONFileName)); Bounds = new Point((int)mapInfo.Width, (int)mapInfo.Height); Grid = new MapTile[Bounds.X, Bounds.Y]; Number = (int)mapInfo.Number; Name = (string)mapInfo.Name; string lodMapName = $"lod{mapInfo.Number}.map"; string directory = Path.GetDirectoryName(JSONFileName); string lodMapPath = directory + "\\" + lodMapName; ReadFile(lodMapPath); TabMap = new TabMap(this); Floor = new FloorLayer(TabMap); TabMap.Layers.Add(Floor); Grid.Action( (x, y, mapTile) => { mapTile.OnMapLoaded(); mapTile.Register(); mapTile.RegisterLayers(Floor); } ); PathFinder = new PathFinder(this); Loaded = true; }
private Arena() { layers = new FloorLayer[2]; for (int i = 0; i < layers.Length; i++) { layers[i] = new FloorLayer(); } }
void Start() { fightUI = GameObject.Find("Canvas/layer_0/FightModule/fightUI").GetComponent <FightUI>(); floorLayer = GameObject.Find("Canvas/layer_0/FightModule/layers/fight_mask/animLayer/floor").GetComponent <FloorLayer>(); coverLayer = GameObject.Find("Canvas/layer_0/FightModule/layers/fight_mask/animLayer/cover").GetComponent <CoverLayer>(); fancelayer = GameObject.Find("Canvas/layer_0/FightModule/layers/fight_mask/animLayer/fence").GetComponent <FanceLayer>(); floorHideLayer = GameObject.Find("Canvas/layer_0/FightModule/layers/fight_mask/animLayer/floor_hide").GetComponent <FloorHideLayer>(); monsterLayer = GameObject.Find("Canvas/layer_0/FightModule/layers/fight_mask/animLayer/monster").GetComponent <MonsterLayer>(); effectLayer = GameObject.Find("Canvas/layer_0/FightModule/layers/effect").GetComponent <EffectLayer>(); fightModule = GameObject.Find("Canvas/layer_0/FightModule").GetComponent <FightModule>(); PropModel.Instance.PropRefreshEvent = PropRefreshEvent; PropModel.Instance.PropChangeCellsEvent = PropChangeCellsEvent; }
public void loadFloorLayer(TileLayer tileLayer) { floorLayer = new FloorLayer(); for (int i = 0; i < tileMap.height; i++) { floorLayer.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(tileMap.tileheight) }); } for (int i = 0; i < tileMap.width; i++) { floorLayer.ColumnDefinitions.Add(new ColumnDefinition() {Width = new GridLength(tileMap.tilewidth) }); } floorLayer.Width = tileMap.width * tileMap.tilewidth; floorLayer.Height = tileMap.height * tileMap.tileheight; for (int i = 0; i < tileLayer.data.Length; i++) { if (tileLayer.data[i] != 0) { int x = i % tileMap.width; int y = i / tileMap.height; Image img = new Image(); img.Source = tileImgSrcs[tileLayer.data[i]-1]; img.SetValue(Grid.ColumnProperty, x); img.SetValue(Grid.RowProperty, y); floorLayer.Children.Add(img); } } }