private void Refresh() { textTitle.text = _title; TransformUtil.ClearChildren(rewardRoot, true); GameResData resData; int totalMoney = 0; int totalAccountExp = 0; for (int i = 0, count = _dataList.Count; i < count; i++) { resData = _dataList[i]; if (resData.type != BaseResType.Account_Exp && resData.type != BaseResType.Hero_Exp && resData.type != BaseResType.Gold) { CommonRewardIcon icon = CommonRewardIcon.Create(rewardRoot); icon.SetGameResData(resData); } if (resData.type == BaseResType.Gold) { totalMoney += resData.count; } else if (resData.type == BaseResType.Account_Exp) { totalAccountExp += resData.count; } } if (rewardRoot.childCount == 0) { gameObject.GetComponent <LayoutElement>().preferredHeight = gameObject.GetComponent <LayoutElement>().preferredHeight - 100; } //exp textAccountLv.text = _accountLevel.ToString(); // textAccountName.text = GameProxy.instance.PlayerInfo.name; textAccountName.text = GameProxy.instance.AccountName; sliderAccountBar.transform.localPosition = textAccountName.transform.localPosition + new Vector3(textAccountName.preferredWidth + 21, 0, 0); textAccountAdd.text = string.Format("+{0}%", (int)_addExpPercent); AccountExpData expData = AccountExpData.GetAccountExpDataByLv(_accountLevel); if (expData == null) { sliderAccountBar.value = 0; } else { sliderAccountBar.value = (_accountExp + 0.0f) / expData.exp; } //money textMoney.text = totalMoney.ToString(); int vip = VIPProxy.instance.VIPLevel; if (vip > 0) { textMoneyVipTip.text = string.Format("(vip{0} +{1}%)", vip, VIPProxy.instance.VIPData.dungeonExtraGoldAmount); } else { textMoneyVipTip.text = string.Empty; } }
private void InitAccountBar() { int level = GameProxy.instance.AccountLevel; int exp = GameProxy.instance.AccountExp; int oldExp = 0; _nextAccountLevel = level; //协议已经过来,账号经验已升级,所以需要计算old exp AccountExpData accountExpData = AccountExpData.GetAccountExpDataByLv(level - 1); int expTotal = 0; if (accountExpData != null) { expTotal = accountExpData.expTotal; } int oldExpTotal = expTotal + exp - _addAcountExp; AccountExpData oldData = AccountExpData.GetAccountExpDataByExp(oldExpTotal); bool isMax = oldData == null; if (isMax) { exp_profession_bar.ChangeValue(0); _curAccountLevel = _oldAccountLevel = level; } else { _curAccountLevel = _oldAccountLevel = oldData.lv; oldExp = oldExpTotal - (oldData.expTotal - oldData.exp); float percent = (oldExp + 0.0f) / oldData.exp; exp_profession_bar.ChangeValue(percent); } }
public static float GetAccountExpPercentToNextLevel(int accountLevel) { float accountExpPercentToNextLevel = 0; AccountExpData data = AccountExpData.GetAccountExpDataByLv(accountLevel); if (data != null && data.exp > 0) { accountExpPercentToNextLevel = (float)GameProxy.instance.AccountExp / AccountExpData.GetAccountExpDataByLv(accountLevel).exp; } return(accountExpPercentToNextLevel); }
private void UpdateAccountBar() { float duringTime = 1f; if (_curAccountLevel == _nextAccountLevel) { AccountExpData data = AccountExpData.GetAccountExpDataByLv(_curAccountLevel); bool isMax = data == null; float percent = 0; if (!isMax) { percent = (GameProxy.instance.AccountExp + 0.0f) / data.exp; } exp_profession_bar.ChangeValue(percent, duringTime * (percent - exp_profession_bar.Value)); } else { exp_profession_bar.ChangeValue(1, duringTime).setOnComplete(AccountLevelUp); } }
private IEnumerator ShowOneByOneActionCoroutine() { TransformUtil.ClearChildren(scrollContentRoot, true); sweepBtnOne.interactable = false; sweepBtnTen.interactable = false; scrollRect.vertical = false; sweepButtonPrefab.gameObject.SetActive(false); _scrollBar.interactable = false; _scrollBar.value = 1; List <int> keys = _rewardDic.GetKeys(); int count = keys.Count; AccountExpData oldExpData = AccountExpData.GetAccountExpDataByLv(_oldAccountLv); int addExp = 0; for (int i = 0; i < count; i++) { int key = keys[i]; SweepButton sweepBtn = Instantiate <SweepButton>(sweepButtonPrefab); sweepBtn.gameObject.SetActive(true); sweepBtn.transform.SetParent(scrollContentRoot, false); List <GameResData> rewardList = _rewardDic[key]; //exp addExp += GetBaseResNum(rewardList, BaseResType.Account_Exp); int totalexp = addExp + _oldAccountExp + (oldExpData.expTotal - oldExpData.exp); AccountExpData accountExpData = AccountExpData.GetAccountExpDataByExp(totalexp); int accountLv = 0; int accountExp = 0; if (accountExpData == null) { accountLv = GameProxy.instance.AccountMaxLevel; accountExp = 0; } else { accountLv = accountExpData.lv; accountExp = totalexp - (accountExpData.expTotal - accountExpData.exp); } float percent = (addExp * 100.0f) / oldExpData.exp; sweepBtn.SetSweepData(Localization.Get(string.Format("ui.dungeon_sweep_view.sweep_{0}", key)), rewardList, accountLv, accountExp, percent); yield return(null); yield return(null); yield return(null); StartCoroutine(ScrollToBottomCoroutine(sweepShowInterval)); if (count == 1) { yield return(new WaitForSeconds(sweepShowDelay)); } else { yield return(new WaitForSeconds(sweepShowInterval + sweepShowDelay)); } } yield return(null); //animation GameObject completeAni = Instantiate <GameObject>(sweepCompletePrefab); completeAni.SetActive(true); completeAni.transform.SetParent(sweepCompletePrefab.transform.parent, false); completeAni.transform.GetChild(0).gameObject.SetActive(true); _scrollBar.interactable = true; scrollRect.vertical = true; yield return(new WaitForSeconds(0.25f)); //shake LeanTween.moveLocalY(shakePanel, shakePanel.transform.localPosition.y - 6, 0.03f).setLoopPingPong(1); yield return(new WaitForSeconds(1f)); sweepBtnOne.interactable = true; sweepBtnTen.interactable = true; completeAni.AddComponent <Logic.UI.CommonAnimations.CommonFadeToAnimation>().init(1, 0, 0.2f, 0); yield return(new WaitForSeconds(0.2f)); GameObject.DestroyImmediate(completeAni); }