示例#1
0
        public int CheckElfType(CharacterController character, ElfRecord tbElf, int targetIndex)
        {
            var sameIndex     = 0;
            var elfBag        = character.GetBag((int)eBagType.Elf);
            var nowFightCount = character.GetElfFightCount();

            if (targetIndex > nowFightCount)
            {
//检查尚未开启的精灵栏,返回不可用
                return(0);
            }
            for (var i = 0; i != nowFightCount; ++i)
            {
                if (i == targetIndex)
                {
                    continue;
                }
                var tempItem = elfBag.GetItemByIndex(i);
                if (tempItem == null)
                {
                    continue;
                }
                var tbTempElf = Table.GetElf(tempItem.GetId());
                if (tbTempElf == null)
                {
                    continue;
                }
                if (tbTempElf.ElfType == tbElf.ElfType)
                {
                    return(sameIndex);
                }
            }
            return(-1);
        }
示例#2
0
        //随机属性条数随机
        private int RandomAddCount(ElfRecord tbElf, int EquipRelateId)
        {
            if (EquipRelateId == -1)
            {
                return(0);
            }
            var tbRelate = Table.GetEquipRelate(EquipRelateId);

            if (tbRelate == null)
            {
                Logger.Error("EquipRelate Id={0} not find", EquipRelateId);
                return(0);
            }
            var AddCount     = 0;
            var nRandom      = MyRandom.Random(10000);
            var nTotleRandom = 0;

            for (var i = 0; i != tbRelate.AttrCount.Length; ++i)
            {
                nTotleRandom += tbRelate.AttrCount[i];
                if (nRandom < nTotleRandom)
                {
                    return(i);
                    //if (i == 0) return 0;
                    //AddCount = i;
                    //break;
                }
            }
            Logger.Error("Elf RandomAddCount not find Pro! EquipRelateId={0}", EquipRelateId);
            return(AddCount);
        }
示例#3
0
 public static int CheckElfType(this CharacterController character, ElfRecord tbElf, int targetIndex)
 {
     return(mStaticImpl.CheckElfType(character, tbElf, targetIndex));
 }
示例#4
0
        //初始化附加属性
        public void InitAddAttr(ElfRecord tbElf, int addCount)
        {
            if (addCount <= 0 || addCount > 6)
            {
                return;
            }
            int nRandom, nTotleRandom;
            var TbAttrPro = Table.GetEquipEnchantChance(tbElf.RandomPropPro);

            if (TbAttrPro == null)
            {
                Logger.Error("Equip InitAddAttr Id={0} not find EquipEnchantChance Id={1}", tbElf.Id,
                             tbElf.RandomPropPro);
                return;
            }
            var tempAttrPro   = new Dictionary <int, int>();
            var nTotleAttrPro = 0;

            for (var i = 0; i != 23; ++i)
            {
                var nAttrpro = TbAttrPro.Attr[i];
                if (nAttrpro > 0)
                {
                    nTotleAttrPro += nAttrpro;
                    tempAttrPro[i] = nAttrpro;
                }
            }
            //属性值都在这里
            var tbEnchant = Table.GetEquipEnchant(tbElf.RandomPropValue);

            if (tbEnchant == null)
            {
                Logger.Error("Equip InitAddAttr Id={0} not find tbEquipEnchant Id={1}", tbElf.Id, tbElf.RandomPropValue);
                return;
            }
            //整理概率
            var AttrValue = new Dictionary <int, int>();

            for (var i = 0; i != addCount; ++i)
            {
                nRandom      = MyRandom.Random(nTotleAttrPro);
                nTotleRandom = 0;
                foreach (var i1 in tempAttrPro)
                {
                    nTotleRandom += i1.Value;
                    if (nRandom < nTotleRandom)
                    {
                        //AddCount = i1.Key;
                        AttrValue[i1.Key] = tbEnchant.Attr[i1.Key];
                        nTotleAttrPro    -= i1.Value;
                        tempAttrPro.Remove(i1.Key);
                        break;
                    }
                }
            }
            var NowAttrCount = AttrValue.Count;

            if (NowAttrCount < addCount)
            {
                Logger.Error("Equip InitAddAttr AddAttr Not Enough AddCount={0},NowAttrCount={1}", addCount,
                             NowAttrCount);
            }

            //EquipRelateRecord tbAttrRelate = Table.GetEquipRelate(tbElf.RandomAttrInterval);
            //if (tbAttrRelate == null)
            //{
            //    Logger.Error("Equip tbAttrRelate Id={0} not find EquipRelate Id={1}", tbElf.Id, tbElf.RandomAttrInterval);
            //    return;
            //}

            for (var i = 0; i != NowAttrCount; ++i)
            {
                var nKey    = AttrValue.Keys.Min();
                var nAttrId = ItemEquip2.GetAttrId(nKey);
                if (nAttrId == -1)
                {
                    continue;
                }
                var fValue = tbEnchant.Attr[nKey];
                //int AttrValueMin = fValue * tbElf.RandomValueMin / 100;
                //int AttrValueMax = fValue * tbElf.RandomValueMax / 100;
                //int AttrValueDiff = AttrValueMax - AttrValueMin;
                //nRandom = MyRandom.Random(10000);
                //nTotleRandom = 0;
                //int rMin = 0;
                //int rMax = 10000;
                //for (int j = 0; j != tbAttrRelate.Value.Length; ++j)
                //{
                //    nTotleRandom += tbAttrRelate.Value[j];
                //    if (nRandom < nTotleRandom)
                //    {
                //        switch (j)
                //        {
                //            case 0:
                //                {
                //                    rMin = 0;
                //                    rMax = 5000;
                //                }
                //                break;
                //            case 1:
                //                {
                //                    rMin = 5000;
                //                    rMax = 7500;
                //                }
                //                break;
                //            case 2:
                //                {
                //                    rMin = 7500;
                //                    rMax = 9000;
                //                }
                //                break;
                //            case 3:
                //                {
                //                    rMin = 9000;
                //                    rMax = 10000;
                //                }
                //                break;
                //        }
                //        break;
                //    }
                //}
                //int AttrValueMin2 = AttrValueMin + AttrValueDiff * rMin / 10000;
                //int AttrValueMax2 = AttrValueMin + AttrValueDiff * rMax / 10000;
                //int AttrRealValue = MyRandom.Random(AttrValueMin2, AttrValueMax2);
                AddAttr(i, nAttrId, fValue);
                AttrValue.Remove(nKey);
            }
        }
