예제 #1
0
        private float GetStrengthenMoney(int curlevel, int nextLevel, int expTotal)
        {
            RoleInfo heroInfo        = HeroStrengthenProxy.instance.StrengthenHeroInfo;
            int      expTempTotal    = expTotal;
            float    moneyTotal      = 0;
            float    partMoney       = 0;
            float    addExpPercent   = 0;
            float    totalExpPercent = 0;

            if (expTotal != 0)
            {
                for (int i = curlevel; i <= nextLevel; i++)
                {
                    HeroStrengthenNeedData needData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByLevel(i);
                    if (needData == null)
                    {
                        needData = HeroStrengthenNeedData.LastNeedData();
                    }

                    if (i == nextLevel)
                    {
                        partMoney        = (expTempTotal + 0.0f) / expTotal * needData.gold_need;
                        moneyTotal      += partMoney;
                        addExpPercent    = (expTempTotal + 0.0f) / needData.exp_need;
                        totalExpPercent += addExpPercent;
                    }
                    else if (i == curlevel)
                    {
                        int exp = needData.exp_need - heroInfo.strengthenExp;
                        partMoney        = (exp + 0.0f) / expTotal * needData.gold_need;
                        moneyTotal      += partMoney;
                        expTempTotal    -= exp;
                        addExpPercent    = (exp + 0.0f) / needData.exp_need;
                        totalExpPercent += addExpPercent;
                    }
                    else
                    {
                        partMoney        = (needData.exp_need + 0.0f) / expTotal * needData.gold_need;
                        moneyTotal      += partMoney;
                        expTempTotal    -= needData.exp_need;
                        totalExpPercent += 1;
                    }
                }
            }
            addExpText.text = string.Format("+{0}% EXP", (int)(totalExpPercent * 100));
            return(moneyTotal);
        }
예제 #2
0
        public static float CalcRolePower(RoleInfo roleInfo)
        {
            PlayerInfo player     = roleInfo as PlayerInfo;
            HeroInfo   hero       = roleInfo as HeroInfo;
            int        correction = 0;

            if (player != null)
            {
                correction = player.heroData.correction;
            }
            else if (hero != null)
            {
                correction = hero.heroData.correction;
            }
            int powerBasic  = GlobalData.GetGlobalData().powerBasic;
            int levelFactor = 0;

            if (roleInfo.level <= 50)
            {
                levelFactor = roleInfo.level - 1;
            }
            else
            {
                levelFactor = 2 * roleInfo.level - 51;
            }

            HeroStrengthenNeedData strengthenData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByLevel(roleInfo.strengthenLevel - 1);
            float aggFactor = 0;

            if (strengthenData != null)
            {
                aggFactor = strengthenData.aggr_value;
            }

            float rolePower = correction / 100.0f * 15 * ((powerBasic + levelFactor + aggFactor) * Mathf.Pow(1.28f, roleInfo.advanceLevel - 1));

            rolePower += EquipmentUtil.CalcEquipPower(EquipmentProxy.instance.GetEquipmentInfoByInstanceID(roleInfo.armorID));
            rolePower += EquipmentUtil.CalcEquipPower(EquipmentProxy.instance.GetEquipmentInfoByInstanceID(roleInfo.weaponID));
            rolePower += EquipmentUtil.CalcEquipPower(EquipmentProxy.instance.GetEquipmentInfoByInstanceID(roleInfo.accessoryID));

            return(rolePower);
        }
예제 #3
0
        public void RefreshExp(int addExp)
        {
            RoleInfo heroInfo = HeroStrengthenProxy.instance.StrengthenHeroInfo;

            int curent = heroInfo.strengthenExp;
            HeroStrengthenNeedData needData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByLevel(heroInfo.strengthenLevel);
            float percent    = 0;
            float addPercent = 0;

            if (needData != null)
            {
                percent    = (curent + 0.0f) / needData.exp_need;
                addPercent = percent + (addExp + 0.0f) / needData.exp_need;
            }
            else
            {
                addExpText.text = "MAX";
            }
            currentExpSlider.value = percent;
            addExpSlider.value     = addPercent;
        }
