Beispiel #1
0
 private void OnDeleteBuilding(HexBuilding building)
 {
     if (building.hex)
     {
         building.hex.data.buildingType = MapCellData.BuildingType.Floor;
         building.hex.data.buildingRes  = null;
         building.hex.data.eventType    = MapCellData.EventType.None;
     }
 }
Beispiel #2
0
 void ChangeGameObjectType(GameObject [] gos)
 {
     if (currentSelect != null)
     {
         foreach (var k in gos)
         {
             Hex      cell = k.GetComponent <Hex>();
             HexBrush hb   = currentSelect.GetComponent <HexBrush>();
             if (cell != null && cell.data.res != AssetDatabase.GetAssetPath(currentSelect)) //选中是地表
             {
                 if (hb.data.buildingType == MapCellData.BuildingType.Floor)                 //画刷是地面
                 {
                     ChangeGameObjectToBrushTypeWithUndo(cell, hb);
                 }
                 else
                 {
                     AddBuildToHexWithUndo(cell, hb);//画刷是建筑
                 }
             }
             if (k)
             {
                 HexBuilding building = k.GetComponent <HexBuilding>();
                 if (building && building.hex)                                      //当前选中的是建筑
                 {
                     if (hb.data.buildingType == MapCellData.BuildingType.Building) //画刷是建筑
                     {
                         AddBuildToHexWithUndo(building.hex, hb);
                     }
                     else if (hb.data.buildingType == MapCellData.BuildingType.Floor)//画刷是Floor,那就替换地面了
                     {
                         ChangeGameObjectToBrushTypeWithUndo(building.hex, hb);
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
    void OnGUIInfo(Rect size)
    {
        GUILayout.BeginArea(size);
        Info = EditorGUILayout.BeginFoldoutHeaderGroup(Info, "Info");
        if (Info)
        {
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            if (Selection.gameObjects != null)
            {
                foreach (var k in Selection.gameObjects)
                {
                    Hex cell = k.gameObject.GetComponent <Hex>();
                    if (cell)
                    {
                        MapCellTool.Draw(cell);
                    }

                    HexBuilding build = k.gameObject.GetComponent <HexBuilding>();
                    if (build)
                    {
                        if (build.hex)
                        {
                            GUI.color = Color.red;
                            EditorGUILayout.LabelField("选中了建筑");
                            GUI.color = Color.white;
                            MapCellTool.Draw(build.hex);
                        }
                    }
                }
            }
            EditorGUILayout.EndScrollView();
        }
        EditorGUILayout.EndFoldoutHeaderGroup();

        GUILayout.EndArea();
    }