//初始化强化需求材料 public void GetEquipEnchance(ItemEquip2 itemequip, CharacterController character, bool isMust = false) { var tbItem = Table.GetItemBase(itemequip.GetId()); if (!isMust) { if (itemequip.GetExdata(22) != -1) { return; } itemequip.MarkDirty(); } Logger.Info("---GetEquipEnchance---Type={0},ItemId={1},Level={2}", tbItem.Type, itemequip.GetId(), itemequip.GetExdata(0)); //var tbEquip = Table.GetEquip(tbItem.Exdata[0]); var nNeedLevel = tbItem.UseLevel; //int nColor = tbItem.Color; var nLevel = itemequip.GetExdata(0); var tbenchance = Table.GetEquipEnchance(nLevel); var tbladder = Table.GetEquipEnchance(nNeedLevel); for (var i = 0; i != 6; ++i) { var nNewLevel = nNeedLevel + (RandomEquipLevel(tbladder) - 3) * 5; var nNewType = RandomEquipType(tbenchance); var nNewColor = RandomEquipColor(tbenchance); //参数构造: 装备类型*10000 + 装备等级 * 10 + 颜色 var nValue = GetEnchanceValue(nNewType, nNewLevel, nNewColor); itemequip.SetExdata(22 + i, nValue); } }
//更换装备时新的等级计算 public void ResetEquipLevel(CharacterController character, ItemEquip2 oldItem, ItemEquip2 newItem) { var tbOldItem = ItemBase.GetTableItem(oldItem.GetId()); if (tbOldItem == null) { Logger.Warn("ResetEquipLevel OldEquip[{0}] not find by Table", oldItem.GetId()); return; } var tbNewItem = ItemBase.GetTableItem(newItem.GetId()); if (tbNewItem == null) { Logger.Warn("ResetEquipLevel NewEquip[{0}] not find by Table", newItem.GetId()); return; } if (tbOldItem.Type != tbNewItem.Type) { Logger.Warn("ResetEquipLevel OldEquip[{0}] NewEquip[{1}] Type is Different", oldItem.GetId(), newItem.GetId()); return; } var nValue = GetEquipAddValue(character, tbOldItem.Type); //计算概率 var nTotleGiveValue = 0; var nLevelUp = 0; var tbNewEquip = ItemEquip2.GetTableEquip(newItem.GetId()); if (tbNewEquip == null) { Logger.Warn("ResetEquipLevel NewEquip[{0}] not find by Table", newItem.GetId()); return; } CalculationEnchance(ref nLevelUp, ref nTotleGiveValue, nValue, 0, tbNewItem, tbNewEquip.MaxLevel); //--todo 临时取消了 //oldItem.SetLevel(0); //newItem.SetLevel(nLevelUp); }