Пример #1
0
    void RetireSubMapView(HexSubMapView sub)
    {
        sub.DestroyTiles();
        sub.DestroyBlocks();
        sub.ReplaceMesh();
        sub.yIdx        = -1;
        sub.xIdx        = -1;
        sub.inUse       = false;
        sub.layout      = null;
        sub.tileTmpDict = null;

        GameObjectPool.GetInstance().RecycleGo(MapPrefabDef.MAP_SUB_VIEW, sub.gameObject);
    }
Пример #2
0
    /// <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);
            }
        }
    }