Beispiel #1
0
    void Init()
    {
        mapProxy = GameFacade.GetProxy <MapProxy>();
        foreach (Dropdown dd in sprLists)
        {
            dd.ClearOptions();
            dd.AddOptions(MapView.Current.Lod0.hex.GetSprNames());
            dd.onValueChanged.AddListener((int sprIndex) =>
            {
                mIsClickEditArea = true;
                ChangeCurOp(EDIT_OP.EDIT_SPRLIST);
                blockTypeLayout.transform.parent.gameObject.SetActive(false);
                UpdateCurOpTips("Change Spr List " + sprIndex);
                List <int> sprs = new List <int>(4);
                for (int i = 0; i < 4; i++)
                {
                    sprs.Add(sprLists[i].value);
                }
                mapProxy.SeedSprList(mCurLeftClicked.GetSubmapCoord(), sprs);
                MapView.Current.Lod0.ForceRereshSubMapView(mCurLeftClicked);
            });
        }

        foreach (Toggle btn in texGroup.GetComponentsInChildren <Toggle>())
        {
            byte index = byte.Parse(btn.name.Substring(1, 1));
            btn.onValueChanged.AddListener((bool isOn) =>
            {
                if (isOn)
                {
                    mIsClickEditArea = true;
                    ChangeCurOp(EDIT_OP.EDIT_TEX);
                    blockTypeLayout.transform.parent.gameObject.SetActive(false);
                    mTexIndex = (byte)(index - 1);
                    UpdateCurOpTips("Texture " + mTexIndex);
                }
            });
        }

        foreach (Button btn in heightLayout.GetComponentsInChildren <Button>())
        {
            byte index = byte.Parse(btn.name.Substring(1, 1));
            btn.onClick.AddListener(() =>
            {
                mIsClickEditArea = true;
                ChangeCurOp(EDIT_OP.EDIT_HEIGHT);
                blockTypeLayout.transform.parent.gameObject.SetActive(false);
                mHeightOp = index == 2 ? true : false;
                UpdateCurOpTips(mHeightOp ? "Height+1 " : "Height-1");
            });
        }

        foreach (Button btn in campLayout.GetComponentsInChildren <Button>())
        {
            byte index = byte.Parse(btn.name.Substring(1, 1));
            btn.onClick.AddListener(() =>
            {
                mIsClickEditArea = true;
                ChangeCurOp(EDIT_OP.EDIT_AREA);
                blockTypeLayout.transform.parent.gameObject.SetActive(false);
                mCampIndex = index;
                UpdateCurOpTips("Area " + mCampIndex);
            });
        }

        foreach (Button btn in levelLayout.GetComponentsInChildren <Button>())
        {
            byte index = byte.Parse(btn.name.Substring(1, 1));
            btn.onClick.AddListener(() =>
            {
                mIsClickEditArea = true;
                ChangeCurOp(EDIT_OP.EDIT_LV);
                blockTypeLayout.transform.parent.gameObject.SetActive(false);
                mLvIndex = index;
                UpdateCurOpTips("Level " + mLvIndex);
            });
        }

        foreach (Button btn in tileTypeLayout.GetComponentsInChildren <Button>())
        {
            byte index = byte.Parse(btn.name.Substring(1, 1));
            btn.onClick.AddListener(() =>
            {
                mIsClickEditArea = true;
                ChangeCurOp(EDIT_OP.EDIT_TILETYPE);
                blockTypeLayout.transform.parent.gameObject.SetActive(index == 1);
                mTypeIndex = index;
                UpdateCurOpTips("MapTileType " + ((MapTileType)mTypeIndex).ToString());
            });
        }

        foreach (Button btn in blockTypeLayout.GetComponentsInChildren <Button>())
        {
            byte index = byte.Parse(btn.name.Substring(1, 1));
            btn.onClick.AddListener(() =>
            {
                mIsClickEditArea = true;
                ChangeCurOp(EDIT_OP.EDIT_BLOCKTYPE);
                mBlockTypeIndex = index;
                UpdateCurOpTips("BlockType " + ((MapBlockType)mBlockTypeIndex).ToString());
            });
        }

        saveBtn.onClick.AddListener(() =>
        {
            mIsClickEditArea = true;
            GameFacade.GetProxy <MapProxy>().Export();
        });

        recToggle.onValueChanged.AddListener((bool isOn) =>
        {
            if (isOn)
            {
                recOp.text = curEdit.text;
            }
        });

        applyBtn.onClick.AddListener(BulkEdit);
    }
Beispiel #2
0
    void ModifyVOByOp(MapTileVO tile)
    {
        switch (curOp)
        {
        case EDIT_OP.EDIT_TEX:
            if (tile.mat == mTexIndex)
            {
                return;
            }
            tile.mat       = mTexIndex;
            tile.type      = MapTileType.Normal;
            tile.blockType = MapBlockType.None;
            break;

        case EDIT_OP.EDIT_HEIGHT:
            byte newHeight = 0;
            if (mHeightOp && tile.height > 0)
            {
                newHeight = (byte)(tile.height - 1);
            }
            else if (!mHeightOp && tile.height < 15)
            {
                newHeight = (byte)(tile.height + 1);
            }
            else
            {
                return;
            }
            if (!TestNewHeight(newHeight))
            {
                return;
            }
            newHeight = (byte)Mathf.Clamp(newHeight, 0, 15);
            if (newHeight == tile.height)
            {
                return;
            }
            tile.height = newHeight;
            break;

        case EDIT_OP.EDIT_AREA:
            if (tile.camp == mCampIndex)
            {
                return;
            }
            tile.camp = mCampIndex;
            break;

        case EDIT_OP.EDIT_LV:
            if (tile.level == mLvIndex)
            {
                return;
            }
            tile.level = mLvIndex;
            break;

        case EDIT_OP.EDIT_TILETYPE:
            MapTileType newType = (MapTileType)mTypeIndex;
            if (tile.type == newType)
            {
                return;
            }
            tile.type = newType;
            if (tile.type != MapTileType.Block)
            {
                tile.blockType = MapBlockType.None;
            }
            break;

        case EDIT_OP.EDIT_BLOCKTYPE:
            MapBlockType newBType = (MapBlockType)mBlockTypeIndex;
            if (tile.blockType == newBType)
            {
                return;
            }
            tile.mat       = 8;
            tile.blockType = newBType;
            tile.type      = MapTileType.Block;
            break;

        case EDIT_OP.EDIT_SPRLIST:
            List <int> sprs = new List <int>(4);
            for (int i = 0; i < 4; i++)
            {
                sprs.Add(sprLists[i].value);
            }
            Coord submap = tile.coord.GetSubmapCoord();
            if (!mBulkSubmaps.Contains(submap))
            {
                mapProxy.SeedSprList(submap, sprs);
                mBulkSubmaps.Add(submap);
            }
            break;
        }
    }