コード例 #1
0
    public CItemBase GetItem(int nIdx, out int nCount, bool isOutPut = false)
    {
        nCount = 1;

        if (m_boxInfo == null)
        {
            return(null);
        }

        if (m_boxInfo == null)
        {
            return(null);
        }

        if (nIdx < 0 || nIdx >= m_boxInfo.itemList.Count)
        {
            return(null);
        }

        CItemBase item = m_boxInfo.itemList[nIdx].item;

        if (isOutPut)
        {
            nCount = m_boxInfo.itemList[nIdx].count;
            m_boxInfo.itemList.RemoveAt(nIdx);
        }

        return(item);
    }
コード例 #2
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        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);
        }
コード例 #3
0
    public CItemBase ItemUse(int nIdx)
    {
        if (nIdx < 0 || nIdx >= InventoryInfo.itemList.Count)
        {
            return(null);
        }

        if (InventoryInfo.itemList[nIdx] == null)
        {
            return(null);
        }

        CItemBase item = InventoryInfo.itemList[nIdx].item;

        InventoryInfo.itemList[nIdx].count -= 1;

        if (InventoryInfo.itemList[nIdx].count < 1)
        {
            InventoryInfo.itemList.RemoveAt(nIdx);

            CurItemSelect = 0;
        }

        return(item);
    }
コード例 #4
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        /// <summary>
        /// 获取座驾列表
        /// </summary>
        public List <CItemBase> GetVehicleList()
        {
            List <CItemBase> tempItemList = new List <CItemBase>();
            List <uint>      tempDelList  = new List <uint>();

            for (int i = 0; i < m_ListVehicleItemID.Count; ++i)
            {
                uint      tempItemID = m_ListVehicleItemID[i];
                CItemBase tempItem   = GetItemByType(tempItemID);
                if (tempItem != null)
                {
                    tempItemList.Add(tempItem);
                }
                else
                {
                    tempDelList.Add(tempItemID);
                }
            }

            for (int i = 0; i < tempDelList.Count; ++i)
            {
                uint tempItemID = tempDelList[i];
                if (m_ListVehicleItemID.Contains(tempItemID))
                {
                    m_ListVehicleItemID.Remove(tempItemID);
                }
            }

            return(tempItemList);
        }
コード例 #5
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        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);
        }
コード例 #6
0
    public CSpellItem SpellUse(int nIdx)
    {
        if (nIdx >= InventoryInfo.spellList.Count)
        {
            return(null);
        }

        if (InventoryInfo.spellList[nIdx] == null)
        {
            return(null);
        }

        CItemBase item = InventoryInfo.spellList[nIdx].item;

        InventoryInfo.spellList[nIdx].count -= 1;

        if (InventoryInfo.spellList[nIdx].count < 1)
        {
            InventoryInfo.spellList.RemoveAt(nIdx);

            CurSpellSelect = 0;
        }

        return(item as CSpellItem);
    }
コード例 #7
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        /// <summary>
        /// 检查是否需要整理背包
        /// </summary>
        public void CheckNeedArrangeItem()
        {
            m_bNeedArrange = false;
            List <uint> tmpListItemType = new List <uint>();
            // 需要整理堆叠的物品列表-道具类
            List <CItemBase> gtList = GetItemList(Item_Column.ItemBagColumn_Expandable);

            for (int i = 0; i < gtList.Count; ++i)
            {
                CItemBase gtItem = gtList[i];
                if (gtItem != null && gtItem.ItemInfo != null && gtItem.ItemInfo.m_nMaxStackNumber > 1)
                {
                    uint tmpItemType = gtItem.ItemInfo.m_nType;
                    // 检查物品数量是否达到物品最大堆叠数
                    if (gtItem.Count < gtItem.ItemInfo.m_nMaxStackNumber)
                    {
                        // 未到达堆叠数的记录物品类型
                        // 如果列表已经有该物品类型说明有多个栏位的物品可以堆叠在一起
                        if (tmpListItemType.Contains(tmpItemType))
                        {
                            m_bNeedArrange = true;
                            break;
                        }
                        else
                        {
                            tmpListItemType.Add(tmpItemType);
                        }
                    }
                }
            }
        }
