Пример #1
0
        /// <summary>
        /// 克隆一个深拷贝对象
        /// </summary>
        //public virtual object Clone()
        //{
        //    PlayerItem res = new PlayerItem();

        //    this.CopyTo(res);

        //    return res;
        //}

        /// <summary>
        /// 将当前对象的所有元素深拷贝到toObj对象中。
        /// </summary>
        //protected virtual void CopyTo(object toObj)
        //{
        //    PlayerItem to = toObj as PlayerItem;

        //    if (to != null)
        //    {
        //        to.m_AllItem = new List<CItemBase>[this.m_AllItem.Length];
        //        for (int i = 0; i < this.m_AllItem.Length; i++)
        //        {
        //            to.m_AllItem[i] = new List<CItemBase>();

        //            List<CItemBase> list = this.m_AllItem[i];
        //            for (int j = 0; j < list.Count; j++)
        //            {
        //                CItemBase itemBase = null;
        //                if (list[j] != null)
        //                {
        //                    itemBase = (CItemBase)(list[j].Clone());
        //                }
        //                to.m_AllItem[i].Add(itemBase);
        //            }
        //        }

        //        for (int i = 0; i < this.m_DefaultEquip.Length; i++)
        //        {
        //            if (m_DefaultEquip[i] != null)
        //            {
        //                to.m_DefaultEquip[i] = (CEquipItem)(m_DefaultEquip[i].Clone());
        //            }
        //        }

        //        for (int i = 0; i < this.m_ListClothEffectHandbookProgress.Count; i++)
        //        {
        //            ClothEffectHandbookProgress progress = m_ListClothEffectHandbookProgress[i];
        //            ClothEffectHandbookProgress clone = null;
        //            if (progress != null)
        //            {
        //                clone = (ClothEffectHandbookProgress)(progress.Clone());
        //            }
        //            to.m_ListClothEffectHandbookProgress.Add(clone);
        //        }

        //        for (int i = 0; i < this.m_ListSevenColorInfo.Count; i++)
        //        {
        //            ClothEffectSevenColorProgress progress = this.m_ListSevenColorInfo[i];
        //            ClothEffectSevenColorProgress clone = null;
        //            if (progress != null)
        //            {
        //                clone = (ClothEffectSevenColorProgress)(progress.Clone());
        //            }
        //            to.m_ListSevenColorInfo.Add(clone);
        //        }
        //    }
        //}

        //public virtual void SerializeItem(NetReadBuffer DataIn)
        //{
        //    ushort itemCount = DataIn.GetUShort();
        //    if (itemCount > 0)
        //    {
        //        for (ushort i = 0; i < itemCount; ++i)
        //        {
        //            uint nItemType = DataIn.GetUInt();
        //            ushort nColumn = DataIn.GetUShort();
        //            ushort nGrid = DataIn.GetUShort();

        //            byte size = 0;
        //            size = DataIn.GetByte();
        //            CItemInfo itemInfo = StaticData.ItemDataMgr.GetByID(nItemType);
        //            CItemBase itemBase = CItemBase.CreateItem(itemInfo);
        //            if (itemBase != null)
        //            {
        //                itemBase.doDecode(DataIn);
        //                itemBase.m_nColumn = nColumn;
        //                itemBase.m_nIndex = nGrid;

        //                PrepareGrid((Item_Column)nColumn, nGrid);
        //                UpdateItem((Item_Column)nColumn, nGrid, itemBase);
        //            }
        //            else
        //            {
        //                string s = "PlayerItem Docode Error_" + "ItemType: " + nItemType + " Not Exist in iteminfo";
        //                int curPos = DataIn.getPostion();
        //                curPos += size;
        //                DataIn.setMaxDataPostion(curPos);
        //                DataIn.setPostion(curPos);
        //                GameMsg_C2S_Msg_BugReport msg = new GameMsg_C2S_Msg_BugReport();
        //                msg.m_BugList = s;
        //                NetworkMgr.SendMsg(msg);
        //            }
        //        }

        //        CheckNeedArrangeItem();
        //    }
        //}

        public void InitItemList(ushort nBadgeGridNum)
        {
            for (Item_Column column = 0; column < Item_Column.ItemColumn_MaxNumber; ++column)
            {
                ushort maxCount = 0;
                if (column == Item_Column.ItemPlayerColumn_Badge)
                {
                    maxCount = nBadgeGridNum;
                }
                else if (column == Item_Column.ItemPlayerColumn_ClothCapsule)
                {
                    maxCount = (ushort)ItemCloth_Type.ItemCloth_Type_MaxNumber;
                }
                else if (column == Item_Column.ItemPlayerColumn_WeddingRing)
                {
                    maxCount = 1;
                }

                List <CItemBase> itemList = new List <CItemBase>();
                for (ushort itemGrid = 0; itemGrid < maxCount; ++itemGrid)
                {
                    itemList.Add(null);
                }

                m_AllItem[(int)column] = itemList;
            }
        }
