Пример #1
0
 public void SaveData(Map map)
 {
     MapName       = map.MapName;
     UnitLength    = map.UnitLength;
     OriginPoint   = map.OriginPoint;
     UnitCounts    = map.UnitCounts;
     MapContentSet = map.MapContentSet;
     ContentInMap  = (GameObject[])map.ContentInMap.Clone();
 }
Пример #2
0
 public void Init(MapData mapdata)
 {
     MapName                   = mapdata.MapName;
     UnitLength                = mapdata.UnitLength;
     UnitCounts                = mapdata.UnitCounts;
     OriginPoint               = mapdata.OriginPoint;
     MapContentSet             = mapdata.MapContentSet;
     ContentInMap              = mapdata.ContentInMap;
     GameController.CurrentMap = this;
     CreateMapByIndex();
 }
Пример #3
0
 void OnEnable()
 {
     t = target as Map;
     GameController.CurrentMap = t;
     UnitLength    = serializedObject.FindProperty("UnitLength");
     UnitCountX    = serializedObject.FindProperty("UnitCounts.x");
     UnitCountY    = serializedObject.FindProperty("UnitCounts.y");
     MapContentSet = serializedObject.FindProperty("MapContentSet");
     mapContentSet = ((MapContentSet)MapContentSet.objectReferenceValue);
     MapName       = serializedObject.FindProperty("MapName");
     Refresh();
 }
Пример #4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        t = target as Map;
        EditorGUILayout.LabelField("地图网格参数");
        EditorGUI.indentLevel++;
        EditorGUILayout.PropertyField(UnitLength);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(UnitCountX);
        EditorGUILayout.PropertyField(UnitCountY);
        EditorGUILayout.EndHorizontal();
        EditorGUI.indentLevel--;

        EditorGUILayout.LabelField("地图内容参数");
        EditorGUI.indentLevel++;
        MapContentSet tempGO = (MapContentSet)MapContentSet.objectReferenceValue;

        if (GUILayout.Button("新建") == true)
        {
            t.ContentInMap = t.NewMap(UnitCountX.intValue, UnitCountY.intValue);
            Refresh();
        }
        if (t.ContentInMap == null)
        {
            return;
        }
        //检查变更的地图块组是否具有相应的组件
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(MapContentSet);
        if (EditorGUI.EndChangeCheck())
        {
            /*
             * MapContentSet ms = (MapContentSet)MapContentSet.objectReferenceValue;
             * if (ms==null) {
             *      Debug.LogError ("不合法的地图块组");
             *      MapContentSet.objectReferenceValue = tempGO;
             * }
             */
        }
        serializedObject.ApplyModifiedProperties();
        if (t.MapContentSet == null)
        {
            return;
        }
        EditorGUI.indentLevel--;

        EditorGUILayout.LabelField("层数");
        EditorGUI.indentLevel++;
        EditorGUI.BeginChangeCheck();
        selectedLayer = (Settings.Layers)EditorGUILayout.EnumPopup(selectedLayer);
        if (EditorGUI.EndChangeCheck())
        {
            Refresh();
        }
        EditorGUI.indentLevel--;

        EditorGUI.BeginChangeCheck();
        showMap = GUILayout.Toggle(showMap, "显示地图");
        if (EditorGUI.EndChangeCheck())
        {
            ClearMapUnits();
            if (showMap == false)
            {
                ClearMapUnits();
            }
            else
            {
                if (showAllLayers == false)
                {
                    ShowUnitsInLayer(selectedLayer);
                }
                else
                {
                    for (int i = 0; i < Settings.MaxLayers; i++)
                    {
                        ShowUnitsInLayer((Settings.Layers)Enum.GetValues(typeof(Settings.Layers)).GetValue(i));
                    }
                }
            }
        }
        EditorGUI.BeginChangeCheck();
        showAllLayers = GUILayout.Toggle(showAllLayers, "显示所有层");
        if (EditorGUI.EndChangeCheck())
        {
            ClearMapUnits();
            if (showMap == true)
            {
                if (showAllLayers == true)
                {
                    for (int i = 0; i < Settings.MaxLayers; i++)
                    {
                        ShowUnitsInLayer((Settings.Layers)Enum.GetValues(typeof(Settings.Layers)).GetValue(i));
                    }
                }
                else
                {
                    ShowUnitsInLayer(selectedLayer);
                }
            }
        }

        EditorGUI.indentLevel++;

        EditorGUI.indentLevel--;
        EditorGUILayout.LabelField("按S放置,按D删除,按住X以矩形放置,按住C以矩形删除");
        Texture[] images = ((MapContentSet)(MapContentSet.objectReferenceValue)).GetSetImages();
        this.selectedSet = GUILayout.SelectionGrid(this.selectedSet, images, Settings.EditorUnitShowMaxAmount);
        EditorGUI.indentLevel++;
        if (GUILayout.Button("清空") == true)
        {
            t.Clear();
            Refresh();
        }
        EditorGUI.indentLevel--;
        EditorGUILayout.PropertyField(MapName);
        serializedObject.ApplyModifiedProperties();
        if (GUILayout.Button("保存"))
        {
            SaveMapData(t.MapName);
        }
        serializedObject.ApplyModifiedProperties();
    }