コード例 #8
0
 void PooledThis()
 {
     m_item            = null;
     m_itemText.text   = "Get Item";
     m_itemIcon.sprite = null;
     CObjectPool.Inst.PooledItem(gameObject, this);
 }
コード例 #9
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;
                            }
                        }
                    }
                }
            }
        }
コード例 #10
0
    public void InputEquip(CItemBase equipmentBase)
    {
        if (m_boxInfo == null)
        {
            return;
        }

        IEquipment equipment = equipmentBase as IEquipment;

        if (equipment == null)
        {
            return;
        }
        if (equipmentBase.ItemIdx <= 0)
        {
            return;
        }

        m_equipments.Add(equipment);

        Data.EquipmentBoxInfo equipmentInfo = new Data.EquipmentBoxInfo();

        equipmentInfo.partsType = equipment.PartsType;
        equipmentInfo.index     = equipmentBase.ItemIdx;

        m_boxInfo.equipmentList.Add(equipmentInfo);
    }
コード例 #11
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        public ushort GetItemColumn(uint itemType)
        {
            ushort    column   = 0;
            CItemBase itemBase = GetItemByType(itemType);

            if (itemBase != null)
            {
                column = itemBase.m_nColumn;
            }

            return(column);
        }
コード例 #12
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        public ushort GetItemSlot(uint itemType)
        {
            ushort    slot     = 0;
            CItemBase itemBase = GetItemByType(itemType);

            if (itemBase != null)
            {
                slot = itemBase.m_nIndex;
            }

            return(slot);
        }
コード例 #13
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        public uint GetWeddingRingID()
        {
            uint ringId = 0;

            CItemBase item = m_AllItem[(int)Item_Column.ItemPlayerColumn_WeddingRing][0];

            if (item != null)
            {
                ringId = item.ItemInfo.m_nType;
            }

            return(ringId);
        }
コード例 #14
0
        void LoadBoxInfo()
        {
            //TextAsset boxText = Resources.Load<TextAsset>("Data/BoxInfo");
            string boxText = File.ReadAllText(Application.streamingAssetsPath + "/Data/BoxInfo.xml");

            //if (inventoryText == null)
            //    return;

            XmlDocument document = new XmlDocument();

            document.LoadXml(boxText);
            //document.LoadXml(boxText.text);

            XmlNode     root  = document.SelectSingleNode("BoxInfo");
            XmlNodeList items = root.SelectNodes("Items/Item");

            for (int i = 0; i < items.Count; i++)
            {
                int nIdx   = int.Parse(items[i].SelectSingleNode("index").InnerText);
                int nCount = int.Parse(items[i].SelectSingleNode("count").InnerText);

                CItemBase item = m_itemContainier.GetItem(nIdx);

                if (item == null)
                {
                    continue;
                }

                ItemData itemData = new ItemData();
                itemData.item  = item;
                itemData.count = nCount;

                m_boxInfo.itemList.Add(itemData);
            }

            XmlNode     equips = root.SelectSingleNode("Equips");
            XmlNodeList parts  = equips.SelectNodes("Parts");

            for (int i = 0; i < parts.Count; i++)
            {
                XmlNode type  = parts[i].SelectSingleNode("partsType");
                XmlNode index = parts[i].SelectSingleNode("index");

                EquipmentBoxInfo equipment = new EquipmentBoxInfo();

                equipment.partsType = (PartsType)System.Enum.Parse(typeof(PartsType), type.InnerText);
                equipment.index     = int.Parse(index.InnerText);

                m_boxInfo.equipmentList.Add(equipment);
            }
        }
コード例 #15
0
        public CItemBase GetItem(int nIdx)
        {
            if (m_itemData.Count <= nIdx)
            {
                return(null);
            }

            string path = "Scriptable/Item/";

            path += m_itemData[nIdx];

            CItemBase item = Resources.Load <CItemBase>(path);

            return(item);
        }
コード例 #16
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        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);
                }
            }
        }
