private void RefreshUI() { PlayerData pd = GameRoot.instance.Playerdata; SetText(txtCharactor, pd.name + " LV" + pd.lv); SetText(txtExp, pd.exp + "/" + PECommon.GetExpUpValByLv(pd.lv)); imgExp.fillAmount = (pd.exp * 1.0f / PECommon.GetExpUpValByLv(pd.lv)); SetText(txtPower, pd.power); imgPower.fillAmount = (pd.power * 1.0f / PECommon.GetPowerLimit(pd.lv)); SetText(txtJob, " 职业 暗夜刺客"); SetText(txtFight, " 战力 " + PECommon.GetFightByPlayerData(pd)); SetText(txtHP, " 生命 " + pd.hp); SetText(txtDamage, " 伤害 " + (pd.ad + pd.ap)); SetText(txtDefend, " 防御 " + (pd.addef + pd.apdef)); //detail SetText(hpValue, pd.hp); SetText(addValue, pd.ad); SetText(apValue, pd.ap); SetText(addValue, pd.addef); SetText(apdValue, pd.apdef); SetText(dodgeValue, pd.dodge); SetText(pierceValue, pd.pierce); SetText(criticalValue, pd.critical); }
public void RefreshUI() { PlayerData pd = GameRoot.instance.Playerdata; SetText(txtFight, PECommon.GetFightByPlayerData(pd)); SetText(txtLV, pd.lv); SetText(txtPower, "体力:" + pd.power + "/" + PECommon.GetPowerLimit(pd.lv)); //需要限制不要超出范围吗? imgPowerPrg.fillAmount = pd.power * 1.0f / PECommon.GetPowerLimit(pd.lv); SetText(txtName, pd.name); #region ExpProgress int expValPercent = (int)(pd.exp * 1.0f / PECommon.GetExpUpValByLv(pd.lv) * 100); SetText(txtExpPrg, expValPercent + "%"); int index = expValPercent / 10; GridLayoutGroup grid = expProgramTrans.GetComponent <GridLayoutGroup>(); //得到 标准高度和当前高度的比例,然后乘以当前宽度得到真实宽度,然后减掉间隙计算经验条宽度 float screenRate = 1.0f * Constants.screenStandardHeight / Screen.height; float screenWidth = Screen.width * screenRate; float width = (screenWidth - 180) / 10; grid.cellSize = new Vector2(width, 7); for (int i = 0; i < expProgramTrans.childCount; i++) { Image expImageValue = expProgramTrans.GetChild(i).GetComponent <Image>(); if (i < index) { expImageValue.fillAmount = 1; } else if (i == index) { expImageValue.fillAmount = expValPercent * 1.0f % 10 / 10; } else { expImageValue.fillAmount = 0; } } #endregion //设置自动任务图标 currentTaskData = resSvc.GetGuideCfgData(pd.guideid); if (currentTaskData != null) { SetGuideBtnIcon(currentTaskData.npcID); } else {//没任务就显示默认图标 SetGuideBtnIcon(-1); } }