Пример #2
0
        public List <CEquipItem> GetItemListByClothType(ItemCloth_Type clothType)
        {
            List <CEquipItem> listItem = new List <CEquipItem>();

            CItemBase  item      = null;
            CEquipItem equipItem = null;

            for (Item_Column column = 0; column < Item_Column.ItemBagColumn_Storage + 1; ++column)
            {
                List <CItemBase> itemBaseList = GetItemList(column);
                if (itemBaseList != null && itemBaseList.Count > 0)
                {
                    int baseCount = itemBaseList.Count;
                    for (int i = 0; i < baseCount; ++i)
                    {
                        item = itemBaseList[i];
                        if (item != null && item.IsEquip())
                        {
                            equipItem = item as CEquipItem;
                            if (equipItem != null)
                            {
                                if (equipItem.GetClothPos() == (byte)clothType)
                                {
                                    listItem.Add(equipItem);
                                }
                            }
                        }
                    }
                }
            }

            return(listItem);
        }
Пример #3
0
        public uint GetItemTotalCountInBag(uint itemType)
        {
            uint count = 0;

            for (Item_Column column = 0; column < Item_Column.ItemColumn_MaxNumber; ++column)
            {
                if (column != Item_Column.ItemPlayerColumn_ClothCapsule && column != Item_Column.ItemBagColumn_Storage)
                {
                    List <CItemBase> itemBaseList = GetItemList(column);
                    if (itemBaseList != null && itemBaseList.Count > 0)
                    {
                        int baseCount = itemBaseList.Count;
                        for (int i = 0; i < baseCount; ++i)
                        {
                            CItemBase itemBase = itemBaseList[i];
                            if (itemBase != null && itemBase.IsValid() && itemBase.ItemInfo.m_nType == itemType)
                            {
                                count += itemBase.m_nCount;
                            }
                        }
                    }
                }
            }

            return(count);
        }
