private void ResetInfo() { trAllRewards.gameObject.SetActive(false); missSelected = null; _stageSelect = -1; _mapSelect = -1; txtLevel.text = ""; txtMission1.text = ""; txtMission2.text = ""; txtMission3.text = ""; levelControll = null; for (int i = 0; i < imgMission.Length; i++) { imgMission[i].sprite = imgStarNotYetUnlock; } }
public void SwitchColor(int _mapIndex) { for (int j = 0; j < gStages[MainMenuController.Instance.stageSelected - 1].transform.childCount; j++) { MapLevelControll levelControll = gStages[MainMenuController.Instance.stageSelected - 1].transform.GetChild(j).GetComponent <MapLevelControll>(); if (levelControll.canPlay) { if (levelControll.mapIndex != _mapIndex) { levelControll.imgMap.sprite = imgMapUnlock; levelControll.transform.localScale = levelControll.vCurScale; levelControll.uiShiny.enabled = false; } else { levelControll.transform.localScale = levelControll.vDesScale; levelControll.uiShiny.enabled = true; } } } }
private void RefreshMap() { for (int j = 0; j < gStages[MainMenuController.Instance.stageSelected - 1].transform.childCount; j++) { MapLevelControll levelControll = gStages[MainMenuController.Instance.stageSelected - 1].transform.GetChild(j).GetComponent <MapLevelControll>(); MapLevel mapLevel = DataUtils.GetMapByIndex(levelControll.stageIndex, levelControll.mapIndex); if (mapLevel.hasComplete || j == 0) { if (j < gStages[MainMenuController.Instance.stageSelected - 1].transform.childCount - 1 || j == 0) { gStages[MainMenuController.Instance.stageSelected - 1].transform.GetChild(j + 1).GetComponent <MapLevelControll>().canPlay = true; levelControll.canPlay = true; } } else { levelControll.canPlay = false; gStages[MainMenuController.Instance.stageSelected - 1].transform.GetChild(j).GetComponent <MapLevelControll>().canPlay = false; } levelControll.RefreshMap(); } }
private void FetchStageData() { ///Check if StageData not yet init if (!DataUtils.StageHasInit()) { #region Stage Data not yet init List <DataStage> lstStages = new List <DataStage>(); for (int i = 0; i < gStages.Length; i++) { DataStage dataStage = new DataStage(); dataStage.stageName = gStages[i].name; if (i == 0) { dataStage.stageHasUnlock = true; } else { dataStage.stageHasUnlock = false; } for (int j = 0; j < gStages[i].transform.childCount; j++) { MapLevelControll levelControll = gStages[i].transform.GetChild(j).GetComponent <MapLevelControll>(); MapLevel mapLevel = new MapLevel(); mapLevel.levelID = levelControll.stageIndex + "_" + levelControll.mapIndex; if (i == 0 && j == 0) { levelControll.canPlay = true; } #region Add Mission to MapLevel Mission mission_ = DataController.instance.allMission[i].missionData[j]; AddMissionToMap(mapLevel, mission_.mission1name); AddMissionToMap(mapLevel, mission_.mission2name); AddMissionToMap(mapLevel, mission_.mission3name); #endregion #region Add Rewards to MapLevel if (mapLevel.rewards == null) { mapLevel.rewards = new List <LVReward>(); } AddRewardsToMap(i + 1, j + 1, mapLevel.rewards); #endregion #region Add Map Level to Stage if (dataStage.levels == null) { dataStage.levels = new List <MapLevel>(); } if (!dataStage.levels.Contains(mapLevel)) { dataStage.levels.Add(mapLevel); } #endregion levelControll.SwitchColor(); levelControll.CheckMapStars(); levelControll.gameObject.SetActive(true); } if (!lstStages.Contains(dataStage)) { lstStages.Add(dataStage); } } string jSave = JsonMapper.ToJson(lstStages); DataUtils.SaveStage(jSave); DataUtils.FillAllStage(); #endregion } else///Check if StageData has init { for (int j = 0; j < gStages[MainMenuController.Instance.stageSelected - 1].transform.childCount; j++) { MapLevelControll levelControll = gStages[MainMenuController.Instance.stageSelected - 1].transform.GetChild(j).GetComponent <MapLevelControll>(); MapLevel mapLevel = DataUtils.GetMapByIndex(levelControll.stageIndex, levelControll.mapIndex); if (mapLevel.hasComplete) { if (j < gStages[MainMenuController.Instance.stageSelected - 1].transform.childCount - 1) { gStages[MainMenuController.Instance.stageSelected - 1].transform.GetChild(j + 1).GetComponent <MapLevelControll>().canPlay = true; levelControll.canPlay = true; } if (levelControll.mapIndex == 7 && !DataUtils.StageHardHasInit()) { // DataUtils.UnlockHardMode(); DataUtils.UnlockHardMode(levelControll.stageIndex); } } else { gStages[MainMenuController.Instance.stageSelected - 1].transform.GetChild(0).GetComponent <MapLevelControll>().canPlay = true; } levelControll.gameObject.SetActive(true); } //if (StageHardHasInit()) //DataUtils.FillAllStageHard(); } }