void OnToggleValueChange(bool selected, LevelMapObject mapObj) { if (selected) { //ChangeUIDisplay(0); if (mapObj) { currentMapObject = mapObj; selectScene = mapObj.level; selectLevel = -1; if (GameGlobalValue.s_CurrentGameType == GameType.Endless) { //获得当前的排名 UpdateRankDisplay(mapObj); } else if (GameGlobalValue.s_CurrentGameType == GameType.Story) { UpdateLevelDisplay(mapObj); } } } else { selectScene = -1; //playButton.enabled = false; } }
/// <summary> /// 更新排行版显示 /// </summary> /// <param name="mapObj"></param> void UpdateRankDisplay(LevelMapObject mapObj) { if (currentMapObject == null) { return; } //显示玩家的排名 // LevelScore Player.CurrentPlayer. UpdatePlayerLevelRank(mapObj.level); // rankZone.rect.Set(rankZone.rect.x, rankZone.rect.y, rankZone.rect.width, 1000f); //rankZone.sizeDelta = new Vector2(rankZone.sizeDelta.x,1000f)x; UpdateLevelLeardBoard(mapObj.LeardBoardID); }
/// <summary> /// 更新关卡显示 /// </summary> /// <param name="mapObj"></param> void UpdateLevelDisplay(LevelMapObject mapObj) { if (currentMapObject == null) { return; } if (levelItemTemplate == null) { Debug.LogError("Miss Level Item Template!"); } levelZone.DetachChildren(); var gridGroup = levelZone.GetComponent <GridLayoutGroup>(); if (gridGroup != null) { int col = Mathf.FloorToInt((levelZone.rect.width - gridGroup.padding.left - gridGroup.padding.right + gridGroup.spacing.x) / (gridGroup.cellSize.x + gridGroup.spacing.x)); int row = Mathf.CeilToInt((float)currentMapObject.levelCount / col); //levelZone.rect.Set(levelZone.rect.x,levelZone.rect.y,levelZone.rect.width, row * gridGroup.cellSize.y + gridGroup.padding.top); levelZone.sizeDelta = new Vector2(levelZone.sizeDelta.x, row * gridGroup.cellSize.y + gridGroup.padding.top + (row - 1) * gridGroup.spacing.y); for (int i = 1; i < currentMapObject.levelCount + 1; i++) { var levelItem = Instantiate(levelItemTemplate) as GameObject; //levelItem.GetComponent<RectTransform>().SetParent(levelZone); levelItem.transform.SetParent(levelZone); levelItem.transform.localScale = new Vector3(1f, 1f, 1f); CommonUtils.SetChildText(levelItem.GetComponent <RectTransform>(), "Text", i.ToString()); var button = levelItem.GetComponent <Button>(); if (button) { bool isUnlocked = Player.CurrentPlayer.IsLevelUnlocked(currentMapObject.level, i); button.interactable = isUnlocked; if (isUnlocked) { button.onClick.AddListener(() => { OnLevelItemClicked(button); }); } } } } }
/// <summary> /// 更新排行版显示 /// </summary> /// <param name="mapObj"></param> void UpdateRankDisplay(LevelMapObject mapObj) { if (currentMapObject == null) return; //显示玩家的排名 // LevelScore Player.CurrentPlayer. UpdatePlayerLevelRank(mapObj.level); // rankZone.rect.Set(rankZone.rect.x, rankZone.rect.y, rankZone.rect.width, 1000f); //rankZone.sizeDelta = new Vector2(rankZone.sizeDelta.x,1000f)x; UpdateLevelLeardBoard(mapObj.LeardBoardID); }
/// <summary> /// 更新关卡显示 /// </summary> /// <param name="mapObj"></param> void UpdateLevelDisplay(LevelMapObject mapObj) { if (currentMapObject == null) return; if (levelItemTemplate == null) Debug.LogError("Miss Level Item Template!"); levelZone.DetachChildren(); var gridGroup = levelZone.GetComponent<GridLayoutGroup>(); if(gridGroup != null) { int col = Mathf.FloorToInt((levelZone.rect.width - gridGroup.padding.left - gridGroup.padding.right + gridGroup.spacing.x) / (gridGroup.cellSize.x + gridGroup.spacing.x)); int row = Mathf.CeilToInt((float)currentMapObject.levelCount / col); //levelZone.rect.Set(levelZone.rect.x,levelZone.rect.y,levelZone.rect.width, row * gridGroup.cellSize.y + gridGroup.padding.top); levelZone.sizeDelta = new Vector2(levelZone.sizeDelta.x, row * gridGroup.cellSize.y + gridGroup.padding.top +(row -1) * gridGroup.spacing.y); for(int i = 1;i < currentMapObject.levelCount + 1;i++) { var levelItem = Instantiate(levelItemTemplate) as GameObject; //levelItem.GetComponent<RectTransform>().SetParent(levelZone); levelItem.transform.SetParent(levelZone); levelItem.transform.localScale = new Vector3(1f, 1f, 1f); CommonUtils.SetChildText(levelItem.GetComponent<RectTransform>(), "Text", i.ToString()); var button = levelItem.GetComponent<Button>(); if(button) { bool isUnlocked = Player.CurrentPlayer.IsLevelUnlocked(currentMapObject.level, i); button.interactable = isUnlocked; if(isUnlocked) { button.onClick.AddListener(()=>{ OnLevelItemClicked(button); }); } } } } }
void OnToggleValueChange(bool selected, LevelMapObject mapObj) { if (selected) { //ChangeUIDisplay(0); if (mapObj) { currentMapObject = mapObj; selectScene = mapObj.level; selectLevel = -1; if(GameGlobalValue.s_CurrentGameType == GameType.Endless) { //获得当前的排名 UpdateRankDisplay(mapObj); } else if (GameGlobalValue.s_CurrentGameType == GameType.Story) { UpdateLevelDisplay(mapObj); } } } else { selectScene = -1; //playButton.enabled = false; } }