private object GetMSPData(string sheetName, KeyValuePair <string, Dictionary <string, object> > Keyvalue) { object result = null; if (sheetName.Equals("Shop") == true) { result = new MSP_Shop(Keyvalue); } if (sheetName.Equals("Game_Base") == true) { result = new MSP_Game_Base(Keyvalue); } if (sheetName.Equals("Localization") == true) { result = new MSP_Localization(Keyvalue); } if (sheetName.Equals("Item_ETC") == true) { result = new MSP_Item_ETC(Keyvalue); } if (sheetName.Equals("Game_Stage") == true) { result = new MSP_Game_Stage(Keyvalue); } return(result); }
public void SetMap(MSP_Game_Stage stage) { this.stage = stage; if (Initalize == true) { LoadMap(stage); } }
private void Btn_CreateMap_Click(object sender, EventArgs e) { bool b_Check_Stage = false; bool b_Check_Scores = false; bool b_Check_ClearCount = false; try { var Stage = Convert.ToInt32(Text_Box_Stage.Text); b_Check_Stage = true; var ClearCount = Convert.ToInt32(Text_Box_ClearCount.Text); b_Check_ClearCount = true; List <int> scores = new List <int>(); var Text_score = Text_Box_Score.Text.Trim().Split(','); foreach (var score in Text_score) { scores.Add(Convert.ToInt32(score.Trim())); } if (scores.Count < 3) { MessageBox.Show("스코어 개수가 부족 합니다."); return; } b_Check_Scores = scores.Count > 0; if (MapGrid.GetCellCount(DataGridViewElementStates.Visible) <= 0) { MessageBox.Show("맵을 만들어 주세요"); return; } if (checkedListBox1.Items.Count <= 0) { MessageBox.Show("클리어 조건을 설정해 주세요"); return; } MSP_Game_Stage stage = new MSP_Game_Stage(); stage.DataKey = $"Map_Stage_{Stage}"; stage.Scores = scores; stage.GameType_Name = new List <string>(); stage.GameType_Count = new List <int>(); foreach (var Condition in winList) { stage.GameType_Name.Add(Condition.Key); stage.GameType_Count.Add(Condition.Value.Item1); } stage.Width = Convert.ToInt32(TextBox_Width.Text); stage.Height = Convert.ToInt32(TextBox_Height.Text); stage.Map = new List <int>(); for (int y = 0; y < MapGrid.Rows.Count; y++) { for (int x = 0; x < MapGrid.Rows[y].Cells.Count; x++) { int type = -1; try { type = Convert.ToInt32(MapGrid.Rows[y].Cells[x].Value); } catch { MessageBox.Show($"맵 정보가 잘못 됬습니다, : {x} , {y}"); return; } stage.Map.Add(type); } } SaveFile(stage); } catch { if (b_Check_Stage == false) { MessageBox.Show("스테이지를 설정 해 주세요"); return; } if (b_Check_Scores == false) { MessageBox.Show("스코어를 설정 해 주세요"); return; } if (b_Check_ClearCount == false) { MessageBox.Show("클리어 까지 남은 턴을 설정 해 주세요"); return; } return; } }
public void LoadMap(MSP_Game_Stage stage) { selectedBlock = null; blocks.Clear(); map = new int[stage.Width, stage.Height]; int index = 0; foreach (var _map in stage.Map) { int h = index / stage.Width; int w = index - (stage.Width * h); map[w, h] = _map; index++; } Turn.text = stage.ClearCount.ToString(); Changer.text = Core.Instance().userDataMangaer.GetData_int("Item_ETC_Changer").ToString(); Hammer.text = Core.Instance().userDataMangaer.GetData_int("Item_ETC_Hammer").ToString(); #region BG 맵 생성 for (int y = 0; y < stage.Height; y++) { for (int x = 0; x < stage.Width; x++) { var obj = GetorAdd(BackGroundTile, $"BG_Tile_{x}_{y}", InGameBackGroundRect); obj.gameObject.GetOrAddComponent <RectTransform>().sizeDelta = new Vector2(64, 64); obj.gameObject.GetOrAddComponent <RectTransform>().anchoredPosition = new Vector3(64 * (x - stage.Width / 2), 64 * (stage.Height / 2 - y)); //obj.gameObject.GetComponent<InGame_Block>().SetNormalBlock(x, y); //blocks.Add(obj.gameObject.GetComponent<InGame_Block>()); } } #endregion #region 인게임 타일 생성 for (int y = 0; y < stage.Height; y++) { for (int x = 0; x < stage.Width; x++) { var obj = GetorAdd(Origin_Tile, $"Tile_{new Vector2(64 * (x - stage.Width / 2), 64 * (stage.Height / 2 - y))}", InGameRect); obj.gameObject.GetOrAddComponent <RectTransform>().sizeDelta = new Vector2(64, 64); obj.gameObject.GetOrAddComponent <RectTransform>().anchoredPosition = new Vector3(64 * (x - stage.Width / 2), 64 * (stage.Height / 2 - y)); obj.gameObject.GetComponent <InGame_Block>().SetNormalBlock(); obj.name = $"Tile_{obj.GetComponent<InGame_Block>().GetPos()}"; blocks.Add(obj.gameObject.GetComponent <InGame_Block>()); } } #endregion CheckMap(); }