Esempio n. 1
0
    public void RPC_S2C_RemoveItem(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int itemID = stream.Read <int>();
        int index  = itemList.FindIndex(iter => (iter == itemID));

        if (index >= 0 && objType != DoodadType.DoodadType_Power && objType != DoodadType.DoodadType_RandomBuilding_Power)
        {
            itemList.RemoveAt(index);
        }
        if (objType == DoodadType.DoodadType_Dead || objType == DoodadType.DoodadType_Drop)
        {
            itemBox.RemoveItem(itemID);
        }
        else if (objType == DoodadType.DoodadType_SceneBox)
        {
            if (wareHouseObj == null)
            {
                wareHouseObj = WareHouseManager.GetWareHouseObject(_assetId);
                if (wareHouseObj != null)
                {
                    wareHouseObj.InitForNet(this);
                }
            }
            if (wareHouseObj != null)
            {
                wareHouseObj.RemoveItemById(itemID);
            }
            else
            {
                Debug.LogError("warehouse is null!!!");
            }
        }
        else if (objType == DoodadType.DoodadType_SceneItem)
        {
            if (itemDrop != null)
            {
                ItemObject itemObj = ItemAsset.ItemMgr.Instance.Get(itemID);
                if (itemObj != null)
                {
                    itemDrop.RemoveDroppableItem(itemObj);
                }
            }
        }
        else if (objType == DoodadType.DoodadType_Repair || objType == DoodadType.DoodadType_RandomBuilding_Repair)
        {
            GameUI.Instance.mRepair.DropItemByNet(this, -1);
        }
        else if (objType == DoodadType.DoodadType_Power || objType == DoodadType.DoodadType_RandomBuilding_Power)
        {
            if (itemList.Count > index && index >= 0)
            {
                itemList[index] = -1;
                GameUI.Instance.mPowerPlantSolar.OnMultiRemoveCallBack(this, index, itemID);
            }
        }
    }