コード例 #17
0
    public void SetItemData(CItemBase itemData)
    {
        if (m_collider != null)
        {
            m_collider.enabled = true;
        }

        m_item = itemData;

        if (m_item != null)
        {
            m_itemText.text   = m_item.Name;
            m_itemIcon.sprite = m_item.IconImg;
        }

        m_lossTime = Random.Range(10f, 15f);
        m_pastTime = 0f;
    }
コード例 #18
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        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);
        }
コード例 #19
0
ファイル: CInventoryUI.cs プロジェクト: Koyatoufu/AbyssHunter
    void UpdateBoxIcon()
    {
        if (m_itemBox == null)
        {
            return;
        }

        for (int i = 0; i < m_boxIcons.Count; i++)
        {
            m_boxIcons[i].sprite = m_emptyIcon;
        }

        for (int i = 0; i < m_equpmentIcons.Count; i++)
        {
            m_equpmentIcons[i].sprite = m_emptyIcon;
        }

        //20개당 페이지 갱신
        Data.BoxInfo boxInfo = m_itemBox.BoxInfo;
        if (boxInfo != null)
        {
            for (int i = 0; i < boxInfo.itemList.Count; i++)
            {
                if (i >= m_boxIcons.Count)
                {
                    break;
                }

                m_boxIcons[i].sprite = boxInfo.itemList[i].item.IconImg;
            }
            //16개당 페이지 갱신
            for (int i = 0; i < m_itemBox.Equipments.Count; i++)
            {
                if (i >= m_equpmentIcons.Count)
                {
                    break;
                }

                CItemBase itemBase = m_itemBox.Equipments[i] as CItemBase;

                m_equpmentIcons[i].sprite = itemBase.IconImg;
            }
        }
    }
コード例 #20
0
ファイル: CInventoryUI.cs プロジェクト: Koyatoufu/AbyssHunter
    void PartsFunc(PartsType type, int nIdx, Data.EquipmentContainer container, bool isSub = false)
    {
        CItemBase parts = container.GetEquipment(type, nIdx) as CItemBase;

        if (isSub)
        {
            if (parts != null)
            {
                m_partsIcons[m_partsIcons.Count - 1].sprite = parts.IconImg;
            }
        }
        else
        {
            if (parts != null)
            {
                m_partsIcons[(int)type].sprite = parts.IconImg;
            }
        }
    }
コード例 #21
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        /// <summary>
        /// 获取仓库中的数量
        /// </summary>
        /// <param name="itemType"></param>
        /// <returns></returns>
        public uint GetItemTotalCountInStore(uint itemType)
        {
            uint             count        = 0;
            List <CItemBase> itemBaseList = GetItemList(Item_Column.ItemBagColumn_Storage);

            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);
        }
コード例 #22
0
ファイル: PlayerItem.cs プロジェクト: happylays/tbb2
        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);
        }
コード例 #23
0
ファイル: CInventoryUI.cs プロジェクト: Koyatoufu/AbyssHunter
    public void InputPouch(int nIdx)
    {
        if (m_inventory == null)
        {
            return;
        }
        if (m_itemBox == null)
        {
            return;
        }

        if (nIdx < 0 || nIdx >= m_boxIcons.Count)
        {
            return;
        }

        int nCount = 0;

        CItemBase item = m_itemBox.GetItem(nIdx, out nCount, true);

        if (item is CSpellItem)
        {
            ItemData itemData = new ItemData();
            itemData.item  = item;
            itemData.count = nCount;

            m_inventory.SpellAdd(itemData);
        }
        else
        {
            ItemData itemData = new ItemData();
            itemData.item  = item;
            itemData.count = nCount;

            m_inventory.ItemAdd(itemData);
        }
    }
コード例 #24
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();
            }
        }
