HexSubMapView CreateSubMapViewInEditor(int x, int y) { HexSubMapView sub = null; var cachedGo = GameObjectPool.GetInstance().WithdrawGo(MapPrefabDef.MAP_SUB_VIEW); if (null == cachedGo) { sub = Instantiate(subMapViewTemplate); LogModule.WarningLog("HexSubMapView Allocated!"); } else { sub = cachedGo.GetComponent <HexSubMapView>(); } sub.name = string.Format("({0}, {1})", x, y); //sub.tileTmpDict = App.MapTileLoader.TileTmpDict; sub.hex = hex; sub.layout = Layout; sub.xIdx = x; sub.yIdx = y; sub.transform.parent = transform; sub.InitPos(); if (MapEditorEntry.Instance != null) { switch (MapEditorEntry.Instance.curOp) { case MapEditorEntry.EDIT_OP.EDIT_AREA: sub.InitBg(false); sub.ShowMarks(MapEditorEntry.EDIT_OP.EDIT_AREA, MapEditorEntry.Instance.campColors); break; case MapEditorEntry.EDIT_OP.EDIT_LV: sub.InitBg(false); sub.ShowMarks(MapEditorEntry.EDIT_OP.EDIT_LV, MapEditorEntry.Instance.levelColors); break; case MapEditorEntry.EDIT_OP.EDIT_TILETYPE: sub.InitBg(false); sub.ShowMarks(MapEditorEntry.EDIT_OP.EDIT_TILETYPE, MapEditorEntry.Instance.typeColors); break; default: sub.InitBg(true); sub.HideMarks(); sub.InitBlocks(); break; } } return(sub); }
/// <summary> /// 地图编辑器强制刷新 /// </summary> /// <param name="tileCoord"></param> public void ForceRereshSubMapView(Coord tileCoord) { List <Coord> needRefresh = new List <Coord>(); Coord submapCoord = new Coord(); submapCoord.x = Mathf.FloorToInt(tileCoord.x / hex.xTile); submapCoord.y = Mathf.FloorToInt(tileCoord.y / hex.yTile); needRefresh.Add(submapCoord); int cx = tileCoord.x % hex.xTile; int cy = tileCoord.y % hex.yTile; if (cx == 0) { needRefresh.Add(new Coord(submapCoord.x - 1, submapCoord.y)); } if (cy == 0) { needRefresh.Add(new Coord(submapCoord.x - 1, submapCoord.y)); } if (cx == 0 && cy == 0) { needRefresh.Add(new Coord(submapCoord.x - 1, submapCoord.y - 1)); } if (cx == hex.xTile - 1) { needRefresh.Add(new Coord(submapCoord.x + 1, submapCoord.y)); } if (cy == hex.yTile) { needRefresh.Add(new Coord(submapCoord.x - 1, submapCoord.y)); } if (cx == hex.xTile && cy == hex.yTile) { needRefresh.Add(new Coord(submapCoord.x + 1, submapCoord.y + 1)); } foreach (Coord coord in needRefresh) { if (subMapViews.ContainsKey(coord)) { HexSubMapView submap = subMapViews[coord]; if (MapEditorEntry.Instance != null) { submap.DestroyTiles(); submap.DestroyBlocks(); submap.ReplaceMesh(); switch (MapEditorEntry.Instance.curOp) { case MapEditorEntry.EDIT_OP.EDIT_AREA: submap.InitBg(false); submap.ShowMarks(MapEditorEntry.EDIT_OP.EDIT_AREA, MapEditorEntry.Instance.campColors); return; case MapEditorEntry.EDIT_OP.EDIT_LV: submap.InitBg(false); submap.ShowMarks(MapEditorEntry.EDIT_OP.EDIT_LV, MapEditorEntry.Instance.levelColors); return; case MapEditorEntry.EDIT_OP.EDIT_TILETYPE: submap.InitBg(false); submap.ShowMarks(MapEditorEntry.EDIT_OP.EDIT_TILETYPE, MapEditorEntry.Instance.typeColors); break; default: submap.InitBg(); submap.InitBlocks(); submap.HideMarks(); break; } } submap.SetPitch(MapView.Current.CameraPitch); } } }