Exemple #1
0
        public static void OnGui(LevelMapArray config, MapEditor wind)
        {
            if (!string.IsNullOrEmpty(wind.selectedLevel) && !EditorTool.IsMatch(config.ConfigID, wind.selectedLevel))
            {
                return;
            }
            if (wind.selectedLevel_Type != 0 && wind.selectedLevel_Type != LevelMgr.GetInstance().GetLevelConfig(config.ConfigID).Config.LevelType)
            {
                return;
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label(config.Id.ToString(), GUILayout.Width(200));
            GUILayout.Label(string.Format("{0}", config.ConfigID), GUILayout.Width(250));
            GUILayout.Label(string.Format("{0} X {1}", config.MapWidth, config.MapHeight), GUILayout.Width(200));
            bool isEdit = GUILayout.Button("修改", GUILayout.Width(50));

            if (isEdit)
            {
                wind.curLevelId = config.Id;
                wind.Pagetype   = MapEditor.PageType.Editor;
            }
            bool isDelete = GUILayout.Button("删除", GUILayout.Width(50));

            if (isDelete)
            {
                m_deletegroup.Add(config);
            }
            GUILayout.EndHorizontal();
        }
Exemple #2
0
    static void AddConfig(MapEditor wind, uint id)
    {
        LevelMapArray config = new LevelMapArray();

        config.Id = id;
        wind.Level_Data.Configs.Add(config);
        wind.SaveEdit();
    }
Exemple #3
0
 public void DeleteConfig(LevelMapArray config)
 {
     if (Configs.Contains(config))
     {
         Configs.Remove(config);
     }
     else
     {
         UnityEngine.Debug.Log("试图删除一个不存在的关卡配置表");
     }
 }
Exemple #4
0
    private static void GenGrid(LevelMapArray config)
    {
        int total = config.MapWidth * config.MapHeight;

        list.Clear();
        Rect rec = new Rect(30f, 90f, CellSize, CellSize);;

        for (int i = 1; i <= total; i++)
        {
            list.Add(rec);
            if (i % config.MapWidth == 0)
            {
                rec.y += (CellSize + CellOffset);
                rec.x  = rect.x;
            }
            else
            {
                rec.x += (CellSize + CellOffset);
            }
        }
    }
Exemple #5
0
    public static void OnGui(MapEditor wind)
    {
        Init(wind);
        isDo = false;
        LevelMapArray config = wind.Level_Config;

        GUILayout.BeginHorizontal();
        if (isEdit)
        {
            isEdit = !GUILayout.Button("确认", GUILayout.Width(50));
        }
        else
        {
            isEdit = GUILayout.Button("编辑", GUILayout.Width(50));
        }
        if (isEdit)
        {
            int owidth  = config.MapWidth;
            int oheight = config.MapHeight;
            GUILayout.Label("宽度:", GUILayout.Width(50));
            string tempx = GUILayout.TextField(config.MapWidth.ToString(), GUILayout.Width(50));
            config.MapWidth = int.Parse(tempx);
            GUILayout.Space(10f);
            GUILayout.Label("高度:", GUILayout.Width(50));
            tempx            = GUILayout.TextField(config.MapHeight.ToString(), GUILayout.Width(50));
            config.MapHeight = int.Parse(tempx);
            config.FitArray(owidth, oheight);

            //string tempxx = config.ConfigID.ToString();
            GUILayout.Label("地图ID:", GUILayout.Width(100));
            tempx = GUILayout.TextField(config.Id.ToString(), GUILayout.Width(50));
            //if (GUILayout.Button("确认", GUILayout.Width(50)))
            uint temp = uint.Parse(tempx);
            wind.curLevelId = temp;
            config.Id       = temp;

            tempx = config.ConfigID.ToString();
            GUILayout.Label("对应配置表ID:", GUILayout.Width(100));
            tempx           = GUILayout.TextField(tempx, GUILayout.Width(50));
            config.ConfigID = uint.Parse(tempx);

            config.FitArray(owidth, oheight);
            GUILayout.Label("格子大小:", GUILayout.Width(50));
            tempx    = GUILayout.TextField(CellSize.ToString(), GUILayout.Width(50));
            CellSize = int.Parse(tempx);
            config.FitArray(owidth, oheight);
            GUILayout.Label("间距:", GUILayout.Width(50));
            tempx      = GUILayout.TextField(CellOffset.ToString(), GUILayout.Width(50));
            CellOffset = int.Parse(tempx);
        }
        else
        {
            GUILayout.Label("宽度:", GUILayout.Width(50));
            GUILayout.Label("" + config.MapWidth, GUILayout.Width(50));
            GUILayout.Space(10f);
            GUILayout.Label("高度:", GUILayout.Width(50));
            GUILayout.Label("" + config.MapHeight, GUILayout.Width(50));
        }



        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("生成"))
        {
            GenGrid(config);
        }
        if (GUILayout.Button("读取底图"))
        {
            MapEditor.BgTexture = EditorTool.LoadTexture();
        }
        if (GUILayout.Button("保存"))
        {
            wind.SaveEdit();
        }
        if (GUILayout.Button("返回总览"))
        {
            IsInit        = false;
            wind.Pagetype = MapEditor.PageType.Total;
            return;
        }
        if (!isShowbg && GUILayout.Button("显示底图"))
        {
            isShowbg = true;
        }
        if (isShowbg && GUILayout.Button("显示网格"))
        {
            isShowbg = false;
        }
        GUILayout.EndHorizontal();
        ShowBg(wind);
        if (!isEdit && !isShowbg)
        {
            ShowGrid(wind);
        }
        if (isDo)
        {
            //wind.SaveEdit();
        }
    }