public void AddGotland(int landID) { bool sameLand = false; for (int i = 0; i < currentUser.gotLandList.Count; i++) { if (currentUser.gotLandList[i].id == landID) { sameLand = true; if (currentUser.gotLandList[i].gotPuzzleList.Count != PuzzleManager.instance.puzzles[landID].Length) { currentUser.gotLandList[i].gotPuzzleList = new List <string>(); currentUser.gotLandList[i].gotPuzzleList = AddGotPuzzles(landID); } break; } } if (sameLand == false) { #region tempLand_DefaultSetting SaveData.GotLand tempLand = new SaveData.GotLand(); tempLand.id = landID; tempLand.weather = 0; tempLand.gotPuzzleList = AddGotPuzzles(landID); #endregion currentUser.gotLandList.Add(tempLand); } }
public void OnGoal() { PuzzleManager.instance.viewCon.puzzleView.transform.GetChild(1).GetComponent <PuzzleButton>().EndButtonChecker_Puzzle(); //ControllerA - 버튼 체크 코루틴 종료 PuzzleManager.instance.viewCon.views[3].GetComponent <PopupViewController>().clearPop.SetActive(true); //클리어 팝업 뜸. #region CurrentWeather if (PuzzleManager.instance.currentPuzzle.type == "S") { int weather = PuzzleInfo.FindPuzzleEffect.FindWeatherNum(PuzzleManager.instance.currentPuzzle.id); UserManager.Instance.SetWeather(LandManager.instance.currentLand.id, weather); //현재 weather 수정. } else { } //Normal Btn은 MethodList에서 찾기. #endregion #region CurrentPuzzle GameObject puzzleIcon = PuzzleManager.instance.viewCon.views[3].transform.GetChild(0).GetChild(0).GetChild(0).gameObject; GameObject puzzleName = PuzzleManager.instance.viewCon.views[3].transform.GetChild(0).GetChild(0).GetChild(1).gameObject; puzzleIcon.GetComponent <Image>().sprite = PuzzleManager.instance.currentSprite; //현재 퍼즐 스프라이트 puzzleName.transform.GetChild(0).GetComponent <Text>().text = PuzzleManager.instance.currentPuzzle.name; //현재 퍼즐 이름 #endregion Debug.Log("CurrentLand : " + LandManager.instance.currentLand.id); #region ClearPuzzle In GotLandList if (!UserManager.Instance.ClearPuzzleCheck(PuzzleManager.instance.currentPuzzle.id)) { SaveData.GotLand land = UserManager.Instance.GetCurrentInGotLandList(LandManager.instance.currentLand.id); land.clearPuzzleList.Add(PuzzleManager.instance.currentPuzzle.id); if (land.clearPuzzleList.Count == land.gotPuzzleList.Count) { UserManager.Instance.currentUser.ClearLandCount++; } //Debug.Log(PuzzleManager.instance.currentPuzzle.id); }//현재 Land에서 ClearPuzzle이 없다면 해당 ClearList에 퍼즐이름 추가. #endregion #region Stars if (PuzzleManager.instance.currentPuzzle.type == "N") { int unitCnt = LandManager.instance.GetComponent <UnitManager>().UnitCountCheck(PuzzleManager.instance.currentPuzzle.id); int maxCnt = PuzzleManager.instance.GetPuzzleMaxCount(PuzzleManager.instance.currentPuzzle.id); if (unitCnt < maxCnt) { UserManager.Instance.currentUser.star += 1; } } else { if (!UserManager.Instance.ClearPuzzleCheck(PuzzleManager.instance.currentPuzzle.id)) { UserManager.Instance.currentUser.star += 1; } } #endregion UserManager.Instance.currentUser.lastLand = LandManager.instance.currentLand.id; MainDataBase.instance.OnSaveAdmin(true); }
public SaveData.GotLand GetCurrentInGotLandList(int landID) { // Debug.Log(landID+", "+currentUser.gotLandList.Count); SaveData.GotLand current = currentUser.gotLandList[0]; for (int i = 0; i < currentUser.gotLandList.Count; i++) { if (landID == currentUser.gotLandList[i].id) { current = currentUser.gotLandList[i]; } //else { Debug.Log("No Found This ID in GotLandList : " + landID + ", "+ currentUser.gotLandList[i].id); } } return(current); }
public bool ClearPuzzleCheck(string puzzleID) { bool check = false; for (int i = 0; i < currentUser.gotLandList.Count; i++) { SaveData.GotLand land = currentUser.gotLandList[i]; check = HarimTool.EditValue.EditSomething.ContainAnB(puzzleID, land.clearPuzzleList); if (check == true) { return(true); } } return(check); }
public void OnLoadAdmin() { LoadLocal(); bool firstTime = true; Debug.Log("default ID : " + UserManager.Instance.currentUser.id); FirebaseDatabase.DefaultInstance.GetReference("Users").Child(UserManager.Instance.currentUser.id).GetValueAsync().ContinueWith ( task => { if (!task.IsCompleted) { Debug.Log("OnLoadAdmin_Error"); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot.ChildrenCount > 0) { if (Convert.ToInt32(snapshot.Child("playTime").GetValue(true)) > UserManager.Instance.currentUser.PlayTime) { #region Admin UserManager.Instance.currentUser.name = snapshot.Child("username").GetValue(true).ToString(); //snapShot에서 name 가져오기. EventManager.instance.NickNameCheckedFunc(true); UserManager.Instance.currentUser.gem = Convert.ToInt32(snapshot.Child("gem").GetValue(true)); UserManager.Instance.currentUser.star = Convert.ToInt32(snapshot.Child("star").GetValue(true)); UserManager.Instance.currentUser.ClearLandCount = Convert.ToInt32(snapshot.Child("clrLndCnt").GetValue(true)); UserManager.Instance.currentUser.PlayTime = Convert.ToInt32(snapshot.Child("playTime").GetValue(true)); Debug.Log("playTime : " + UserManager.Instance.currentUser.PlayTime); UserManager.Instance.currentUser.lastLand = Convert.ToInt32(snapshot.Child("lastLand").GetValue(true)); #endregion #region Land if (UserManager.Instance.currentUser.gotLandList.Count > 0) { UserManager.Instance.currentUser.gotLandList.Clear(); } for (int i = 0; i < snapshot.Child("gotLands").ChildrenCount; i++) { string i_ = i.ToString(); SaveData.GotLand tempGotLand = new SaveData.GotLand(); tempGotLand.id = Convert.ToInt32(snapshot.Child("gotLands").Child(i_).Child("id").GetValue(true)); tempGotLand.weather = Convert.ToInt32(snapshot.Child("gotLands").Child(i_).Child("weather").GetValue(true)); for (int j = 0; j < snapshot.Child("gotLands").Child(i_).Child("clrPuzzles").ChildrenCount; j++) { string j_ = j.ToString(); tempGotLand.clearPuzzleList.Add(snapshot.Child("gotLands").Child(i_).Child("clrPuzzles").Child(j_).GetValue(true).ToString()); } for (int j = 0; j < snapshot.Child("gotLands").Child(i_).Child("units").ChildrenCount; j++) { string j_ = j.ToString(); tempGotLand.unitList.Add(snapshot.Child("gotLands").Child(i_).Child("units").Child(j_).GetValue(true).ToString()); } UserManager.Instance.currentUser.gotLandList.Add(tempGotLand); } #endregion } } if (UserManager.Instance.currentUser.PlayTime > 0) { firstTime = false; } Debug.Log(UserManager.Instance.currentUser.name + ", firstTime : " + firstTime); loadAdmin = true; } }); }