예제 #4
0
        private void RefreshAttribute()
        {
            HeroInfo info;
            int      expTotal = 0;
            float    crit     = 0;

            HeroInfo[] materials           = HeroStrengthenProxy.instance.SelectedMaterialHeroInfos;
            int        count               = materials.Length;
            int        selectMaterialCount = 0;

            for (int i = 0; i < count; i++)
            {
                info = materials[i];
                if (info != null)
                {
                    HeroStrengthenProvideData data = HeroStrengthenProvideData.GetHeroStrengthenProvideDataByID(info.advanceLevel);
                    if (data != null)
                    {
                        expTotal += data.exp_provide;
                        crit     += (data.exp_provide * data.crit);
                    }
                    selectMaterialCount++;
                }
            }
            //crit
            if (expTotal != 0)
            {
                crit = crit / expTotal;
            }
            string s;

            if (crit >= 0 && crit < 10)
            {
                s = Localization.Get("ui.hero_strengthen_view.small");
            }
            else if (crit >= 10 && crit < 30)
            {
                s = Localization.Get("ui.hero_strengthen_view.mid");;
            }
            else
            {
                s = Localization.Get("ui.hero_strengthen_view.big");;
            }

            currentCriticalChangeText.text = s;

            //level
            RoleInfo heroInfo = HeroStrengthenProxy.instance.StrengthenHeroInfo;


            HeroStrengthenNeedData curData  = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByLevel(heroInfo.strengthenLevel);
            HeroStrengthenNeedData nextData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByExp(HeroStrengthenNeedData.GetStrengthenTotalExp(heroInfo.strengthenLevel) + heroInfo.strengthenExp + expTotal);
            bool isMax = curData == null ? true : false;

            _isReachMaxLevel = isMax ? true : (nextData == null ? true : false);
            int addLevel = isMax ? 0 : (nextData == null) ? HeroStrengthenNeedData.LastNeedData().aggr_lv - heroInfo.strengthenLevel + 1 : nextData.aggr_lv - heroInfo.strengthenLevel;

            strengthenAddLevel = addLevel;

            int totalLv = heroInfo.strengthenLevel + addLevel;
            int stLv    = RoleUtil.GetStrengthenAddShowValue(totalLv);

            if (stLv == 0)
            {
                strengthenLevelText.text = "";
            }
            else
            {
                strengthenLevelText.text = string.Format("+{0}", stLv);
            }
            strengthenLevelDesText.text = string.Format(Localization.Get("ui.hero_strengthen_view.strengthen_level"), RoleUtil.GetStrengthenLevelColorName(totalLv));
            HeroStrengthenNeedData heroStrengthenNeedData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByID(totalLv - 1);
            RoleStrengthenStage    color = RoleStrengthenStage.White;

            if (heroStrengthenNeedData != null)
            {
                color = heroStrengthenNeedData.roleStrengthenStage;
                strengthenLevelText.color    = UIUtil.GetRoleNameColor(color);
                strengthenLevelDesText.color = UIUtil.GetRoleNameColor(color);
            }
            else
            {
                strengthenLevelText.color    = UIUtil.GetRoleNameColor(RoleStrengthenStage.White);
                strengthenLevelDesText.color = UIUtil.GetRoleNameColor(RoleStrengthenStage.White);
            }

            //属性
            RefreshMainAttribute(addLevel);

            //money
            float moneyTotal = GetStrengthenMoney(heroInfo.strengthenLevel, heroInfo.strengthenLevel + addLevel, expTotal);

            moneyTotal = moneyTotal * selectMaterialCount;
            if (moneyTotal > GameProxy.instance.BaseResourceDictionary.GetValue(BaseResType.Gold))
            {
                coinText.text = UIUtil.FormatToRedText(((int)moneyTotal).ToString());
            }
            else
            {
                coinText.text = ((int)moneyTotal).ToString();
            }

            RefreshExp(expTotal);
        }
