private void EquipUnequipItemRPC(int itemTypeID, int slotID, bool equip) { // The character has to be alive to equip. if (!m_CharacterLocomotion.Alive && equip) { return; } var itemType = ItemTypeTracker.GetItemType(itemTypeID); if (itemType == null) { return; } var item = m_Inventory.GetItem(slotID, itemType); if (item == null) { return; } if (equip) { m_Inventory.EquipItem(itemType, slotID, true); } else { m_Inventory.UnequipItem(itemType, slotID); } }
private void PickupUsableItemActionRPC(int itemTypeID, int slotID, int itemActionID, float itemActionCount, float consumableItemTypeCount) { var itemType = ItemTypeTracker.GetItemType(itemTypeID); if (itemType == null) { return; } var item = m_Inventory.GetItem(slotID, itemType); if (item == null) { return; } var usableItemAction = item.GetItemAction(itemActionID) as IUsableItem; if (usableItemAction == null) { return; } // The IUsableItem has two counts: the first count is from the inventory, and the second count is set on the actual ItemAction. m_Inventory.PickupItemType(usableItemAction.GetConsumableItemType(), itemActionCount, -1, false, false, false); usableItemAction.SetConsumableItemTypeCount(consumableItemTypeCount); }
private void ItemTypePickupRPC(int itemTypeID, float count, int slotID, bool immediatePickup, bool forceEquip) { var itemType = ItemTypeTracker.GetItemType(itemTypeID); if (itemType == null) { return; } m_Inventory.PickupItemType(itemType, count, slotID, immediatePickup, forceEquip); }
private void PickupItemTypeRPC(int itemTypeID, float count) { var itemType = ItemTypeTracker.GetItemType(itemTypeID); if (itemType == null) { return; } m_Inventory.PickupItemType(itemType, count, -1, false, false, false); }
/// <summary> /// The object has been spawned. Initialize the item pickup. /// </summary> public void ObjectSpawned() { var photonView = gameObject.GetCachedComponent <PhotonView>(); if (photonView == null || photonView.InstantiationData == null) { return; } // Return the old. for (int i = 0; i < m_ItemTypeCounts.Length; ++i) { ObjectPool.Return(m_ItemTypeCounts[i]); } // Setup the item counts. var itemTypeCountLength = (photonView.InstantiationData.Length - (m_TrajectoryObject != null ? 3 : 0)) / 2; if (m_ItemTypeCounts.Length != itemTypeCountLength) { m_ItemTypeCounts = new ItemTypeCount[itemTypeCountLength]; } for (int i = 0; i < itemTypeCountLength; ++i) { var itemTypeCount = ObjectPool.Get <ItemTypeCount>(); itemTypeCount.Initialize(ItemTypeTracker.GetItemType((int)photonView.InstantiationData[i * 2]), (float)photonView.InstantiationData[i * 2 + 1]); m_ItemTypeCounts[i] = itemTypeCount; } Initialize(true); // Setup the trajectory object. if (m_TrajectoryObject != null) { var velocity = (Vector3)photonView.InstantiationData[photonView.InstantiationData.Length - 3]; var torque = (Vector3)photonView.InstantiationData[photonView.InstantiationData.Length - 2]; var originatorID = (int)photonView.InstantiationData[photonView.InstantiationData.Length - 1]; GameObject originator = null; if (originatorID != -1) { var originatorView = PhotonNetwork.GetPhotonView(originatorID); if (originatorView != null) { originator = originatorView.gameObject; } } m_TrajectoryObject.Initialize(velocity, torque, originator); } }