예제 #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);
            }
        }
    }
예제 #2
0
    public void RPC_S2C_RequestItemList(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int[] item = stream.Read <int[]>();
        itemList.Clear();
        foreach (int itemid in item)
        {
            itemList.Add(itemid);
        }
        if (objType == DoodadType.DoodadType_Dead || objType == DoodadType.DoodadType_Drop)
        {
            itemBox.OnRequestItemList(itemList);
        }
        else if (objType == DoodadType.DoodadType_SceneBox)
        {
            //if(wareHouseObj == null)
            //	wareHouseObj = WareHouseManager.GetWareHouseObject(_assetId);
            //if(wareHouseObj != null && wareHouseObj.ItemPak == null)
            //{
            //	wareHouseObj.InitForNet( this );
            //}
            if (wareHouseObj == null)
            {
                wareHouseObj = WareHouseManager.GetWareHouseObject(_assetId);
                if (wareHouseObj != null)
                {
                    wareHouseObj.InitForNet(this);
                }
            }

            if (wareHouseObj != null)
            {
                wareHouseObj.ResetItemByIdList(itemList);
            }
        }
        else if (objType == DoodadType.DoodadType_SceneItem)
        {
            if (_sceneItemName == "backpack")
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreateBackpack(transform.position, itemList, this);
                }
            }
            else if (_sceneItemName == "pajaLanguage")
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreatePajaLanguage(transform.position, itemList, this);
                }
            }
            else if (_sceneItemName == "probe")
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreateProbe(transform.position, itemList, this);
                }
            }
            else if (_sceneItemName == "hugefish_bone")
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreateHugefish_bone(transform.position, itemList, this);
                }
            }
            else if (_sceneItemName == "1_larve_Q425")
            {
                itemDrop = StroyManager.Createlarve_Q425(transform.position);
            }
            else if (_sceneItemName == "ash_box")
            {
                itemBox.OnRequestItemList(itemList, true);
            }
            else if (_sceneItemName == "ash_ball")
            {
                itemBox.OnRequestItemList(itemList, true);
            }
            else if (_sceneItemName.Contains("language_sample_canUse(Clone):"))
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreateLanguageSampleNet(_sceneItemName, transform.position, itemList, this);
                }
            }
            else if (_sceneItemName.Contains("coelodonta_rhino_bone"))
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreateAndHeraNest_indexNet(_sceneItemName, transform.position, itemList, this);
                }
            }
            else if (_sceneItemName.Contains("lepus_hare_bone"))
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreateAndHeraNest_indexNet(_sceneItemName, transform.position, itemList, this);
                }
            }
            else if (_sceneItemName.Contains("andhera_queen_egg"))
            {
                if (itemList.Count > 0)
                {
                    itemDrop = StroyManager.CreateAndHeraNest_indexNet(_sceneItemName, transform.position, itemList, this);
                }
            }
        }
        else if (objType == DoodadType.DoodadType_Repair || objType == DoodadType.DoodadType_RandomBuilding_Repair)
        {
            if (itemList.Count > 0)
            {
                GameUI.Instance.mRepair.SetItemByNet(this, itemList[0]);
            }
            else
            {
                GameUI.Instance.mRepair.SetItemByNet(this, -1);
            }
        }
        else if (objType == DoodadType.DoodadType_Power || objType == DoodadType.DoodadType_RandomBuilding_Power)
        {
            GameUI.Instance.mPowerPlantSolar.OnMultiOpenDropCallBack(this, itemList.ToArray());
        }
    }