예제 #5
0
        /// <summary>
        /// 计算英雄属性(不包含装备)
        /// </summary>
        public static Dictionary <RoleAttributeType, RoleAttribute> CalcHeroAttributesDic(HeroData heroData, int level, int advanceLevel, int strengthenLevel)
        {
            if (heroData == null)
            {
                return(null);
            }
            Dictionary <RoleAttributeType, RoleAttribute> attributeDic = new Dictionary <RoleAttributeType, RoleAttribute>();

            int max = (int)RoleAttributeType.MAX;
            RoleAttributeType type;
            float             factor = 0;//成长系数
            bool  canGrowUp          = false;
            float basic = 0;

            for (int i = 0; i < max; i++)
            {
                type      = (RoleAttributeType)i;
                factor    = 0;
                canGrowUp = false;
                switch (type)
                {
                case RoleAttributeType.HP:
                    basic     = heroData.HP;
                    factor    = heroData.hpAdd / 1000.0f;
                    canGrowUp = true;
                    break;

                case RoleAttributeType.NormalAtk:
                    basic     = heroData.normalAtk;
                    factor    = heroData.normalAtkAdd / 1000.0f;
                    canGrowUp = true;
                    break;

                case RoleAttributeType.MagicAtk:
                    basic     = heroData.magicAtk;
                    factor    = heroData.magicAtkAdd / 1000.0f;
                    canGrowUp = true;
                    break;

                case RoleAttributeType.Normal_Def:
                    basic     = heroData.normalDef;
                    factor    = heroData.normalDefAdd / 1000.0f;
                    canGrowUp = true;
                    break;

                case RoleAttributeType.Speed:
                    basic = heroData.speed;
                    break;

                case RoleAttributeType.Hit:
                    basic = heroData.hit;
                    break;

                case RoleAttributeType.Dodge:
                    basic = heroData.dodge;
                    break;

                case RoleAttributeType.Crit:
                    basic = heroData.crit;
                    break;

                case RoleAttributeType.AntiCrit:
                    basic = heroData.antiCrit;
                    break;

                case RoleAttributeType.Block:
                    basic = heroData.block;
                    break;

                case RoleAttributeType.AntiBlock:
                    basic = heroData.antiBlock;
                    break;

                case RoleAttributeType.CounterAtk:
                    basic = heroData.counterAtk;
                    break;

                case RoleAttributeType.CritHurtAdd:
                    basic = heroData.critHurtAdd;
                    break;

                case RoleAttributeType.CritHurtDec:
                    basic = heroData.critHurtDec;
                    break;

                case RoleAttributeType.Armor:
                    basic = heroData.armor;
                    break;

                case RoleAttributeType.DamageAdd:
                    basic = heroData.damageAdd;
                    break;

                case RoleAttributeType.DamageDec:
                    basic = heroData.damageDec;
                    break;

                default:
                    basic = 0;
                    break;
                }
                int multiple = 2;
                if (level <= 50)
                {
                    multiple = 1;
                }
                float total = basic;
                if (canGrowUp)
                {
                    HeroStrengthenNeedData strengthenData = HeroStrengthenNeedData.GetHeroStrengthenNeedDataByLevel(strengthenLevel - 1);
                    float aggFactor = 0;
                    if (strengthenData != null)
                    {
                        aggFactor = strengthenData.aggr_value;
                    }
                    //  total = (basic + (hero.level * multiple - 1) * factor + hero.strengthenLevel * factor * 6) * Mathf.Pow(1.28f, hero.advanceLevel - 1);
                    total = (basic + (level * multiple - 1 - 50 * (multiple - 1)) * factor + aggFactor * factor) * GlobalData.GetGlobalData().starAttr[advanceLevel] * heroData.quality_attr;
                    //total = (basic + (level * multiple - 1) * factor + factor*aggFactor) * Mathf.Pow(1.28f,advanceLevel - 1);
                }
                RoleAttribute attri = new RoleAttribute(type, total);
                attributeDic.Add(type, attri);
            }
            return(attributeDic);
        }