Exemplo n.º 1
0
        /// <summary>
        /// 通过[等级]二分快速查表
        /// </summary>
        /// <param name="level">等级</param>
        /// <returns></returns>
        public static IEnumerable <PetUpGradeDataBase> Query(this List <PetUpGradeDataBase> sorted, uint level)
        {
            var key = new PetUpGradeDataBase()
            {
                level = level
            };
            var comparer = new Comparer1();
            var from     = sorted.BinarySearch(key, comparer);

            if (from < 0)
            {
                yield break;
            }
            var to = from + 1;

            while (from > 0 && comparer.Compare(key, sorted[from - 1]) == 0)
            {
                from--;
            }
            while (to < sorted.Count && comparer.Compare(key, sorted[to]) == 0)
            {
                to++;
            }
            for (var i = from; i < to; i++)
            {
                yield return(sorted[i]);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 通过[等级 + 宠物ID]二分快速查表
        /// </summary>
        /// <param name="level">等级</param>
        /// <param name="petID">宠物ID</param>
        /// <returns></returns>
        public static PetUpGradeDataBase Query(this List <PetUpGradeDataBase> sorted, uint level, uint petID)
        {
            var key = new PetUpGradeDataBase()
            {
                level = level, petID = petID
            };
            var comparer = new Comparer2();
            var index    = sorted.BinarySearch(key, comparer);

            return(index >= 0 ? sorted[index] : default(PetUpGradeDataBase));
        }
Exemplo n.º 3
0
    public uint GetBaseProp(string prop, int petBaseID, uint level, bool isAddPointUI = false)
    {
        PetUpGradeDataBase db = GetPetUpGradeDataBase(level, petBaseID);

        if (db != null)
        {
            PetTalent tal = CurPet.GetAttrTalent();
            if (prop == FightCreatureProp.Strength.ToString())
            {
                if (isAddPointUI)
                {
                    return(db.power);
                }
                return(db.power + tal.liliang);
            }
            else if (prop == FightCreatureProp.Corporeity.ToString())
            {
                if (isAddPointUI)
                {
                    return(db.tizhi);
                }
                return(db.tizhi + tal.tizhi);
            }
            else if (prop == FightCreatureProp.Intelligence.ToString())
            {
                if (isAddPointUI)
                {
                    return(db.zhili);
                }
                return(db.zhili + tal.zhili);
            }
            else if (prop == FightCreatureProp.Spirit.ToString())
            {
                if (isAddPointUI)
                {
                    return(db.jingshen);
                }
                return(db.jingshen + tal.jingshen);
            }
            else if (prop == FightCreatureProp.Agility.ToString())
            {
                if (isAddPointUI)
                {
                    return(db.minjie);
                }
                return(db.minjie + tal.minjie);
            }
        }
        return(0);
    }
Exemplo n.º 4
0
    bool IsCanUpLevel()
    {
        uint itemID = m_currUICommonUseItemGrid.Data.itemid;

        if (m_UseItemParam.type == UseItemEnum.PetExp)
        {
            int level       = ClientGlobal.Instance().MainPlayer.GetProp((int)CreatureProp.Level);
            int yinhunLevel = CurPet.GetProp((int)PetProp.YinHunLevel);
            int totalLevel  = level + yinhunLevel;
            if (m_nCurPetLevel >= totalLevel)
            {
                return(false);
            }
            int addexp = GameTableManager.Instance.GetGlobalConfig <int>("ExpItem", itemID.ToString());
            m_nCurPetExp = m_nCurPetExp + addexp;
            PetUpGradeDataBase db = GameTableManager.Instance.GetTableItem <PetUpGradeDataBase>((uint)m_nCurPetLevel, (int)CurPet.PetBaseID);
            if (db == null)
            {
                Engine.Utility.Log.Error("level is error " + m_nCurPetLevel);
                return(false);
            }
            uint needExp = db.upGradeExp;
            while (m_nCurPetExp >= needExp)
            {
                int petlevel = m_nCurPetLevel + 1;

                if (petlevel >= totalLevel)
                {
                    OnPetUse(m_currUICommonUseItemGrid);
                    return(false);
                }
                else
                {
                    m_nCurPetLevel = petlevel;
                }
                m_nCurPetExp -= (int)needExp;
                needExp       = GameTableManager.Instance.GetTableItem <PetUpGradeDataBase>((uint)m_nCurPetLevel, (int)CurPet.PetBaseID).upGradeExp;
            }
        }
        return(true);
    }
Exemplo n.º 5
0
    /*
     * 	力量天赋系数计算公式
     * 力量天赋系数 = (力量天赋 / 10000 + 1)* 100%
     * 	体质天赋系数计算公式
     * 体质天赋系数 = (体质天赋 / 10000 + 1)* 100%
     * 	敏捷天赋系数计算公式
     * 敏捷天赋系数 = (敏捷天赋 / 10000 + 1)* 100%
     * 	智力天赋系数计算公式
     * 智力天赋系数 = (智力天赋 / 10000 + 1)* 100%
     * 	精神天赋系数计算公式
     * 精神天赋系数 = (精神天赋 / 10000 + 1)* 100%
     *
     */
    void InitAddLabelData()
    {
        if (CurPet != null)
        {
            float liliangfactor  = ((float)(CurPet.GetProp((int)PetProp.StrengthTalent) * 1.0f / 10000) + 1);
            float tizhifactor    = ((float)(CurPet.GetProp((int)PetProp.CorporeityTalent) * 1.0f / 10000) + 1);
            float minjiefactor   = ((float)(CurPet.GetProp((int)PetProp.AgilityTalent) * 1.0f / 10000) + 1);
            float zhilifactor    = ((float)(CurPet.GetProp((int)PetProp.IntelligenceTalent) * 1.0f / 10000) + 1);
            float jingshenfactor = ((float)(CurPet.GetProp((int)PetProp.SpiritTalent) * 1.0f / 10000) + 1);
            int   level          = petDataManager.GetCurPetLevel();
            //成长属性系数
            List <float> gradeAttr = GameTableManager.Instance.GetGlobalConfigList <float>("GradeAttr");
            int          state     = CurPet.GetProp((int)PetProp.PetGuiYuanStatus) - 1;

            float growFactor = gradeAttr[state];
            //成长潜修系数
            List <float> gradeArg = GameTableManager.Instance.GetGlobalConfigList <float>("GradeArg");

            float qianxiuFactor   = gradeArg[state];
            PetUpGradeDataBase db = GameTableManager.Instance.GetTableItem <PetUpGradeDataBase>((uint)CurPet.PetBaseID, level);
            foreach (var dic in labelAddDic)
            {
                UILabel label    = dic.Value;
                int     oldValue = petDataManager.GetPropByString(dic.Key);
                string  newStr   = "";
                int     newValue = 0;
                if (dic.Key == CreatureProp.MaxHp.ToString())
                {//生命基础值 + 体质基础值 * 体质天赋系数 * 成长属性系数 * 体质生命转换系数
                    int   baseValue = addPointDic[FightCreatureProp.Corporeity.ToString()];
                    float factor    = GameTableManager.Instance.GetGlobalConfig <float>("Tizhi2HP");
                    newValue = (int)(/*db.maxHp+*/ baseValue * tizhifactor * growFactor * factor);
                    newStr   = newValue.ToString();
                }
                else if (dic.Key == FightCreatureProp.PhysicsAttack.ToString())
                {//b)	物理攻击 = 力量基础值 * 力量天赋系数 * 成长属性系数 * 力量物攻转换系数
                    int   baseValue = addPointDic[FightCreatureProp.Strength.ToString()];
                    float factor    = GameTableManager.Instance.GetGlobalConfig <float>("Lilang2Pdam");
                    newValue = (int)(baseValue * liliangfactor * growFactor * factor);
                    newStr   = newValue.ToString();
                }
                else if (dic.Key == FightCreatureProp.PhysicsDefend.ToString())
                {//b)	物理防御 = 体质基础值 * 体质天赋系数 * 成长属性系数 * 体质物防转换系数
                    int   baseValue = addPointDic[FightCreatureProp.Corporeity.ToString()];
                    float factor    = GameTableManager.Instance.GetGlobalConfig <float>("Tizhi2Pdef");
                    newValue = (int)(baseValue * tizhifactor * growFactor * factor);
                    newStr   = newValue.ToString();
                }
                else if (dic.Key == FightCreatureProp.MagicAttack.ToString())
                {//b)	法术攻击 = 智力基础值 * 智力天赋系数 * 成长属性系数 * 智力法攻转换系数
                    int   baseValue = addPointDic[FightCreatureProp.Intelligence.ToString()];
                    float factor    = GameTableManager.Instance.GetGlobalConfig <float>("Zhili2Mdam");
                    newValue = (int)(baseValue * zhilifactor * growFactor * factor);
                    newStr   = newValue.ToString();
                }
                else if (dic.Key == FightCreatureProp.MagicDefend.ToString())
                {//b)	法术防御 = 精神基础值 * 精神天赋系数 * 成长属性系数 * 精神法防转换系
                    int   baseValue = addPointDic[FightCreatureProp.Spirit.ToString()];
                    float factor    = GameTableManager.Instance.GetGlobalConfig <float>("Jingshen2Mdef");
                    newValue = (int)(baseValue * jingshenfactor * growFactor * factor);
                    newStr   = newValue.ToString();
                }
                else if (dic.Key == FightCreatureProp.Hit.ToString())
                {//d)	命中值 =(命中初始加成值 + 敏捷基础值 * 敏捷命中转换系数 * 敏捷天赋系数)* 命中修正系)
                    //	命中值 =(命中初始加成值 + 敏捷基础值 * 敏捷命中转换系数 * 敏捷天赋系数) 新公式 like说不乘修正系数
                    int   baseValue1 = addPointDic[FightCreatureProp.Agility.ToString()];
                    int   baseValue2 = GameTableManager.Instance.GetGlobalConfig <int>("HitInit");
                    float factor     = GameTableManager.Instance.GetGlobalConfig <float>("Minjie2Hit");
                    float factor2    = GameTableManager.Instance.GetGlobalConfig <float>("HitFix");
                    newValue = (int)((/* baseValue2 +*/ baseValue1 * factor * minjiefactor) * 100);
                    newStr   = newValue.ToString();
                }
                else if (dic.Key == FightCreatureProp.Dodge.ToString())
                {//d)	回避值 = (回避初始加成值 + 敏捷基础值 * 敏捷回避转换系数 * 敏捷天赋系数)* 回避修正系数
                    //回避值 = (回避初始加成值 + 敏捷基础值 * 敏捷回避转换系数 * 敏捷天赋系数)
                    int   baseValue1 = addPointDic[FightCreatureProp.Agility.ToString()];
                    int   baseValue2 = GameTableManager.Instance.GetGlobalConfig <int>("HideInit");
                    float factor     = GameTableManager.Instance.GetGlobalConfig <float>("Minjie2Hide");
                    float factor2    = GameTableManager.Instance.GetGlobalConfig <float>("HideFix");
                    newValue = (int)((/*baseValue2 +*/ baseValue1 * factor * minjiefactor) * 100);
                    newStr   = newValue.ToString();
                }
                else if (dic.Key == FightCreatureProp.PhysicsCrit.ToString())
                {//c)	物理致命几率 = (物理致命基础附加值 + 敏捷基础值 * 敏捷天赋系数 * 成长属性系数 * 敏捷物爆转换系数 / 100) * 100%
                    int    baseValue1 = addPointDic[FightCreatureProp.Agility.ToString()];
                    double baseValue2 = GameTableManager.Instance.GetGlobalConfig <double>("PluckyInit");
                    float  factor     = GameTableManager.Instance.GetGlobalConfig <float>("Minjie2Plucky");
                    int    nv         = (int)((/*baseValue2 +*/ baseValue1 * growFactor * minjiefactor * factor / 100) * 10000);
                    newStr = nv.ToString();
                }
                else if (dic.Key == FightCreatureProp.MagicCrit.ToString())
                {//c)	法术致命几率 = (法术致命基础附加值 + 智力基础值 * 智力天赋系数 * 成长属性系数 * 智力法爆转换系数 / 100) * 100%
                    int    baseValue1 = addPointDic[FightCreatureProp.Intelligence.ToString()];
                    double baseValue2 = GameTableManager.Instance.GetGlobalConfig <double>("MluckyInit");
                    float  factor     = GameTableManager.Instance.GetGlobalConfig <float>("Zhili2Mlucky");
                    int    nv         = (int)((/*baseValue2 +*/ baseValue1 * growFactor * zhilifactor * factor / 100) * 10000);
                    newStr = nv.ToString();
                }

                label.text = newStr;
            }
        }
    }
Exemplo n.º 6
0
    bool GetInheritLevel(out int level)
    {
        level = 0;
        IPet oldpet = petDataManager.GetInheritPet((int)PetInheritPos.Old);

        if (oldpet == null)
        {
            return(true);
        }
        IPet newpet = petDataManager.GetInheritPet((int)PetInheritPos.New);

        if (newpet == null)
        {
            return(true);
        }
        int  oldPetLv = oldpet.GetProp((int)CreatureProp.Level);
        uint oldExp   = (uint)oldpet.GetProp((int)PetProp.LevelExp);

        for (int i = 1; i < oldPetLv; i++)
        {
            PetUpGradeDataBase udb = GameTableManager.Instance.GetTableItem <PetUpGradeDataBase>((uint)i, (int)oldpet.PetBaseID);
            if (udb != null)
            {
                oldExp += udb.upGradeExp;
            }
        }

        int  newPetLv = newpet.GetProp((int)CreatureProp.Level);
        uint newExp   = (uint)newpet.GetProp((int)PetProp.LevelExp);

        newExp += oldExp;
        level   = newPetLv;
        int playerLv = MainPlayerHelper.GetPlayerLevel();
        int newYinLv = newpet.GetProp((int)PetProp.YinHunLevel);

        if (petDataManager.bInheritXiuwei)
        {
            GetInheritXiuWeiLevel(out newYinLv);
        }
        int maxLv = playerLv + newYinLv;

        maxLv = maxLv > level ? maxLv : level;
        int tempLv = level;

        while (newExp > 0)
        {
            PetUpGradeDataBase udb = GameTableManager.Instance.GetTableItem <PetUpGradeDataBase>((uint)tempLv, (int)newpet.PetBaseID);
            if (udb != null)
            {
                if (newExp >= udb.upGradeExp)
                {
                    tempLv += 1;
                    newExp -= udb.upGradeExp;
                }
                else
                {
                    break;
                }
            }
            else
            {
                tempLv -= 1;

                level = tempLv > maxLv ? maxLv : tempLv;
                return(false);
            }
        }

        level = tempLv > maxLv ? maxLv : tempLv;
        return(true);
    }