private void OnLoad(lib.Event e) { if (levelTxt.text == "") { EditorTip.Show("未输入关卡"); return; } LevelConfig level = LevelConfig.GetConfig(Convert.ToInt32(levelTxt.text)); if (level == null) { EditorTip.Show("没有对应的关卡!"); return; } //清除之前的颜色 List <GridVO> grids = EditorVO.Instance.piecesGrids; for (int i = 0; i < grids.Count; i++) { grids[i].color.value = 0; } grids = EditorVO.Instance.grids; for (int i = 0; i < grids.Count; i++) { grids[i].color.value = 0; } grids = EditorVO.Instance.otherGrids1; for (int i = 0; i < grids.Count; i++) { grids[i].color.value = 0; } for (int i = 0; i < level.pieces.Count; i++) { for (int n = 0; n < level.pieces[i].coords.Count; n++) { if (EditorVO.Instance.GetGrid(level.pieces[i].coords[n].x, level.pieces[i].coords[n].y).color.value != 0) { EditorTip.Show("关卡数据错误,有重叠!"); } EditorVO.Instance.GetGrid(level.pieces[i].coords[n].x, level.pieces[i].coords[n].y).color.value = i + 1; } } for (int i = 0; i < level.pieces2.Count; i++) { for (int n = 0; n < level.pieces2[i].coords.Count; n++) { if (EditorVO.Instance.GetGrid1(level.pieces2[i].coords[n].x, level.pieces2[i].coords[n].y).color.value != 0) { EditorTip.Show("关卡数据错误,多余片有重叠!"); } EditorVO.Instance.GetGrid1(level.pieces2[i].coords[n].x, level.pieces2[i].coords[n].y).color.value = level.pieces.Count + i + 1; } } EditorTip.Show("加载成功!"); new CreateLevelCommand(); DrawPieces(); }
/// <summary> /// 保存 /// </summary> /// <param name="e"></param> private void OnSave(lib.Event e) { if (levelTxt.text == "") { EditorTip.Show("未输入关卡"); return; } EditorTip.Show("保存中..."); new SaveLevelCommand(Convert.ToInt32(levelTxt.text)); EditorTip.Show("保存成功!"); DrawPieces(); }
private void OnClear(lib.Event e) { //清除之前的颜色 List <GridVO> grids = EditorVO.Instance.piecesGrids; for (int i = 0; i < grids.Count; i++) { grids[i].color.value = 0; } grids = EditorVO.Instance.grids; for (int i = 0; i < grids.Count; i++) { grids[i].color.value = 0; } grids = EditorVO.Instance.otherGrids1; for (int i = 0; i < grids.Count; i++) { grids[i].color.value = 0; } EditorTip.Show("已清除"); }
private void OnTip(Event e) { EditorTip.Show((string)e.Data); }
// Use this for initialization void Start() { new EditorMainThread(); new CheckThread(); ConfigDecode.Decode(); //删除重复的 piece 信息 for (int i = 0; i < PieceConfig.Configs.Count; i++) { for (int j = i + 1; j < PieceConfig.Configs.Count; j++) { if (PieceConfig.Configs[i].id == PieceConfig.Configs[j].id) { PieceConfig.Configs.RemoveAt(j); EditorTip.Show("重复的片信息 : " + PieceConfig.Configs[i].id); j--; } } } EditorVO.Instance.dispatcher.AddListener("UIsaveHandle", OnSave); EditorVO.Instance.dispatcher.AddListener("UIloadHandle", OnLoad); EditorVO.Instance.dispatcher.AddListener("UIclearHandle", OnClear); //colorDropDown.options = EditorVO.Instance.colors; //colorDropDown.value = EditorVO.Instance.color.value; //生成格子 List <GridVO> grids = EditorVO.Instance.grids; for (int i = 0; i < grids.Count; i++) { GameObject obj = ResourceManager.CreateImage("image/grid/gridBg"); Point2D position = HaxgonCoord <Point2D> .CoordToPosition(Point2D.Create(grids[i].x.value, grids[i].y.value), 0.4f); obj.transform.position = new Vector3((float)(position.x + offx), position.y + offy); (obj.AddComponent <GameGrid>()).vo = grids[i]; } grids = EditorVO.Instance.otherGrids1; for (int i = 0; i < grids.Count; i++) { GameObject obj = ResourceManager.CreateImage("image/grid/gridBg"); Point2D position = HaxgonCoord <Point2D> .CoordToPosition(Point2D.Create(grids[i].x.value, grids[i].y.value), 0.4f); obj.transform.position = new Vector3((float)(position.x + offx1), position.y + offy1); (obj.AddComponent <GameGrid>()).vo = grids[i]; } grids = EditorVO.Instance.piecesGrids; for (int i = 0; i < grids.Count; i++) { GameObject obj = ResourceManager.CreateImage("image/grid/gridBg"); obj.transform.localScale = new Vector3(0.5f, 0.5f); Point2D position = HaxgonCoord <Point2D> .CoordToPosition(Point2D.Create(grids[i].x.value, grids[i].y.value), 0.2f); obj.transform.position = new Vector3((float)(position.x + 2), position.y); (obj.AddComponent <GameGrid>()).vo = grids[i]; } for (int i = 0; i < LevelConfig.Configs.Count; i++) { for (int j = 0; j < LevelConfig.Configs[i].pieces.Count; j++) { if (LevelConfig.Configs[i].pieces[j] == null) { EditorTip.Show("关卡 " + LevelConfig.Configs[i].id + " 缺少片信息"); } } for (int j = 0; j < LevelConfig.Configs[i].pieces2.Count; j++) { if (LevelConfig.Configs[i].pieces2[j] == null) { EditorTip.Show("关卡 " + LevelConfig.Configs[i].id + " 缺少片信息"); } } } }