示例#5
0
        //获得属性列表
        public void GetAttrList(Dictionary <int, int> AttrList, ElfRecord tbElf, int characterLevel, int baseValueBili)
        {
            var elfLevel = GetExdata(0);
            var isBattle = GetIndex(); //GetExdata(1);

            //基础属性
            for (var i = 0; i < tbElf.ElfInitProp.Length; i++)
            {
                var attrId = tbElf.ElfInitProp[i];
                if (attrId == -1)
                {
                    break;
                }
                long attrValue = tbElf.ElfProp[i];
                if (elfLevel > 1)
                {
                    var upvalue = tbElf.GrowAddValue[i];
                    attrValue += upvalue * (elfLevel - 1);
                    //int attrindex = GetAttrIndex(attrId);
                    //if (attrindex != -1)
                    //{
                    //    attrValue += tbLevelRef.PropPercent[attrindex] * (elfLevel - 1);
                    //}
                    //else
                    //{
                    //    attrindex = GetBaseAttrIndex(attrId);
                    //    if (attrindex != -1)
                    //    {
                    //        attrValue += tbLevelRef.Attr[attrindex] * (elfLevel - 1);
                    //    }
                    //    else
                    //    {
                    //        Logger.Warn("elf GetAttrList not find attr id={0},attrId={1}", tbElf.Id, attrId);
                    //    }
                    //}
                }
                if (isBattle == 0)
                {
                    var v = (int)(attrValue * BattleRef / 10000 * baseValueBili / 10000);
                    AttrList.modifyValue(attrId, v);
                }
                else
                {
                    var v = (int)(attrValue * NoBattleRef / 10000 * baseValueBili / 10000);
                    AttrList.modifyValue(attrId, v);
                }
            }
            //随机属性
            //if (isBattle == 0)    // 上阵的都有天赋属性
            {
                for (var i = 2; i < 8; ++i)
                {
                    var attrId = GetExdata(i);
                    if (attrId == -1)
                    {
                        continue;
                    }
                    var attrValue = GetExdata(i + 6);
                    AttrList.modifyValue(attrId, attrValue);
                }
            }
        }