public static void RemoveWareHouseObjectList(WareHouseObject obj) { if (m_WareHouseObjectList.Contains(obj)) { m_WareHouseObjectList.Remove(obj); } }
public static void AddWareHouseObjectList(WareHouseObject obj) { if (!m_WareHouseObjectList.Contains(obj)) { m_WareHouseObjectList.Add(obj); } }
public static bool MatchID(WareHouseObject iter, int id) { if (iter == null) { return(false); } return(iter._id == id); }
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); } } }
void CreateWareHouse(GameObject go, int id) { go.name = "emergency_kit"; go.transform.parent = transform; go.transform.localScale = Vector3.one; WareHouseObject script = go.GetComponent <WareHouseObject>(); script._id = id; }
void Start() { RemoveAll(); string path = "Prefab/Item/Scene/emergency_kit"; foreach (KeyValuePair <int, WareHouse> ite in m_WareHouseMap) { UnityEngine.Object obj = Resources.Load(path); if (obj != null) { GameObject gameObject = Instantiate(obj, ite.Value.m_Pos, ite.Value.m_Rotation) as GameObject; gameObject.name = "emergency_kit"; gameObject.transform.parent = transform; WareHouseObject script = gameObject.GetComponent <WareHouseObject>(); script._id = ite.Value.m_ID; } // AssetBundleReq req = AssetBundlesMan.Instance.AddReq(path, ite.Value.m_Pos, ite.Value.m_Rotation); // req.ReqFinishWithReqHandler += OnSpawned; // reqlist[req] = ite.Value.m_ID; } }
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()); } }
protected override void OnPEInstantiate(uLink.NetworkMessageInfo info) { objType = (DoodadType)info.networkView.initialData.Read <int>(); int playerId = info.networkView.initialData.Read <int>(); _teamId = info.networkView.initialData.Read <int>(); _assetId = info.networkView.initialData.Read <int>(); _id = info.networkView.initialData.Read <int>(); _protoTypeId = info.networkView.initialData.Read <int>(); Vector3 scale = info.networkView.initialData.Read <Vector3>(); string param = info.networkView.initialData.Read <string>(); SceneDoodadDesc doodad = null; _pos = transform.position; rot = transform.rotation; if (null == ParentTrans) { ParentTrans = new GameObject("DoodadNetworkMgr").transform; } transform.parent = ParentTrans; if (PeGameMgr.IsMultiStory) { doodad = StoryDoodadMap.Get(_assetId); } if (objType == DoodadType.DoodadType_Drop || objType == DoodadType.DoodadType_Dead) { itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, playerId, _pos, this); } else if (objType == DoodadType.DoodadType_SceneBox) { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } if (entity != null) { WareHouseObject script = entity.gameObject.GetComponent <WareHouseObject>(); if (script != null) { script._id = _assetId; } } } else if (objType == DoodadType.DoodadType_SceneItem) { string[] str = param.Split('|'); if (str.Length != 2) { return; } _sceneItemName = str[1]; if (_sceneItemName == "ash_box") { itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, _assetId, _pos, this); } else if (_sceneItemName == "ash_ball") { itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, _assetId, _pos, this); } else { RequestItemList(); } } else if (objType == DoodadType.DoodadType_Repair) { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } } else if (objType == DoodadType.DoodadType_Power) { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } } else if (objType == DoodadType.DoodadType_RandomBuilding || objType == DoodadType.DoodadType_RandomBuilding_Repair || objType == DoodadType.DoodadType_RandomBuilding_Power) { ExtractParam(param, out townId, out _campId, out _damageId, out _dPlayerId); if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateNetRandTerDoodad(Id, _protoTypeId, _pos, scale, rot, townId, _campId, _damageId, _dPlayerId); } } else { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } } if (entity != null) { OnSpawned(entity.gameObject); } mapObjNetworkMgr.Add(this); gameObject.name = string.Format("Mapobj assetId:{0}, protoTypeId:{1}, objType:{2}, entityId:{3}", _assetId, _protoTypeId, objType, _id); }
public static WareHouseObject GetWareHouseObject(int id) { return(m_WareHouseObjectList.Find(ite => WareHouseObject.MatchID(ite, id))); }
public void ResetItemPacket(ItemPackage itemPackage, Transform obj, WareHouseObject wareObj) { mItemPackage = itemPackage; mOpObject = obj; _wareObj = wareObj; }