/// <summary> /// 克隆一个深拷贝对象 /// 其中m_ItemInfo为静态数据,做浅拷贝 /// </summary> public virtual object Clone() { CItemBase res = new CItemBase(); this.CopyTo(res); return((object)res); }
public float m_nTotalScore = 0; //物品的属性分,用于T台秀装备显示的排序和不显示剔除等逻辑; /// <summary> /// 将当前对象的所有元素深拷贝到toObj中。 /// </summary> protected virtual void CopyTo(object toObj) { CItemBase itemBase = toObj as CItemBase; if (itemBase != null) { itemBase.m_nColumn = this.m_nColumn; itemBase.m_nIndex = this.m_nIndex; itemBase.m_nUseTimes = this.m_nUseTimes; itemBase.m_nCount = this.m_nCount; itemBase.m_nMatune = this.m_nMatune; // CItemInfo从静态数据中加载,直接拷贝引用 itemBase.m_ItemInfo = this.m_ItemInfo; } }
public static CItemBase CreateItem(CItemInfo pItemInfo) { CItemBase pItem = null; if (pItemInfo == null) { return(pItem); } if (pItemInfo.IsEquip()) { pItem = CEquipItem.CreateEquip(pItemInfo); } else { pItem = new CItemBase(); if (pItem != null) { pItem.ItemInfo = pItemInfo; } } return(pItem); }