コード例 #25
0
    protected virtual IEnumerator DeathCoroutine()
    {
        CNpcUnit unit = m_unit as CNpcUnit;

        if (unit == null)
        {
            Destroy(gameObject);
            yield break;
        }

        NavMeshAgent agent = GetComponent <NavMeshAgent>();

        if (agent != null)
        {
            agent.isStopped = true;
            agent.SetDestination(transform.position);
            yield return(null);
        }

        if (unit.UnitData != null && unit.UnitData.PutItems != null)
        {
            GameObject putItemGo = CObjectPool.Inst.GetItem();
            putItemGo.transform.position = transform.position;
            putItemGo.transform.rotation = Quaternion.identity;
            putItemGo.SetActive(true);

            CPutItem putItem = putItemGo.GetComponent <CPutItem>();
            if (putItem != null)
            {
                CItemBase item = null;

                if (unit.UnitData.PutItems.Count > 0)
                {
                    int nIdx = Random.Range(0, unit.UnitData.PutItems.Count);
                    item = unit.UnitData.PutItems[nIdx];
                }

                if (item != null)
                {
                    putItem.SetItemData(item);
                }
            }
        }

        yield return(null);

        m_isDeathStart = true;

        yield return(new WaitForSeconds(m_fDeathWait));

        m_unit.StayLevel = null;
        if (m_unit.SpawnedPoint != null)
        {
            m_unit.SpawnedPoint.RemoveUnitFromList(m_unit);
        }
        m_unit.SpawnedPoint = null;

        CObjectPool.Inst.PooledObject(gameObject, unit.UnitData, unit.UnitData.UnitType, unit.UnitData.Index);

        yield return(null);
    }
コード例 #26
0
        void LoadInvenToryData()
        {
            //TextAsset inventoryText = Resources.Load<TextAsset>("Data/Inventory");
            string inventoryText = File.ReadAllText(Application.streamingAssetsPath + "/Data/Inventory.xml");

            //if (inventoryText == null)
            //    return;

            XmlDocument document = new XmlDocument();

            document.LoadXml(inventoryText);
            //document.LoadXml(inventoryText.text);

            XmlNode root = document.SelectSingleNode("Inventory");

            #region ItemLoad

            XmlNodeList items = root.SelectNodes("Items/Item");

            for (int i = 0; i < items.Count; i++)
            {
                int nIdx   = int.Parse(items[i].SelectSingleNode("index").InnerText);
                int nCount = int.Parse(items[i].SelectSingleNode("count").InnerText);

                CItemBase item = m_itemContainier.GetItem(nIdx);

                if (item == null)
                {
                    continue;
                }

                ItemData itemData = new ItemData();
                itemData.item  = item;
                itemData.count = nCount;

                m_inventoryInfo.itemList.Add(itemData);
            }

            #endregion

            #region SpellLoad

            XmlNodeList spells = root.SelectNodes("Spells/Spell");

            for (int i = 0; i < spells.Count; i++)
            {
                int nIdx   = int.Parse(spells[i].SelectSingleNode("index").InnerText);
                int nCount = int.Parse(spells[i].SelectSingleNode("count").InnerText);

                CItemBase item = m_itemContainier.GetItem(nIdx);

                if (item == null)
                {
                    continue;
                }

                if (!(item is CSpellItem))
                {
                    continue;
                }

                ItemData itemData = new ItemData();
                itemData.item  = item;
                itemData.count = nCount;

                m_inventoryInfo.spellList.Add(itemData);
            }

            #endregion

            #region EquipLoad
            XmlNode equips = root.SelectSingleNode("Equips");

            XmlNode weapon = equips.SelectSingleNode("Weapon");
            m_inventoryInfo.curWeaponIdx = int.Parse(weapon.InnerText);

            XmlNode subWeapon = equips.SelectSingleNode("SubWeapon");
            m_inventoryInfo.subWeaponIdx = int.Parse(subWeapon.InnerText);

            XmlNode body = equips.SelectSingleNode("Body");
            m_inventoryInfo.curBodyIdx = int.Parse(body.InnerText);

            XmlNode leg = equips.SelectSingleNode("Leg");
            m_inventoryInfo.curLegIdx = int.Parse(leg.InnerText);

            XmlNode head = equips.SelectSingleNode("Head");
            m_inventoryInfo.curHeadIdx = int.Parse(head.InnerText);

            XmlNode arm = equips.SelectSingleNode("Arm");
            m_inventoryInfo.curArmIdx = int.Parse(arm.InnerText);
            #endregion
        }