int Equip(CEquipment pEquip, EEquipPos ePos) { if (!ItemCreator.MIsEquipment(pEquip.GetItemTypeID())) { return(1); } if (pEquip.m_pEquipProto.byLevel > m_nLevel) { return(2); } CEquipment pSrc = (CEquipment)m_pEquipment.GetPos((Int16)ePos); if (pSrc != null) { // switch equip 's pos CItemMgr.Inst.m_pPocket.Remove(pEquip.GetItemID()); m_pEquipment.Equip(pEquip, (Int16)ePos); ProcEquipEffect(pEquip, pSrc); } else { CItemMgr.Inst.m_pPocket.Remove(pEquip.GetItemID()); m_pEquipment.Equip(pEquip, (Int16)ePos); ProcEquipEffect(pEquip, null); } //if( CNGUISys.Inst != null ) //{ // CNGUISys.Inst.OnUpdateCharacterALL(); //} return(0); }
void ShowRewardItem(GameObject item, uint dwTypeID, int nNum) { if (ItemCreator.MIsEquipment(dwTypeID)) { tagEquipProto pEquipProto = null; CProtoManager.inst.m_mapEquip.TryGetValue(dwTypeID, out pEquipProto); if (pEquipProto != null) { Transform pIcon = item.transform.Find("Icon"); if (pIcon != null) { UIAtlas tu = Resources.Load("GameIcon", typeof(UIAtlas)) as UIAtlas; UnityEngine.GameObject ctrl = pIcon.gameObject; ctrl.GetComponent <UISprite>().atlas = tu; ctrl.GetComponent <UISprite>().spriteName = pEquipProto.strIcon; } Transform pNum = item.transform.Find("num"); if (pNum != null) { UnityEngine.GameObject ctrl = pNum.gameObject; ctrl.GetComponent <UILabel>().text = nNum.ToString(); } } } else { tagItemProto pProto = null; CProtoManager.inst.m_mapItem.TryGetValue(dwTypeID, out pProto); if (pProto != null) { Transform pIcon = item.transform.Find("Icon"); if (pIcon != null) { UIAtlas tu = Resources.Load("GameIcon", typeof(UIAtlas)) as UIAtlas; UnityEngine.GameObject ctrl = pIcon.gameObject; ctrl.GetComponent <UISprite>().atlas = tu; ctrl.GetComponent <UISprite>().spriteName = pProto.strIcon; } Transform pNum = item.transform.Find("num"); if (pNum != null) { UnityEngine.GameObject ctrl = pNum.gameObject; ctrl.GetComponent <UILabel>().text = nNum.ToString(); } } } }
public bool AddItem2Bag(uint dwTypeID, Int16 nNum, EItemQuality eQ, int nCmd) { if (m_pPocket.IsFull()) { return(false); } CItem pNewItem = null; Int16 nBagSpace = (Int16)CalSpaceUsed(dwTypeID, nNum); // check bag free grid is enongh int nFreeSpace = m_pPocket.GetFreeSpaceSize(); if (nFreeSpace < nBagSpace - 1) { return(false); } for (int i = 0; i < nBagSpace; i++) { tagItem pNew = ItemCreator.Create(dwTypeID, nNum, EItemQuality.EIQ_White, 0); if (pNew != null) { if (ItemCreator.MIsEquipment(dwTypeID)) { pNewItem = new CEquipment((tagEquip)pNew); } else { pNewItem = new CItem(pNew); } } if (pNewItem != null) { AddItem(m_pPocket, pNewItem, nNum); } } return(true); }
//---------------------------------------------------------------------- int CalSpaceUsed(uint dwTypeID, Int16 nNum) { tagItemProto pProto = null; if (ItemCreator.MIsEquipment(dwTypeID)) { tagEquipProto pEquipProto = null; CProtoManager.inst.m_mapEquip.TryGetValue(dwTypeID, out pEquipProto); pProto = (tagItemProto)pEquipProto; } else { CProtoManager.inst.m_mapItem.TryGetValue(dwTypeID, out pProto); } if (pProto == null) { return(-1); } int nUseSpace = 0; if (nNum < pProto.nMaxLapNum) { nUseSpace = 1; } else { if (pProto.nMaxLapNum <= 0) { pProto.nMaxLapNum = 1; } nUseSpace = (1 == pProto.nMaxLapNum ? nNum : (nNum - 1) / pProto.nMaxLapNum); } return(nUseSpace); }