Пример #4
0
        /// <summary>
        /// 克隆一个深拷贝对象
        /// </summary>
        //public override object Clone()
        //{
        //    MainPlayerItem res = new MainPlayerItem();

        //    this.CopyTo(res);

        //    return res;
        //}

        /// <summary>
        /// 将当前对象的所有元素深拷贝到toObj对象中。
        /// </summary>
        //protected override void CopyTo(object toObj)
        //{
        //    MainPlayerItem to = toObj as MainPlayerItem;

        //    if (to != null)
        //    {
        //        base.CopyTo(toObj);

        //        to.m_fElapseTime = this.m_fElapseTime;
        //    }
        //}

        //public override void SerializeItem(NetReadBuffer DataIn)
        //{
        //    base.SerializeItem(DataIn);

        //    ushort defaultClothCount = DataIn.GetUShort();
        //    for (int i = 0; i < defaultClothCount; ++i)
        //    {
        //        ushort column = DataIn.GetUShort();
        //        ushort grid = DataIn.GetUShort();

        //        CItemBase itembase = GetItemByPos((Item_Column)column, grid);
        //        if (itembase != null)
        //        {
        //            m_DefaultEquip[itembase.ItemInfo.GetClothPos()] = (CEquipItem)itembase;
        //        }
        //    }

        //    ushort itemCount = DataIn.GetUShort();
        //    for (int i = 0; i < itemCount; ++i)
        //    {
        //        ClothEffectHandbookProgress info = new ClothEffectHandbookProgress();
        //        info.doDecode(DataIn);
        //        m_ListClothEffectHandbookProgress.Add(info);
        //    }

        //    itemCount = DataIn.GetUShort();
        //    for (int i = 0; i < itemCount; ++i)
        //    {
        //        ClothEffectSevenColorProgress info = new ClothEffectSevenColorProgress();
        //        info.doDecode(DataIn);
        //        m_ListSevenColorInfo.Add(info);
        //    }

        //    m_nCollectCount = DataIn.GetUInt();
        //    m_nBrilliantCount = DataIn.GetUInt();
        //}

        public override void UpdateEx()
        {
            m_fElapseTime += Time.deltaTime;

            mIntervalcount = (int)(m_fElapseTime / CommonDef.UPDATE_INTERVAL_ITEM);
            if (mIntervalcount > 0)
            {
                mElapsetime    = CommonDef.UPDATE_INTERVAL_ITEM * mIntervalcount;
                m_fElapseTime -= mElapsetime;

                for (Item_Column column = 0; column <= Item_Column.ItemBagColumn_Storage; ++column)
                {
                    mItemList = m_AllItem[(int)column];
                    for (int i = 0; i < mItemList.Count; ++i)
                    {
                        mItemBase = mItemList[i];
                        if (mItemBase != null && mItemBase.m_nMatune >= 0)
                        {
                            if (mItemBase.m_nMatune > mElapsetime)
                            {
                                mItemBase.m_nMatune -= mElapsetime;
                            }
                            else
                            {
                                mItemBase.m_nMatune = 0;
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
        public bool IsGridValid(Item_Column itemColumn, ushort itemGrid)
        {
            if (IsColumnValid(itemColumn) && itemGrid < m_AllItem[(ushort)itemColumn].Count)
            {
                return(true);
            }

            return(false);
        }
Пример #6
0
        public bool IsColumnValid(Item_Column itemColumn)
        {
            if (itemColumn <= Item_Column.ItemColumn_Begin || itemColumn >= Item_Column.ItemColumn_MaxNumber)
            {
                return(false);
            }

            return(true);
        }
Пример #7
0
        public CItemBase GetItemByPos(Item_Column column, ushort grid)
        {
            if (IsGridValid(column, grid))
            {
                return(m_AllItem[(ushort)column][grid]);
            }

            return(null);
        }
Пример #8
0
        public List <CItemBase> GetItemList(Item_Column column)
        {
            if (IsColumnValid(column))
            {
                return(m_AllItem[(ushort)column]);
            }

            return(null);
        }
Пример #9
0
 public void PrepareGrid(Item_Column itemColumn, ushort itemGrid)
 {
     if (IsColumnValid(itemColumn))
     {
         int nCount = itemGrid - m_AllItem[(ushort)itemColumn].Count + 1;
         for (int i = 0; i < nCount; ++i)
         {
             m_AllItem[(ushort)itemColumn].Add(null);
         }
     }
 }
Пример #10
0
        public virtual void UpdateItem(Item_Column column, ushort grid, CItemBase itemBase)
        {
            if (IsGridValid(column, grid))
            {
                //蛋道具 加入data;
                m_AllItem[(ushort)column][grid] = itemBase;
            }

            if (itemBase != null)
            {
                if (itemBase.IsVehicle() && !m_ListVehicleItemID.Contains(itemBase.ItemInfo.m_nType))
                {
                    m_ListVehicleItemID.Add(itemBase.ItemInfo.m_nType);
                }
            }
        }
Пример #11
0
        public CItemBase GetItemByType(uint itemType)
        {
            CItemBase itemBase = null;

            for (Item_Column column = 0; column < Item_Column.ItemColumn_MaxNumber; ++column)
            {
                if (column != Item_Column.ItemPlayerColumn_ClothCapsule)
                {
                    itemBase = GetItemByType(column, itemType);
                    if (itemBase != null)
                    {
                        break;
                    }
                }
            }

            return(itemBase);
        }
Пример #12
0
        public CItemBase GetItemByType(Item_Column column, uint itemType)
        {
            List <CItemBase> itemList = GetItemList(column);

            if (itemList != null)
            {
                int itemCount = itemList.Count;
                for (int i = 0; i < itemCount; ++i)
                {
                    CItemBase itemBase = itemList[i];
                    if (itemBase != null && itemBase.IsValid() && itemBase.ItemInfo.m_nType == itemType)
                    {
                        return(itemBase);
                    }
                }
            }

            return(null);
        }
Пример #13
0
        //the equiped items of main player will not be serialized in separate array, use the flag IsEquiped to check
        public override void UpdateItem(Item_Column column, ushort grid, CItemBase itemBase)
        {
            if (column == Item_Column.ItemBagColumn_ClothCapsule)
            {
                CEquipItem oldEquip = (CEquipItem)m_AllItem[(int)column][grid];
                base.UpdateItem(column, grid, itemBase);

                if (oldEquip != null && oldEquip.IsEquiped)
                {
                    m_AllItem[(int)Item_Column.ItemPlayerColumn_ClothCapsule][oldEquip.GetClothPos()] = null;
                }

                CEquipItem newEquip = itemBase as CEquipItem;
                if (newEquip != null && newEquip.IsEquiped)
                {
                    m_AllItem[(int)Item_Column.ItemPlayerColumn_ClothCapsule][newEquip.GetClothPos()] = newEquip;
                }
            }
            else
            {
                base.UpdateItem(column, grid, itemBase);
                CheckNeedArrangeItem();
            }
        }