Ejemplo n.º 1
0
    void CalculateUpdateData()
    {
        if (heroCardItem == null)
        {
            heroUpdateInfo.gameObject.SetActive(false);
            return;
        }


        int money = heroCardItem.GetUpDateCostMoney(materialCardItems);

        float skillUpdateRate = this.CalculateSkillUpdateRate(materialCardItems);

        int exp = 0;

        for (int i = 0; i < materialCardItems.Length; i++)
        {
            if (materialCardItems[i] != null)
            {
                exp += TableManager.GetCardByID(materialCardItems[i].templateID).ExpBase *materialCardItems[i].level;
            }
        }

        int nMaxLev     = TableManager.GetCardByID(heroCardItem.templateID).MaxLevel;
        int curTotalExp = (TableManager.GetCardexperienceByID(heroCardItem.level).TotalExp
                           - TableManager.GetCardexperienceByID(heroCardItem.level).CardExp)
                          + heroCardItem.cardExp;

        int nMaxTotalExp   = TableManager.GetCardexperienceByID(nMaxLev).TotalExp - TableManager.GetCardexperienceByID(nMaxLev).CardExp;
        int nMaxLevNeedExp = nMaxTotalExp - curTotalExp;

        expLabel.text = exp + "/" + nMaxLevNeedExp;

        if (exp > 0)
        {
            //if(tbl_skill_vol.SkillMaxlevel == heroCardItem.skillLevel)
            //{
            //heroUpdateInfo.gameObject.SetActive(false);
            //}
            //else
            //{
            heroUpdateInfo.gameObject.SetActive(true);
            //}

            Tab_Card  tbl_card      = TableManager.GetCardByID(heroCardItem.templateID);
            Tab_Skill tbl_skill_vol = TableManager.GetSkillByID(tbl_card.SkillVol);

            if (!IsChoosedMaterials() || tbl_skill_vol.SkillMaxlevel == heroCardItem.skillLevel)
            {
                labelSkillRate.gameObject.SetActive(false);
                labelSkill.gameObject.SetActive(false);
            }
            else
            {
                labelSkillRate.gameObject.SetActive(true);
                labelSkill.gameObject.SetActive(true);
            }


            float fSkillRate = skillUpdateRate * 100;
            volSkillProb.text = (int)fSkillRate + "%";
            costMoney.text    = money.ToString();

            //?????€??????
            if (heroCardItem.level < TableManager.GetCardByID(heroCardItem.templateID).MaxLevel)
            {
                int  temp_lvl    = heroCardItem.level;
                int  temp_exp    = exp;
                int  temp_curexp = heroCardItem.cardExp;
                bool is_add      = true;

                int dexp = TableManager.GetCardexperienceByID(temp_lvl).CardExp - temp_curexp;
                if (temp_exp < dexp)
                {
                    is_add       = false;
                    temp_curexp += temp_exp;
                }

                while (is_add)
                {
                    if (temp_lvl >= TableManager.GetCardByID(heroCardItem.templateID).MaxLevel)
                    {
                        is_add = false;
                        break;
                    }
                    dexp = TableManager.GetCardexperienceByID(temp_lvl).CardExp - temp_curexp;

                    if (temp_exp < dexp)
                    {
                        is_add      = false;
                        temp_curexp = temp_exp;
                    }
                    else
                    {
                        temp_exp   -= dexp;
                        temp_curexp = 0;
                        temp_lvl++;
                    }
                }

                if (temp_lvl > heroCardItem.level)
                {
                    levelValue.gameObject.SetActive(false);
                    lvlUpdatedValue.gameObject.SetActive(true);
                    hpAddValue.gameObject.SetActive(true);
                    AttackAddValue.gameObject.SetActive(true);
                    expUpdateBar.gameObject.SetActive(true);
                    expUpdateBar.sliderValue = ((float)temp_curexp) / (float)TableManager.GetCardexperienceByID(temp_lvl).CardExp;
                    lvlUpdatedValue.text     = temp_lvl.ToString();
                    hpAddValue.text          = "+" + (TableManager.GetCardByID(heroCardItem.templateID).HpGrow *(temp_lvl - heroCardItem.level)).ToString();
                    AttackAddValue.text      = "+" + (TableManager.GetCardByID(heroCardItem.templateID).AttackGrow *(temp_lvl - heroCardItem.level)).ToString();
                }
                else
                {
                    expUpdateBar.gameObject.SetActive(true);
                    expUpdateBar.sliderValue = ((float)temp_curexp) / (float)TableManager.GetCardexperienceByID(temp_lvl).CardExp;
                    AttackAddValue.gameObject.SetActive(false);
                    hpAddValue.gameObject.SetActive(false);
                    lvlUpdatedValue.gameObject.SetActive(false);
                    levelValue.gameObject.SetActive(true);
                }


                //ÅжÏÖ®ºó»á²»»áÉýŒ¶,ŽÓ¶øÓ°Ï죬µÈŒ¶ÎÄ×ÖµÄÇл»ÏÔÊŸ
                if (temp_lvl > heroCardItem.level)
                {
                    bBeGoingToUpdate = true;
                }
                else
                {
                    bBeGoingToUpdate = false;
                }

                addExp.text         = exp.ToString();
                updateBtn.isEnabled = true;
                //updateBtn.transform.FindChild("Sprite").GetComponent<UISprite>().color = Color.white;
            }
            else             //??????????¡Á???????????,??????????????
            {
                fSkillRate        = skillUpdateRate * 100;
                volSkillProb.text = (int)fSkillRate + "%";
                addExp.text       = "0";
                AttackAddValue.gameObject.SetActive(false);
                hpAddValue.gameObject.SetActive(false);
                lvlUpdatedValue.gameObject.SetActive(false);
                levelValue.gameObject.SetActive(true);
                bBeGoingToUpdate = false;
            }
        }
        else
        {
            heroUpdateInfo.gameObject.SetActive(false);
        }
    }