public void GetSameItemList(uint dwTypeID) { for (int i = 0; i < m_Container.Count; i++) { CItem pItem = m_Container[i]; if (pItem != null && pItem.GetItemTypeID() == dwTypeID) { m_samelist.Add(pItem); } } }
public void Removes(uint dwTypeID) { for (int i = 0; i < m_Container.Count; i++) { CItem pItem = m_Container[i]; if (pItem != null && pItem.GetItemTypeID() == dwTypeID) { Remove(pItem.GetPos()); } } }
public CItem GetItemByTypeID(uint dwTypeID) { for (int i = 0; i < m_Container.Count; i++) { CItem pItem = m_Container[i]; if (pItem != null && pItem.GetItemTypeID() == dwTypeID) { return(pItem); } } return(null); }
public int GetItemNumByTypeID(uint dwTypeID) { int nRet = 0; for (int i = 0; i < m_Container.Count; i++) { CItem pItem = m_Container[i]; if (pItem != null && pItem.GetItemTypeID() == dwTypeID) { nRet += pItem.GetItemNum(); } } return(nRet); }
public void Removes(uint dwTypeID, int nNum) { m_samelist.Clear(); GetSameItemList(dwTypeID); for (int i = 0; i < m_samelist.Count; i++) { CItem pItem = m_samelist[i]; if (pItem == null && pItem.GetItemTypeID() == dwTypeID) { if (pItem.GetItemNum() < nNum) { nNum -= pItem.GetItemNum(); Remove(pItem.GetPos()); } else if (pItem.GetItemNum() == nNum) { nNum = 0; Remove(pItem.GetPos()); break; } } } }
public bool Add(CItem pItem) { Int16 n16CanLap = 0; Int16 n16HaveAdd = 0; if (m_eType == EItemConType.EICT_Bag || m_eType == EItemConType.EICT_RoleWare) { if (pItem.m_pProto.nMaxLapNum > 1) { m_samelist.Clear(); GetSameItemList(pItem.GetItemTypeID()); for (int i = 0; i < m_samelist.Count; i++) { CItem pConItem = m_samelist[i]; n16CanLap = (Int16)(pConItem.m_pProto.nMaxLapNum - pConItem.GetItemNum()); if (n16CanLap > 0) { n16HaveAdd = (Int16)(n16HaveAdd + n16CanLap); if (n16HaveAdd > pItem.GetItemNum()) { pConItem.m_data.n16Num += pItem.m_data.n16Num; n16HaveAdd = pItem.GetItemNum(); break; } else { pConItem.m_data.n16Num += n16CanLap; } } } } int NotHaveAdd = pItem.GetItemNum() - n16HaveAdd; if (NotHaveAdd > 0) { Int16 iPos = GetFreeGrid(); Add(pItem, iPos); } } else { if (pItem.m_pProto.nMaxLapNum > 1) { m_samelist.Clear(); GetSameItemList(pItem.GetItemTypeID()); for (int i = 0; i < m_samelist.Count; i++) { CItem pConItem = m_samelist[i]; n16CanLap = (Int16)(pConItem.m_pProto.nMaxLapNum - pConItem.GetItemNum()); if (n16CanLap >= pItem.GetItemNum()) { pConItem.m_data.n16Num += pItem.m_data.n16Num; n16HaveAdd = pItem.GetItemNum(); } } } if (0 == n16HaveAdd) { Int16 ipos = GetFreeGrid(); Add(pItem, ipos); } } return(true); }