1846 lines
56 KiB
C#
1846 lines
56 KiB
C#
//********************************************************************
|
||
// 文件名: GameItem.cs
|
||
// 描述: 物品
|
||
// 作者: TangYi
|
||
// 创建时间: 2013-12-25
|
||
//
|
||
// 修改历史:
|
||
//********************************************************************
|
||
|
||
using UnityEngine;
|
||
using System.Collections.Generic;
|
||
using System;
|
||
using GCGame.Table;
|
||
using Games.GlobeDefine;
|
||
using GCGame;
|
||
|
||
namespace Games.Item
|
||
{
|
||
/// <summary>
|
||
/// 物品总类(对应commonitem.txt中ClassID)
|
||
/// </summary>
|
||
public enum ItemClass
|
||
{
|
||
EQUIP = 1, //装备
|
||
ADVANCEITEM, //进阶丹药
|
||
STRENGTHEN, //强化道具
|
||
PRIZE, //奖励物品
|
||
MEDIC, //药品
|
||
MISSION, //任务道具
|
||
FASHION, //时装
|
||
MOUNT, //坐骑
|
||
FELLOW, //伙伴
|
||
TRESURE = 12, //宝图
|
||
DAY_LIMIT = 13, //每日限制次数道具
|
||
CHANGENAME = 14, //改名道具
|
||
MAGICITEM = 15, //法宝
|
||
ADVANCEEQUIP = 16, //坐骑装备
|
||
ADVANCEFASHION = 17, //进阶时装
|
||
CHEEST = 18, //宝箱
|
||
GIFTBAG = 19,//礼包
|
||
MARKETINGACT = 20,// 运营活动使用物品
|
||
GUILDCHANGENAME = 23,//帮会修改名字
|
||
}
|
||
|
||
public enum ChestSubType
|
||
{
|
||
ChestBox, //宝箱钥匙
|
||
ChestKey, //宝箱
|
||
}
|
||
|
||
public enum GiftBagSubType
|
||
{
|
||
MultiSelection = 1, // 多选固定数量礼包
|
||
MultiSelection_Random, // 多选随机数量礼包
|
||
OneAmountTime, // 一物多用礼包
|
||
TypeAmountTime, // 一类多用礼包
|
||
AccumulateTime, // 累计到达次数才能使用的礼包
|
||
}
|
||
|
||
public enum AdvanceItemSubType
|
||
{
|
||
Ride = 1, //坐骑
|
||
GodWeapon, //神兵
|
||
Wing, //翅膀
|
||
Wish, //如意
|
||
Seal, //玉玺
|
||
Mask, //面具
|
||
Crown, //皇冠
|
||
Meridian, //经脉
|
||
RideSkill, //坐骑技能
|
||
GodWeaponSkill, //神兵技能
|
||
WingSkill, //翅膀技能
|
||
WishSkill, //如意技能
|
||
SealSkill, //玉玺技能
|
||
MaskSkill, //面具技能
|
||
CrownSkill, //皇冠技能
|
||
|
||
//16--29 注魂注灵道具,都打开第一个界面
|
||
RideSoul = 16,
|
||
CrownSoul = 22,
|
||
RideSprit = 23,
|
||
CrownSprit = 29,
|
||
}
|
||
|
||
public enum AdvanceFashionSubType
|
||
{
|
||
Ride, //坐骑
|
||
GodWeapon, //神兵
|
||
Wing, //翅膀
|
||
Wish, //如意
|
||
Seal, //玉玺
|
||
Mask, //面具
|
||
Crown, //皇冠
|
||
}
|
||
|
||
public enum AdvanceEquipSubClass
|
||
{
|
||
Slot_MATAO = 0,
|
||
Slot_MABIAN = 1,
|
||
Slot_MAAN = 2,
|
||
Slot_MADENG = 3,
|
||
}
|
||
|
||
/// <summary>
|
||
/// 法宝子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum MagicSubClass
|
||
{
|
||
GOLD, //暗器
|
||
TREE, //灵药
|
||
WATER, //宝珠
|
||
FIRE, //灵丹
|
||
SOIL, //古董
|
||
}
|
||
|
||
/// <summary>
|
||
/// 装备子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum EquipSubClass
|
||
{
|
||
WEAPON = 1, //武器
|
||
HEAD=2, //头部
|
||
ARMOR=3, //上衣
|
||
GLOVES=4, //手套
|
||
CUFF=5, //手镯
|
||
SHOES=6, //鞋子
|
||
CHARM1=7, //饰品1(吊坠)
|
||
CHARM2=8, //饰品2(戒指)
|
||
SUBWEAPON=9, //副武器
|
||
BELT=10, //腰带
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 强化道具子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum StrengthenSubClass
|
||
{
|
||
QIANGHUA = 1, //强化
|
||
CITIAOXILIAN, //词条洗练
|
||
JICHUXILIAN, //基础洗练
|
||
CITIAOZHIHUAN, //词条置换
|
||
XIANGQIAN, //宝石镶嵌
|
||
JINENG, //角色技能
|
||
KAIKONG, //宝石开孔
|
||
MAGICCLEAR, //宝物洗练
|
||
PK, // PK
|
||
Frenzy,// 狂化
|
||
}
|
||
/// <summary>
|
||
/// 奖励物品子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum PrizeSubClass
|
||
{
|
||
BIND_YUANBAO = 1, //绑定元宝
|
||
JADGE, //灵玉
|
||
BAG, //礼包
|
||
FORCE_MEDIC, //体力药
|
||
EXP, //经验丹
|
||
DOUBLE, //双倍丹
|
||
SPEAKER, //喇叭
|
||
BOX, //宝箱
|
||
BOTTLE = 9, //逆流瓶
|
||
BAOLINGDAN = 10, //保灵丹
|
||
DreamDan = 12, //回梦丹
|
||
EXPBOOK = 15, //经验丹书
|
||
CALLMONSTER, //召唤怪物
|
||
ROSE, //玫瑰
|
||
SILVER, //银两
|
||
BANKNOTES, //银票
|
||
GUILDCONTRIBUTIONDAN, //帮贡丹
|
||
CLEANPKDAN, //清除PK值
|
||
ROLESKILL, //角色技能书
|
||
ADVANCESOULDAN, //进阶魂丹
|
||
ADVANCESPIRITDAN, //进阶灵丹
|
||
LIVINGSKILL = 25, //生活材料
|
||
SYNTHETICMAT, //合成材料
|
||
TITLE, //称号
|
||
FRIEND, //金兰
|
||
SINGLERING = 29, //单身戒指
|
||
MARRIEDRING = 30, //结婚戒指
|
||
DIVORCEDRING = 31, //离婚戒指
|
||
Meridian = 32, //经脉
|
||
LOVEBEAN = 33, //相思豆
|
||
DIAMOND = 34, //钻石
|
||
VIPCOST = 35, //特权激活卡
|
||
MOUNTLEVELADVANCE = 36, //坐骑直升丹
|
||
GUQINLEVELADVANACE, //古琴直升丹
|
||
WINGLEVELADVANCE, //翅膀直升丹
|
||
RINGLEVELADVANCE, //神戒直升丹
|
||
HUNQILEVELADVANCE, //魂器直升丹
|
||
MASKLEVELADVANCE, //面具直升丹
|
||
HUOPAOLEVELADVANCE, //火炮直升丹
|
||
AllSERVERHORN = 45, //全服喇叭
|
||
CROSSSERVERHORN = 46, //跨服喇叭
|
||
EQUIPCOPY = 47, //装备副本道具
|
||
//日常副本道具
|
||
DAILYCOPY1 = 50,
|
||
DAILYCOPY2,
|
||
DAILYCOPY3,
|
||
DAILYCOPY4,
|
||
CHILDGROWTH = 54, //子女成长道具
|
||
CHILDSTUDY = 55, //子女技能道具
|
||
}
|
||
|
||
/// <summary>
|
||
/// 药品子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum MedicSubClass
|
||
{
|
||
HP = 1, //红药
|
||
MP, //蓝药
|
||
ATTR, //属性
|
||
HP_DY, //动态红药
|
||
MP_DY, //动态蓝药
|
||
//HPMP_DY, //动态红蓝药
|
||
}
|
||
/// <summary>
|
||
/// 任务子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum MissionSubClass
|
||
{
|
||
MISSION = 1,
|
||
ITEM,
|
||
LIVINGSKILL,
|
||
SWORN,
|
||
SPRICE,
|
||
}
|
||
/// <summary>
|
||
/// 坐骑子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum MountSubClass
|
||
{
|
||
MOUNT = 1, //坐骑
|
||
}
|
||
/// <summary>
|
||
/// 时装子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum FashionSubClass
|
||
{
|
||
FASHION = 1, //时装
|
||
WEAPON = 2, //武器时装
|
||
CHILDFASHION = 3, //子女时装
|
||
}
|
||
/// <summary>
|
||
/// 伙伴令牌子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum FellowSubClass
|
||
{
|
||
EEP = 1, //宠物经验道具
|
||
LIFT = 2, //宠物寿命道具
|
||
SKILL = 3, //宠物技能书
|
||
XW = 4, //宠物修为道具
|
||
WX = 5, //宠物悟性道具
|
||
CLEAR = 6, //宠物洗练道具
|
||
FELLOW = 7,
|
||
CALL = 8, //宠物召唤道具
|
||
}
|
||
|
||
/// <summary>
|
||
/// 宝图子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum TresureSubClass
|
||
{
|
||
UndefinedLow = 1, //未鉴定
|
||
UndefinedHeight, //高级未鉴定
|
||
PosClearLow, //低级标注坐标
|
||
PosClearMid, //中级标注坐标
|
||
PosClearHeight, //高级标注坐标
|
||
PosClearGold, //黄金级标注坐标
|
||
PosNotClearLow, //低级未标注坐标
|
||
PosNotClearHeight, //高级未标注坐标
|
||
Lottery, //抽奖
|
||
}
|
||
|
||
/// <summary>
|
||
/// 侠客子类(对应commonitem.txt中SubClassID)
|
||
/// </summary>
|
||
public enum SwordsManSubClass
|
||
{
|
||
SWORDSMAN = 1, //侠客令牌
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物品品质
|
||
/// </summary>
|
||
public enum ItemQuality
|
||
{
|
||
QUALITY_INVALID = 0,
|
||
QUALITY_WHITE, //白
|
||
QUALITY_GREEN, //绿
|
||
QUALITY_BLUE, //蓝
|
||
QUALITY_PURPLE, //紫
|
||
QUALITY_PINK, //粉
|
||
QUALITY_GOLD, //金
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物品出售类型
|
||
/// </summary>
|
||
public enum ItemSellMoneyType
|
||
{
|
||
TYPE_INVALID = -1,
|
||
TYPE_COIN = 0,
|
||
TYPE_YUANBAO,
|
||
TYPE_BIND_YUANBAO,
|
||
}
|
||
|
||
public class EquipXilianAttr : ICloneable
|
||
{
|
||
public bool IsBaseAttr = false;
|
||
public Tab_EquipBaptizePropName XilianTab;
|
||
public int mPropID;
|
||
public int PropSubID;
|
||
public int XilianValue;
|
||
public bool IsFixedImg = false;
|
||
|
||
public object Clone()
|
||
{
|
||
EquipXilianAttr newOne = new EquipXilianAttr();
|
||
newOne.IsBaseAttr = this.IsBaseAttr;
|
||
newOne.XilianTab = this.XilianTab;
|
||
newOne.mPropID = this.mPropID;
|
||
newOne.PropSubID = this.PropSubID;
|
||
newOne.XilianValue = this.XilianValue;
|
||
newOne.IsFixedImg = this.IsFixedImg;
|
||
|
||
return newOne;
|
||
}
|
||
}
|
||
|
||
public class GameItem : ICloneable
|
||
{
|
||
/// <summary>
|
||
/// 构造函数
|
||
/// </summary>
|
||
public GameItem()
|
||
{
|
||
m_nDataID = -1;
|
||
m_nSignDataID = GlobeVar.INVALID_GUID;
|
||
m_nGuid = GlobeVar.INVALID_GUID;
|
||
|
||
m_bBindFlag = false;
|
||
m_nStackCount = 0;
|
||
m_nEnchanceLevel = 0;
|
||
m_bEnchanceTotalExp = 0;
|
||
m_nStarLevel = 0;
|
||
m_oDynamicData = new int[DYNAMIC_NUM] { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||
}
|
||
protected const int DYNAMIC_NUM = 8;
|
||
|
||
/// <summary>
|
||
/// IsValid
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public void CleanUp()
|
||
{
|
||
m_nDataID = -1;
|
||
m_nSignDataID = GlobeVar.INVALID_GUID;
|
||
m_nGuid = GlobeVar.INVALID_GUID;
|
||
m_bBindFlag = false;
|
||
m_nStackCount = 0;
|
||
m_nEnchanceLevel = 0;
|
||
m_bEnchanceTotalExp = 0;
|
||
m_nStarLevel = 0;
|
||
for (int i = 0; i < DynamicData.Length; i++)
|
||
{
|
||
DynamicData[i] = 0;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// IsValid
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool IsValid()
|
||
{
|
||
if (m_nDataID >= 0)
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 取得排序ID
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public int SortId()
|
||
{
|
||
if (m_nDataID >= 0)
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.SortId;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 宝石信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public int GemLevel()
|
||
{
|
||
Tab_GemProp gemProp = TableManager.GetGemPropByID(m_nDataID, 0);
|
||
if (gemProp != null)
|
||
{
|
||
return gemProp.GemLevel;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否装备
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool IsEquipMent()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.ClassID == (int)ItemClass.EQUIP)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否法宝
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool IsMagicMent()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.ClassID == (int)ItemClass.MAGICITEM)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public int SellPrice()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.SellPrice;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否进阶装备
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool IsAdvanceMent()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.ClassID == (int)ItemClass.ADVANCEEQUIP)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 装备等级
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public int GetEquipLevel()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.MinLevelRequire;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 取得物品品质
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public ItemQuality GetQuality()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return (ItemQuality)(line.Quality);
|
||
}
|
||
return ItemQuality.QUALITY_INVALID;
|
||
}
|
||
|
||
public int GetProfessionRequire()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.ProfessionRequire;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
//0无1拾取绑定2装备绑定
|
||
public int GetBindType()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.BindType;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
public int GetMinLevelRequire()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.MinLevelRequire;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
public string GetIcon()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.Icon;
|
||
}
|
||
return "";
|
||
}
|
||
public string GetName()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.Name;
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public string GetChatLogName()
|
||
{
|
||
return GameItem.GetChatLogName(m_nDataID, 0);
|
||
}
|
||
|
||
public static string GetChatLogName(int dataID, int strength)
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(dataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (strength > 0)
|
||
{
|
||
return "[" + line.Name + " +" + strength.ToString() + "]";
|
||
}
|
||
else
|
||
{
|
||
return "[" + line.Name + "]";
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public int GetClass()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.ClassID;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
public int GetSubClass()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
return line.SubClassID;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否能售出
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool CanSell()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.CanSell == 1)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否能使用
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool CanUse()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.CanUse == 1)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否能丢弃
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool CanThrow()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.CanThrow == 1)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是不是腰带
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool IsBelt()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.ClassID == (int)ItemClass.EQUIP && line.SubClassID == (int)EquipSubClass.BELT)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsGem()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.ClassID == (int)ItemClass.STRENGTHEN && line.SubClassID == (int)StrengthenSubClass.XIANGQIAN)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 取得物品的品质边框
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetQualityFrame()
|
||
{
|
||
//if (IsEquipMent() || IsMagicMent())
|
||
{
|
||
bool isSuper = false;
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (line != null)
|
||
{
|
||
isSuper = line.SuperEquipment > 0;
|
||
}
|
||
|
||
return Utils.GetItemQualityFrame((int)GetQuality(), isSuper, IsFrenzy);
|
||
}
|
||
//else
|
||
//{
|
||
// return Utils.GetItemQualityFrame((int)ItemQuality.QUALITY_WHITE);
|
||
//}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获得物品品质背景 - 长条形
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetQualityBG()
|
||
{
|
||
return Utils.GetItemQualityBG((int)GetQuality(), IsFrenzy);
|
||
}
|
||
|
||
public string GetItemColorName()
|
||
{
|
||
int nQuality = (int)GetQuality();
|
||
string commonItem = Utils.GetItemQualityColor((int)GetQuality(), IsFrenzy);
|
||
commonItem += TableManager.GetCommonItemByID(DataID, 0).Name;
|
||
commonItem += "</color>";
|
||
|
||
return commonItem;
|
||
}
|
||
|
||
public bool IsFitForPlayer()
|
||
{
|
||
Tab_CommonItem tabItem = TableManager.GetCommonItemByID(DataID, 0);
|
||
if (tabItem == null)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
//int nPlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
||
//if (nPlayerLevel < EquipUseLevel)
|
||
//{
|
||
// return false;
|
||
//}
|
||
|
||
int nPlayerProfession = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession;
|
||
int proLimit = tabItem.ProfessionRequire;
|
||
if (((proLimit >> GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession) & 1) == 0)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
public bool IsEnchanceExpItem()
|
||
{
|
||
Tab_CommonItem tabItem = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (tabItem != null)
|
||
{
|
||
if (tabItem.ClassID == (int)ItemClass.STRENGTHEN && tabItem.SubClassID == (int)StrengthenSubClass.QIANGHUA)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsStarStone()
|
||
{
|
||
Tab_CommonItem tabItem = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (tabItem != null)
|
||
{
|
||
if (tabItem.ClassID == (int)ItemClass.STRENGTHEN && tabItem.SubClassID == (int)StrengthenSubClass.XIANGQIAN)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsFellowSkillBook()
|
||
{
|
||
Tab_CommonItem tabItem = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (tabItem != null)
|
||
{
|
||
if (tabItem.ClassID == (int)ItemClass.STRENGTHEN && tabItem.SubClassID == (int)StrengthenSubClass.JINENG)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsMountItem()
|
||
{
|
||
Tab_CommonItem tabItem = TableManager.GetCommonItemByID(m_nDataID, 0);
|
||
if (tabItem != null)
|
||
{
|
||
if (tabItem.ClassID == (int)ItemClass.MOUNT)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public int GetMountId()
|
||
{
|
||
int nMountID = -1;
|
||
Tab_UsableItem tabItem = TableManager.GetUsableItemByID(m_nDataID, 0);
|
||
if (null == tabItem)
|
||
{
|
||
return nMountID;
|
||
}
|
||
return tabItem.UseParamA;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物品署名ID
|
||
/// </summary>
|
||
protected string m_nSignName;
|
||
public string SignName
|
||
{
|
||
get { return m_nSignName; }
|
||
set { m_nSignName = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物品署名ID
|
||
/// </summary>
|
||
protected ulong m_nSignDataID;
|
||
public ulong SignDataID
|
||
{
|
||
get { return m_nSignDataID; }
|
||
set { m_nSignDataID = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物品ID
|
||
/// </summary>
|
||
protected int m_nDataID;
|
||
public int DataID
|
||
{
|
||
get { return m_nDataID; }
|
||
set { m_nDataID = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 位置index
|
||
/// </summary>
|
||
protected int m_nIndex;
|
||
public int Index
|
||
{
|
||
get { return m_nIndex; }
|
||
set { m_nIndex = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物品GUID
|
||
/// </summary>
|
||
protected UInt64 m_nGuid;
|
||
public UInt64 Guid
|
||
{
|
||
get { return m_nGuid; }
|
||
set { m_nGuid = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定标记
|
||
/// </summary>
|
||
protected bool m_bBindFlag;
|
||
public bool BindFlag
|
||
{
|
||
get { return m_bBindFlag; }
|
||
set { m_bBindFlag = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 堆叠数量
|
||
/// </summary>
|
||
protected int m_nStackCount;
|
||
public int StackCount
|
||
{
|
||
get { return m_nStackCount; }
|
||
set { m_nStackCount = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建时间
|
||
/// </summary>
|
||
protected int m_nCreateTime;
|
||
public int CreateTime
|
||
{
|
||
get { return m_nCreateTime; }
|
||
set { m_nCreateTime = value; }
|
||
}
|
||
|
||
///// <summary>
|
||
///// 上次使用物品的时间(相距1970年,单位:毫秒)
|
||
///// </summary>
|
||
//protected int m_lastUseTime;
|
||
//public int LastUseTime
|
||
//{
|
||
// get { return m_lastUseTime; }
|
||
// set { m_lastUseTime = value; }
|
||
//}
|
||
|
||
/// <summary>
|
||
/// 强化等级
|
||
/// </summary>
|
||
protected int m_nEnchanceLevel;
|
||
public int EnchanceLevel
|
||
{
|
||
get { return m_nEnchanceLevel; }
|
||
set { m_nEnchanceLevel = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 强化经验
|
||
/// </summary>
|
||
protected int m_nEnchanceExp;
|
||
public int EnchanceExp
|
||
{
|
||
get { return m_nEnchanceExp; }
|
||
set { m_nEnchanceExp = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 强化总经验
|
||
/// </summary>
|
||
protected System.Int64 m_bEnchanceTotalExp;
|
||
public System.Int64 EnchanceTotalExp
|
||
{
|
||
get { return m_bEnchanceTotalExp; }
|
||
set { m_bEnchanceTotalExp = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否是狂化装备
|
||
/// </summary>
|
||
protected bool m_isFrenzy;
|
||
public bool IsFrenzy
|
||
{
|
||
get { return m_isFrenzy; }
|
||
set { m_isFrenzy = value; }
|
||
}
|
||
|
||
public bool IsCanFrenzy()
|
||
{
|
||
int total = 0;
|
||
|
||
Tab_CommonItem itemTab = TableManager.GetCommonItemByID(DataID, 0);
|
||
var tab = TableManager.GetEquipFrenzy().Values;
|
||
foreach (var kv in tab)
|
||
{
|
||
if ((int)GetQuality() == kv.Quality
|
||
&& itemTab.MinLevelRequire >= kv.EquipLevelMin
|
||
&& itemTab.MinLevelRequire <= kv.EquipLevelMax)
|
||
{
|
||
total += kv.AddPercent;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return total != 0;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打星等级
|
||
/// </summary>
|
||
protected int m_nStarLevel;
|
||
public int StarLevel
|
||
{
|
||
get { return m_nStarLevel; }
|
||
set { m_nStarLevel = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打星次数
|
||
/// </summary>
|
||
protected int m_nStarTimes;
|
||
public int StarTimes
|
||
{
|
||
get { return m_nStarTimes; }
|
||
set { m_nStarTimes = value; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 动态数据
|
||
/// </summary>
|
||
protected int[] m_oDynamicData;
|
||
public int[] DynamicData
|
||
{
|
||
get { return m_oDynamicData; }
|
||
set { m_oDynamicData = value; }
|
||
}
|
||
|
||
// 物品已经使用次数 - 只有特殊礼包会用到
|
||
private int usedCount = 0;
|
||
public int UsedCount
|
||
{
|
||
get
|
||
{
|
||
return usedCount;
|
||
}
|
||
|
||
set
|
||
{
|
||
if(value >= 0)
|
||
{
|
||
usedCount = value;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 使用次数限制,配合上面的字段使用
|
||
// -1 表示没有该物品使用上限配置
|
||
public int UseLimit
|
||
{
|
||
get
|
||
{
|
||
Tab_UsableItem limit = TableManager.GetUsableItemByID(this.DataID, 0);
|
||
if(limit != null)
|
||
{
|
||
// 特殊礼包3的使用上限在这个表内
|
||
if(GetClass() == (int)ItemClass.GIFTBAG && GetSubClass() == (int)GiftBagSubType.OneAmountTime)
|
||
{
|
||
return limit.UseParamB;
|
||
}
|
||
|
||
// 其他物品的使用上限需要转其他表
|
||
var countLimitTab = TableManager.GetCountLimitByID(limit.LimitId, 0);
|
||
if(countLimitTab != null)
|
||
{
|
||
if (countLimitTab.DayLimit != -1)
|
||
{
|
||
return countLimitTab.DayLimit;
|
||
}
|
||
else if (countLimitTab.WeekLimit != -1)
|
||
{
|
||
return countLimitTab.WeekLimit;
|
||
}
|
||
else if (countLimitTab.MonthLimit != -1)
|
||
{
|
||
return countLimitTab.MonthLimit;
|
||
}
|
||
else
|
||
{
|
||
return countLimitTab.TotalLimit;
|
||
}
|
||
}
|
||
}
|
||
|
||
return -1;
|
||
}
|
||
}
|
||
|
||
// 有限制使用次数的物品
|
||
private int _usedLimitCount = 0;
|
||
public int UsedLimitCount
|
||
{
|
||
get
|
||
{
|
||
return _usedLimitCount;
|
||
}
|
||
|
||
set
|
||
{
|
||
_usedLimitCount = value;
|
||
if (_usedLimitCount < 0)
|
||
_usedLimitCount = 0;
|
||
}
|
||
}
|
||
|
||
public bool IsPlayerEquiped()
|
||
{
|
||
if (false == IsValid())
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (false == IsEquipMent())
|
||
{
|
||
return false;
|
||
}
|
||
|
||
GameItemContainer equipPack = GameManager.gameManager.PlayerDataPool.EquipPack;
|
||
if (equipPack.GetItemByGuid(Guid) == null)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
public bool IsTimeLimitItem()
|
||
{
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(DataID, 0);
|
||
if (line != null)
|
||
{
|
||
if (line.ExistTime != -1)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public int GetLeftTime()
|
||
{
|
||
int nLeftTime = -1;
|
||
Tab_CommonItem line = TableManager.GetCommonItemByID(DataID, 0);
|
||
if (null == line)
|
||
{
|
||
return nLeftTime;
|
||
}
|
||
if (-1 == line.ExistTime)
|
||
{
|
||
return nLeftTime;
|
||
}
|
||
nLeftTime = (line.ExistTime * 60) - (GlobalData.ServerAnsiTime - CreateTime);
|
||
if (nLeftTime < 0)
|
||
{
|
||
nLeftTime = 0;
|
||
}
|
||
return nLeftTime;
|
||
}
|
||
|
||
public bool EquipRefit(int packetType)
|
||
{
|
||
foreach (var attr in ExAttrs)
|
||
{
|
||
if (attr.XilianTab.PropID == (int)PropID.PropertyID.EQUIP_XILIAN_NOREFIT)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
CG_REPAIR_EQUIP packet = (CG_REPAIR_EQUIP)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REPAIR_EQUIP);
|
||
packet.Packtype = packetType;
|
||
packet.Equipguid = Guid;
|
||
|
||
packet.SendPacket();
|
||
|
||
return true;
|
||
}
|
||
|
||
#region Equip attr
|
||
|
||
public const int MAX_GEM_INFO = 6;
|
||
|
||
public int Durable;
|
||
public int CombatValue;
|
||
public List<RoleViewAttrPair.AttrPair> BaseAttrs = new List<RoleViewAttrPair.AttrPair>();
|
||
//public List<RoleViewAttrPair.AttrPair> BaseOriginAttrs = new List<RoleViewAttrPair.AttrPair>();
|
||
public int StrengthLevel;
|
||
public List<int> StrengPerfect = new List<int>();
|
||
public int StrengthPerfect;
|
||
public List<EquipXilianAttr> ExAttrs = new List<EquipXilianAttr>();
|
||
public List<EquipXilianAttr> ExAttrsNew = new List<EquipXilianAttr>();
|
||
public int XilianPoint;
|
||
public int ZhihuanTimes;
|
||
public List<GemData> GemItems = new List<GemData>();
|
||
public int GemSuitID;
|
||
public int GemSuitLevel;
|
||
public int _GemSuit1;
|
||
public int _GemSuit2;
|
||
public int _GemSuit3;
|
||
public int EquipUseLevel;
|
||
public long ShihunTime;
|
||
public long BaohuTime;
|
||
public bool IsRare = false;
|
||
public int EnchanceScore = 0;
|
||
|
||
public int BaseCombat = 0;
|
||
|
||
public RoleViewAttrPair.AttrPair GetBaseAttr(int idx, int value, int exValue)
|
||
{
|
||
int propID = -1;
|
||
int isenhance = -1;
|
||
int propMaxValue = -1;
|
||
float exRate = exValue * 0.0001f;
|
||
if (IsEquipMent())
|
||
{
|
||
Tab_EquipAttr equipAttr = TableManager.GetEquipAttrByID(DataID, 0);
|
||
propID = equipAttr.GetPropIDbyIndex(idx);
|
||
isenhance = equipAttr.GetIsEnchanceAddbyIndex(idx);
|
||
propMaxValue = equipAttr.GetPropValuebyIndex(idx);
|
||
}
|
||
if (IsMagicMent())
|
||
{
|
||
Tab_MagicWeaponBaseAttr equipAttr = TableManager.GetMagicWeaponBaseAttrByID(DataID, 0);
|
||
propID = equipAttr.GetPropIdbyIndex(idx);
|
||
isenhance = equipAttr.GetPropSubIdbyIndex(idx);
|
||
propMaxValue = equipAttr.GetPropValbyIndex(idx);
|
||
}
|
||
RoleViewAttrPair.AttrPair baseAttr = new RoleViewAttrPair.AttrPair((PropID.PropertyID)propID, (int)(value * (1 + exRate)), (int)(propMaxValue * (1 + exRate)));
|
||
baseAttr._OrgValue = value;
|
||
return baseAttr;
|
||
}
|
||
|
||
public RoleViewAttrPair.AttrPair GetBaseAttrCalculated(int idx, int value)
|
||
{
|
||
Tab_EquipAttr equipAttr = TableManager.GetEquipAttrByID(DataID, 0);
|
||
int propID = equipAttr.GetPropIDbyIndex(idx);
|
||
int isenhance = equipAttr.GetIsEnchanceAddbyIndex(idx);
|
||
int propMaxValue = equipAttr.GetPropValuebyIndex(idx);
|
||
|
||
RoleViewAttrPair.AttrPair baseAttr = new RoleViewAttrPair.AttrPair((PropID.PropertyID)propID, value, propMaxValue);
|
||
float strendVal = 1 + GetTotalStrengthVal() * 0.01f;
|
||
if (isenhance > 0)
|
||
{
|
||
baseAttr._Value1 = (int)(baseAttr._Value1 * strendVal);
|
||
}
|
||
return baseAttr;
|
||
}
|
||
|
||
public int GetXilianBasetAttrDelta()
|
||
{
|
||
if (ExAttrsNew.Count == 0)
|
||
return 0;
|
||
|
||
var baptizeTab = TableManager.GetEquipBaptizeByID((int)GetQuality(), 0);
|
||
if (baptizeTab == null)
|
||
return 0;
|
||
|
||
var tabAttr = baptizeTab.GetPropExtAddRatebyIndex(ExAttrs.Count - 1);
|
||
var tabNew = baptizeTab.GetPropExtAddRatebyIndex(ExAttrsNew.Count - 1);
|
||
float attrDelta = tabNew * 100 - tabAttr * 100;
|
||
|
||
return Mathf.RoundToInt(attrDelta);
|
||
}
|
||
|
||
public int GetXilianBasetAttr()
|
||
{
|
||
if (ExAttrs.Count == 0)
|
||
return 0;
|
||
|
||
var baptizeTab = TableManager.GetEquipBaptizeByID((int)GetQuality(), 0);
|
||
if (baptizeTab == null)
|
||
return 0;
|
||
|
||
var tabNew = baptizeTab.GetPropExtAddRatebyIndex(ExAttrs.Count - 1);
|
||
float attrDelta = tabNew * 100;
|
||
|
||
return Mathf.RoundToInt(attrDelta);
|
||
}
|
||
|
||
public EquipXilianAttr GetXilianAttr(int propID,int subID, int value)
|
||
{
|
||
var xilianAttrs = TableManager.GetEquipBaptizePropNameByID(propID);
|
||
if (xilianAttrs == null)
|
||
{
|
||
// return null;
|
||
EquipXilianAttr xilianAttr = new EquipXilianAttr();
|
||
xilianAttr.XilianTab = new Tab_EquipBaptizePropName();
|
||
xilianAttr.mPropID = propID;
|
||
xilianAttr.PropSubID = subID;
|
||
xilianAttr.XilianValue = value;
|
||
//LogModule.ErrorLog("GetXilianAttr error:" + propID + "," + value);
|
||
return xilianAttr;
|
||
}
|
||
if(IsMagicMent())
|
||
{
|
||
EquipXilianAttr xilianAttr = new EquipXilianAttr();
|
||
xilianAttr.mPropID = propID;
|
||
xilianAttr.PropSubID = subID;
|
||
xilianAttr.XilianValue = value;
|
||
return xilianAttr;
|
||
}
|
||
|
||
foreach (var xilian in xilianAttrs)
|
||
{
|
||
if (xilian.PropSubID == subID)
|
||
{
|
||
if (value >= xilian.Min && value <= xilian.Max)
|
||
{
|
||
EquipXilianAttr xilianAttr = new EquipXilianAttr();
|
||
xilianAttr.XilianTab = xilian;
|
||
xilianAttr.mPropID = xilian.PropID;
|
||
xilianAttr.PropSubID = subID;
|
||
xilianAttr.XilianValue = value;
|
||
return xilianAttr;
|
||
}
|
||
}
|
||
}
|
||
if (propID == 0 && subID == 0 && value == 0)
|
||
{
|
||
//全为0,正常情况忽略
|
||
}
|
||
else
|
||
{
|
||
Module.Log.LogModule.ErrorLog("找不到属性对应的名称:" + propID + "," + subID + "," + value);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public bool IsCanXilian()
|
||
{
|
||
if (GetQuality() >= ItemQuality.QUALITY_PURPLE)
|
||
return true;
|
||
return false;
|
||
}
|
||
|
||
public Vector3 GetEquipStarRate(int strengLevel)
|
||
{
|
||
var strengTab = TableManager.GetEquipEnchanceRandRateByID(strengLevel, 0);
|
||
if (strengTab == null)
|
||
return Vector3.zero;
|
||
|
||
if (strengLevel <= 0)
|
||
return Vector3.zero;
|
||
|
||
Vector3 starRate = Vector3.zero;
|
||
if (StrengPerfect.Count >= strengLevel)
|
||
starRate.x = StrengPerfect[strengLevel - 1];
|
||
for (int i = 0; i < strengTab.getWeightCount(); ++i)
|
||
{
|
||
int weight = strengTab.GetWeightbyIndex(i);
|
||
if (starRate.y <= 0 && weight > 0)
|
||
{
|
||
starRate.y = i + 1;
|
||
}
|
||
|
||
if (weight > 0)
|
||
{
|
||
starRate.z = i + 1;
|
||
}
|
||
}
|
||
|
||
return starRate;
|
||
}
|
||
|
||
public int GetEquipMaxDurable()
|
||
{
|
||
Tab_EquipAttr tabItem = TableManager.GetEquipAttrByID(DataID, 0);
|
||
if (tabItem == null)
|
||
return 0;
|
||
|
||
return tabItem.DurablePropValue;
|
||
}
|
||
|
||
public bool IsShihun()
|
||
{
|
||
return ShihunTime > 0;
|
||
}
|
||
|
||
// 最全的名称
|
||
// 获取装备的名称,并且装备强化强度,可追加后缀字符串suffixStr,使suffixStr附带颜色
|
||
public string GetEquipName(bool isBlack = false, string suffixStr = "")
|
||
{
|
||
int nQuality = (int)GetQuality();
|
||
string equipName = GetEquipColorStr(isBlack);
|
||
|
||
if(IsFrenzy)
|
||
{
|
||
equipName += StrDictionary.GetClientDictionaryString("#{5801}");
|
||
}
|
||
|
||
equipName += TableManager.GetCommonItemByID(DataID, 0).Name;
|
||
|
||
var tabprop = TableManager.GetEquipBaptizeByID(nQuality, 0);
|
||
if (tabprop != null && tabprop.PropBarCnt == ExAttrs.Count)
|
||
{
|
||
equipName += StrDictionary.GetClientDictionaryString("#{5342}");
|
||
}
|
||
if (StrengthLevel > 0)
|
||
{
|
||
equipName += "+" + StrengthLevel;
|
||
}
|
||
equipName += suffixStr + "</color>";
|
||
|
||
return equipName;
|
||
}
|
||
|
||
public string GetEquipNameWithoutEnhance(bool isBlack = false, string suffixStr = "")
|
||
{
|
||
int nQuality = (int)GetQuality();
|
||
string equipName = GetEquipColorStr(isBlack);
|
||
|
||
if (IsFrenzy)
|
||
{
|
||
equipName += StrDictionary.GetClientDictionaryString("#{5801}");
|
||
}
|
||
|
||
equipName += TableManager.GetCommonItemByID(DataID, 0).Name;
|
||
|
||
var tabprop = TableManager.GetEquipBaptizeByID(nQuality, 0);
|
||
if (tabprop != null && tabprop.PropBarCnt == ExAttrs.Count)
|
||
{
|
||
equipName += StrDictionary.GetClientDictionaryString("#{5342}");
|
||
}
|
||
|
||
equipName += suffixStr + "</color>";
|
||
|
||
return equipName;
|
||
}
|
||
|
||
public string GetEquipNameWithoutColor(bool isBlack = false)
|
||
{
|
||
int nQuality = (int)GetQuality();
|
||
string equipName = "";
|
||
|
||
equipName += TableManager.GetCommonItemByID(DataID, 0).Name;
|
||
|
||
var tabprop = TableManager.GetEquipBaptizeByID(nQuality, 0);
|
||
if (tabprop != null && tabprop.PropBarCnt == ExAttrs.Count)
|
||
{
|
||
equipName += StrDictionary.GetClientDictionaryString("#{5342}");
|
||
}
|
||
if (StrengthLevel > 0)
|
||
{
|
||
equipName += "+" + StrengthLevel;
|
||
}
|
||
//equipName += "</color>";
|
||
|
||
return equipName;
|
||
}
|
||
|
||
public string GetEquipNameInBrackets(bool isShowBlack)
|
||
{
|
||
int nQuality = (int)GetQuality();
|
||
string equipName = GetEquipColorStr(isShowBlack);
|
||
equipName += "【";
|
||
|
||
if (IsFrenzy)
|
||
{
|
||
equipName += StrDictionary.GetClientDictionaryString("#{5801}");
|
||
}
|
||
|
||
equipName += TableManager.GetCommonItemByID(DataID, 0).Name;
|
||
|
||
var tabprop = TableManager.GetEquipBaptizeByID(nQuality, 0);
|
||
if (tabprop != null && tabprop.PropBarCnt == ExAttrs.Count)
|
||
{
|
||
equipName += StrDictionary.GetClientDictionaryString("#{5342}");
|
||
}
|
||
if (StrengthLevel > 0)
|
||
{
|
||
equipName += "+" + StrengthLevel;
|
||
}
|
||
equipName += "】";
|
||
equipName += "</color>";
|
||
|
||
return equipName;
|
||
}
|
||
|
||
public string GetEquipColorStr(bool isBlack = false)
|
||
{
|
||
if (isBlack)
|
||
return Utils.GetQualityColorInTip((int)GetQuality(), IsFrenzy);
|
||
else if(!IsRare)
|
||
{
|
||
return Utils.GetRareItemNameColor((int)GetQuality(), IsFrenzy);
|
||
}
|
||
else
|
||
{
|
||
return Utils.GetItemQualityColor((int)GetQuality(), IsFrenzy);
|
||
}
|
||
}
|
||
|
||
public int GetSuitID()
|
||
{
|
||
return GemSuitID;
|
||
}
|
||
|
||
public int GetQianghuaPerfectLevel()
|
||
{
|
||
return 1;
|
||
}
|
||
|
||
public int GetUnLockedGemPos()
|
||
{
|
||
for (int i = 0; i < GemItems.Count; ++i)
|
||
{
|
||
if (!GemItems[i].IsOpen)
|
||
return i;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
|
||
public bool IsEquipGem()
|
||
{
|
||
foreach (var gemInfo in GemItems)
|
||
{
|
||
if (gemInfo.IsOpen == true && gemInfo.DataID > 0)
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsEquipGemPos()
|
||
{
|
||
var playerLevel = ObjManager.Instance.MainPlayer.BaseAttr.Level;
|
||
int gemLimit = GetEquipGemSlotCnt();
|
||
for (int i = 0; i < gemLimit; ++i)
|
||
{
|
||
var consumeTab = TableManager.GetEquipPunchConsumeByID(i);
|
||
if (consumeTab.OpenLevel <= playerLevel)
|
||
{
|
||
if (GemItems[i].DataID < 0)
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsCanAnyGemLvUp()
|
||
{
|
||
for (int i = 0; i < GemItems.Count; ++i)
|
||
{
|
||
if (IsCanGemLevelUp(GemItems[i]))
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsCanAnyGemQualityLvUp()
|
||
{
|
||
for (int i = 0; i < GemItems.Count; ++i)
|
||
{
|
||
if (IsCanGemQualityLevelUp(GemItems[i]))
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsCanGemLevelUp(GemData gemData)
|
||
{
|
||
if (gemData.DataID <= 0)
|
||
return false;
|
||
|
||
Tab_GemLvlUpConsume gemLvConsume = TableManager.GetGemLvlUpConsumeByID(gemData.DataID);
|
||
if (gemLvConsume.NextLevel < 0)
|
||
return false;
|
||
|
||
int gemCnt = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(gemLvConsume.ConsumeSubType);
|
||
var playerLevel = ObjManager.Instance.MainPlayer.BaseAttr.Level;
|
||
var levelLimitTab = TableManager.GetGemInlayLvlLimitByID(gemLvConsume.DesLevel + 1, 0);
|
||
if (levelLimitTab == null)
|
||
return false;
|
||
|
||
if (gemLvConsume.ConsumeNum <= gemCnt && levelLimitTab.MinLvl <= playerLevel)
|
||
return true;
|
||
|
||
return false;
|
||
}
|
||
|
||
public bool IsCanGemQualityLevelUp(GemData gemData)
|
||
{
|
||
if (gemData.DataID <= 0)
|
||
return false;
|
||
|
||
Tab_GemLvlUpConsume gemLvConsume = TableManager.GetGemLvlUpConsumeByID(gemData.DataID);
|
||
if (gemLvConsume.NextQuality <= 0)
|
||
return false;
|
||
|
||
var itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(gemLvConsume.QualityConsumeSubType);
|
||
if (itemCount >= gemLvConsume.QualityConsumeNum)
|
||
return true;
|
||
|
||
return false;
|
||
}
|
||
|
||
// 计算当前装备所有强化带来的属性提升百分比
|
||
public int GetTotalStrengthVal()
|
||
{
|
||
int total = GetStrengthVal();
|
||
total += GetFrenzyVal();
|
||
|
||
return total;
|
||
}
|
||
|
||
// 获取装备强化带来的属性提升百分比
|
||
public int GetStrengthVal()
|
||
{
|
||
int total = 0;
|
||
foreach (var strengthInfo in StrengPerfect)
|
||
{
|
||
total += strengthInfo;
|
||
}
|
||
|
||
return total;
|
||
}
|
||
|
||
// 获取装备狂化带来的属性提升百分比
|
||
public int GetFrenzyVal()
|
||
{
|
||
int total = 0;
|
||
|
||
if(IsFrenzy)
|
||
{
|
||
Tab_CommonItem itemTab = TableManager.GetCommonItemByID(DataID, 0);
|
||
var tab = TableManager.GetEquipFrenzy().Values;
|
||
foreach (var kv in tab)
|
||
{
|
||
if ((int)GetQuality() == kv.Quality
|
||
&& itemTab.MinLevelRequire >= kv.EquipLevelMin
|
||
&& itemTab.MinLevelRequire <= kv.EquipLevelMax)
|
||
{
|
||
total += kv.AddPercent;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
return total;
|
||
}
|
||
|
||
public int GetStrengthPerfect()
|
||
{
|
||
return StrengthPerfect;
|
||
}
|
||
|
||
public int GetMagicSlotIndex()
|
||
{
|
||
int subclassid = TableManager.GetCommonItemByID(m_nDataID, 0).SubClassID;
|
||
return subclassid;
|
||
}
|
||
|
||
public int GetOpenedGemPos()
|
||
{
|
||
int openedPos = 0;
|
||
for (int i = 0; i < GemItems.Count; ++i)
|
||
{
|
||
if (GemItems[i].IsOpen)
|
||
{
|
||
++openedPos;
|
||
}
|
||
}
|
||
|
||
return openedPos;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 取得装备在装备槽位的索引
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public int GetEquipSlotIndex()
|
||
{
|
||
if (IsEquipMent())
|
||
{
|
||
int subclassid = TableManager.GetCommonItemByID(m_nDataID, 0).SubClassID;
|
||
EquipSubClass ClassID = (EquipSubClass)subclassid;
|
||
switch (ClassID)
|
||
{
|
||
case EquipSubClass.WEAPON: return (int)EquipPackSlot.Slot_WEAPON;
|
||
case EquipSubClass.HEAD: return (int)EquipPackSlot.Slot_HEAD;
|
||
case EquipSubClass.ARMOR: return (int)EquipPackSlot.Slot_ARMOR;
|
||
case EquipSubClass.GLOVES: return (int)EquipPackSlot.Slot_LEG_GUARD;
|
||
case EquipSubClass.CUFF: return (int)EquipPackSlot.Slot_CUFF;
|
||
case EquipSubClass.SHOES: return (int)EquipPackSlot.Slot_SHOES;
|
||
case EquipSubClass.CHARM1: return (int)EquipPackSlot.Slot_NECK;
|
||
case EquipSubClass.CHARM2: return (int)EquipPackSlot.Slot_RING;
|
||
case EquipSubClass.SUBWEAPON: return (int)EquipPackSlot.Slot_AMULET;
|
||
case EquipSubClass.BELT: return (int)EquipPackSlot.Slot_BELT;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
public int GetEquipGemSlotCnt()
|
||
{
|
||
int subclassid = GetSubClass();
|
||
var equipHoleTab = TableManager.GetGemHoleLimitByID(subclassid);
|
||
if (equipHoleTab != null)
|
||
{
|
||
return equipHoleTab.HoleNum;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
public bool CanEquipItem()
|
||
{
|
||
int nPlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
||
if (nPlayerLevel < EquipUseLevel)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
int equipProfession = GetProfessionRequire();
|
||
if (equipProfession > 0)
|
||
{
|
||
int nPlayerProfession = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession;
|
||
if (((equipProfession >> nPlayerProfession) & 1) == 0)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
public object Clone()
|
||
{
|
||
GameItem newItem = new GameItem();
|
||
|
||
newItem.SignName = this.SignName;
|
||
newItem.SignDataID = this.SignDataID;
|
||
newItem.DataID = this.DataID;
|
||
newItem.Index = this.Index;
|
||
newItem.Guid = this.Guid;
|
||
newItem.BindFlag = this.BindFlag;
|
||
newItem.StackCount = this.StackCount;
|
||
newItem.CreateTime = this.CreateTime;
|
||
newItem.EnchanceLevel = this.EnchanceLevel;
|
||
newItem.EnchanceExp = this.EnchanceExp;
|
||
newItem.EnchanceTotalExp = this.EnchanceTotalExp;
|
||
newItem.IsFrenzy = this.IsFrenzy;
|
||
newItem.StarLevel = this.StarLevel;
|
||
newItem.StarTimes = this.StarTimes;
|
||
newItem.DynamicData = (int[])this.DynamicData.Clone();
|
||
newItem.UsedCount = this.UsedCount;
|
||
newItem.UsedLimitCount = this.UsedLimitCount;
|
||
newItem.Durable = this.Durable;
|
||
newItem.CombatValue = this.CombatValue;
|
||
newItem.BaseAttrs = new List<RoleViewAttrPair.AttrPair>();
|
||
for(int i = 0; i < this.BaseAttrs.Count; ++i)
|
||
{
|
||
newItem.BaseAttrs.Add((RoleViewAttrPair.AttrPair)this.BaseAttrs[i].Clone());
|
||
}
|
||
|
||
newItem.StrengthLevel = this.StrengthLevel;
|
||
newItem.StrengPerfect = new List<int>(this.StrengPerfect);
|
||
newItem.StrengthPerfect = this.StrengthPerfect;
|
||
newItem.ExAttrs = new List<EquipXilianAttr>();
|
||
for (int i = 0; i < this.ExAttrs.Count; ++i)
|
||
{
|
||
newItem.ExAttrs.Add((EquipXilianAttr)this.ExAttrs[i].Clone());
|
||
}
|
||
|
||
newItem.ExAttrsNew = new List<EquipXilianAttr>();
|
||
for (int i = 0; i < this.ExAttrsNew.Count; ++i)
|
||
{
|
||
newItem.ExAttrsNew.Add((EquipXilianAttr)this.ExAttrsNew[i].Clone());
|
||
}
|
||
|
||
newItem.XilianPoint = this.XilianPoint;
|
||
newItem.ZhihuanTimes = this.ZhihuanTimes;
|
||
|
||
newItem.GemItems = new List<GemData>();
|
||
for (int i = 0; i < this.GemItems.Count; ++i)
|
||
{
|
||
newItem.GemItems.Add((GemData)this.GemItems[i].Clone());
|
||
}
|
||
|
||
newItem.GemSuitID = this.GemSuitID;
|
||
newItem.GemSuitLevel = this.GemSuitLevel;
|
||
newItem.EquipUseLevel = this.EquipUseLevel;
|
||
newItem.ShihunTime = this.ShihunTime;
|
||
newItem.BaohuTime = this.BaohuTime;
|
||
newItem.IsRare = this.IsRare;
|
||
newItem.EnchanceScore = this.EnchanceScore;
|
||
newItem.BaseCombat = this.BaseCombat;
|
||
|
||
return newItem;
|
||
}
|
||
|
||
public void UpdateGemSuit()
|
||
{
|
||
int totalLevel = 0;
|
||
_GemSuit1 = -1;
|
||
_GemSuit2 = -1;
|
||
_GemSuit3 = -1;
|
||
for (int i = 0; i< GemItems.Count; ++i)
|
||
{
|
||
if (GemItems[i].IsValid())
|
||
{
|
||
totalLevel += GemItems[i].Level;
|
||
}
|
||
}
|
||
|
||
Tab_GemSuit suit1Tab = null;
|
||
Tab_GemSuit suit2Tab = null;
|
||
Tab_GemSuit suit3Tab = null;
|
||
var gemSuitTables = TableManager.GetGemSuit().Values;
|
||
var gemSuitInlay = TableManager.GetGemSuitInlayByID(DataID, 0);
|
||
|
||
foreach (var gemSuitTab in gemSuitTables)
|
||
{
|
||
//if (gemSuitTab.RequireGemType == 1)
|
||
if (gemSuitInlay.GetSuitIDbyIndex(0) == gemSuitTab.SuitID)
|
||
{
|
||
if (totalLevel >= gemSuitTab.RequireGemLevel
|
||
&& (suit1Tab == null || suit1Tab.SuitLevel < gemSuitTab.SuitLevel))
|
||
{
|
||
//if (gemSuitInlay.GetSuitIDbyIndex(0) == gemSuitTab.SuitID)
|
||
{
|
||
suit1Tab = gemSuitTab;
|
||
_GemSuit1 = gemSuitTab.Id;
|
||
}
|
||
}
|
||
}
|
||
//else if (gemSuitTab.RequireGemType == 2)
|
||
else if (gemSuitInlay.GetSuitIDbyIndex(1) == gemSuitTab.SuitID)
|
||
{
|
||
int gemCnt = 0;
|
||
for (int i = 0; i < GemItems.Count; ++i)
|
||
{
|
||
if (GemItems[i].IsValid()
|
||
&& GemItems[i].GetQuality() >= gemSuitTab.RequireGemQuality
|
||
&& GemItems[i].Level >= gemSuitTab.RequireGemLevel)
|
||
{
|
||
++gemCnt;
|
||
}
|
||
}
|
||
if (gemCnt >= gemSuitTab.RequireGemNum
|
||
&& (suit2Tab == null || gemSuitTab.SuitLevel > suit2Tab.SuitLevel))
|
||
{
|
||
//eliteSuitTab = gemSuitTab;
|
||
//_EliteGemSuit = gemSuitTab.Id;
|
||
if (gemSuitInlay.GetSuitIDbyIndex(1) == gemSuitTab.SuitID)
|
||
{
|
||
suit2Tab = gemSuitTab;
|
||
_GemSuit2 = gemSuitTab.Id;
|
||
}
|
||
}
|
||
}
|
||
//else if (gemSuitTab.RequireGemType == 3)
|
||
else if (gemSuitInlay.GetSuitIDbyIndex(2) == gemSuitTab.SuitID)
|
||
{
|
||
int gemCnt = 0;
|
||
for (int i = 0; i < GemItems.Count; ++i)
|
||
{
|
||
if (GemItems[i].IsValid()
|
||
&& GemItems[i].GetQuality() >= gemSuitTab.RequireGemQuality
|
||
&& GemItems[i].Level >= gemSuitTab.RequireGemLevel)
|
||
{
|
||
++gemCnt;
|
||
}
|
||
}
|
||
if (gemCnt >= gemSuitTab.RequireGemNum
|
||
&& (suit3Tab == null || gemSuitTab.SuitLevel > suit3Tab.SuitLevel))
|
||
{
|
||
//eliteSuitTab = gemSuitTab;
|
||
//_EliteGemSuit = gemSuitTab.Id;
|
||
if (gemSuitInlay.GetSuitIDbyIndex(2) == gemSuitTab.SuitID)
|
||
{
|
||
suit3Tab = gemSuitTab;
|
||
_GemSuit3 = gemSuitTab.Id;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
|
||
}
|
||
|