Example #1
0
    private void CalcExp(PlayerData pd, int addExp)
    {
        int curExp     = pd.exp;
        int addRestExp = addExp;
        int curtLv     = pd.lv;

        while (addRestExp > 0)
        {
            int totalExp = PECommon.GetExpUpVaByLv(curtLv);
            int needExp  = totalExp - curExp;

            if (needExp <= addRestExp)
            {
                curtLv++;
                curExp      = 0;
                addRestExp -= needExp;
            }
            else
            {
                curExp     += addRestExp;
                addRestExp -= addRestExp;
            }
        }
        pd.lv  = curtLv;
        pd.exp = curExp;
    }
Example #2
0
    public void RefreshUI()
    {
        #region UI显示
        PlayerData playerData = GameRoot.instance.PlayerData;
        SetText(txFight, PECommon.GetFightByProps(playerData));
        SetText(txPower, "体力:" + playerData.power + "/150");
        impPowerPrg.fillAmount = playerData.power * 1.0f / 150;

        SetText(txLevel, playerData.lv);
        SetText(txName, playerData.name);
        #endregion

        //expprg
        #region Expprg自适应
        int expPrgVal = (int)((playerData.exp * 1.0f) / PECommon.GetExpUpVaByLv(playerData.lv) * 100);
        SetText(txExpPrg, expPrgVal + "%");

        int index = expPrgVal / 10;
        for (int i = 0; i < expPrgTrans.childCount; i++)
        {
            Image img = expPrgTrans.GetChild(i).GetComponent <Image>();
            if (i < index)
            {
                img.fillAmount = 1;
            }
            else if (i == index)
            {
                img.fillAmount = expPrgVal % 10 * 1.0f / 10;
            }
            else
            {
                img.fillAmount = 0;
            }
        }

        GridLayoutGroup grid = expPrgTrans.GetComponent <GridLayoutGroup>();

        float gloablRate = 1.0f * Constants.ScreenStandardHeight / Screen.height;

        float real_width = Screen.width * gloablRate;

        float width = (real_width - 180) / 10;

        grid.cellSize = new Vector2(width, 7);
        #endregion

        #region 任务图标
        curtTaskData = ResSvc.instance.GetGuideCfg(playerData.guideid);
        if (curtTaskData != null)
        {
            SetGuideImage(curtTaskData.npcID);
        }
        else
        {
            SetGuideImage(-1);
        }

        #endregion
    }
Example #3
0
    private void RefreshUI()
    {
        PlayerData data = GameRoot.instance.PlayerData;

        SetText(txInfo, data.name + "LV." + data.lv);
        SetText(txExp, data.exp + "/" + PECommon.GetExpUpVaByLv(data.lv));
        SetText(txPower, data.power + "/" + 150);

        imgExp.fillAmount   = data.exp * 1.0f / PECommon.GetExpUpVaByLv(data.lv);
        imgPower.fillAmount = data.power * 1.0f / 150;
        SetText(txOccp, "暗夜刺客");
        SetText(txHp, data.hp);
        SetText(txHurt, data.ad);
        SetText(txDefense, data.addef);
        SetText(txBattle, PECommon.GetFightByProps(data));

        //detail
    }