Пример #1
0
 public void Unregister(InventoryEventListener listenerToRemove)
 {
     if (gameEventListeners.Contains(listenerToRemove))
     {
         gameEventListeners.Remove(listenerToRemove);
     }
 }
Пример #2
0
 public void Register(InventoryEventListener listenerToAdd)
 {
     if (!gameEventListeners.Contains(listenerToAdd))
     {
         gameEventListeners.Add(listenerToAdd);
     }
 }
Пример #3
0
        public static void AddComponentAtRunTime(GameObject _entity, InventoryEvent _eventToReact,
                                                 UnityAction <InventoryEventData> _onInvoke)
        {
            InventoryEventListener newListener = _entity.AddComponent <InventoryEventListener>();

            newListener.eventToReact = _eventToReact;
            _eventToReact.Register(newListener);
            newListener.onReceiveEvent = new attachedUnityEvent();
            newListener.onReceiveEvent.AddListener(_onInvoke);
        }
Пример #4
0
        private IEnumerator WaitForPossibleSecondInventory()
        {
            yield return(StartCoroutine(InventoryEventListener.WaitForPossibleEvent(1)));

            if (receivedInventories[1] == null)
            {
                EnablePanels(receivedInventories[0].owner);
            }
            else
            {
                InventoryOwner nonPlayerOwner = GetNonPlayerOwner();
                EnablePanels(nonPlayerOwner);
            }

            inventoryOpen = true;
        }
Пример #5
0
        private IEnumerator DropCoroutine()
        {
            yield return(StartCoroutine(InventoryEventListener.WaitForPossibleEvent(5)));

            if (!dropOnItemSlot) // drop item on floor
            {
                dataInputAtStart.container.DropItemOnFloor(dataInputAtStart.itemSlot);
                string infoMessage = MakeDropOnFloorMessage(dataInputAtStart.itemSlot.Quantity,
                                                            dataInputAtStart.itemSlot.Item.name);
                SendStringMessage(infoMessage);
                ResetPanel();
            }
            else if (dataInputAtStart.itemSlot == dataInputAtEnd.itemSlot) // depart = destination
            {
                ResetPanel();
            }
            else
            {
                Item itemAtStart = dataInputAtStart.itemSlot.Item;
                Item itemAtEnd   = dataInputAtEnd.itemSlot.Item;

                if (itemAtEnd == null || itemAtEnd != itemAtStart) // swap itemSlot
                {
                    dataInputAtStart.container.SwapItemSlot(dataInputAtStart.container, dataInputAtStart.itemSlot,
                                                            dataInputAtEnd.container, dataInputAtEnd.itemSlot);
                    ResetPanel();
                }
                else if (itemAtEnd == itemAtStart) // stack itemSlot;
                {
                    if (dataInputAtStart.container == dataInputAtEnd.container ||
                        dataInputAtStart.itemSlot.Quantity == 1)
                    {
                        MoveItem(dataInputAtStart.itemSlot.Quantity);
                    }
                    else
                    {
                        AskForQuantity();
                    }
                }
            }
        }