////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //
    /// </summary>
    /// <param name="queue"></param>
    /// <returns>
    //  bool
    /// </returns>
    public bool ContainsQueue(UI_BuildingQueue queue)
    {
        bool match = false;

        for (int i = 0; i < _Queues.Count; i++)
        {
            if (_Queues[i] == queue)
            {
                match = true;
                break;
            }
        }
        return(match);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //
    /// </summary>
    /// <param name="queue"></param>
    public void RemoveFromQueue(UI_BuildingQueue queue)
    {
        // look for match
        for (int i = 0; i < _Queues.Count; i++)
        {
            // Look for match
            if (_Queues[i] == queue)
            {
                // Remove & destroy
                _Queues.RemoveAt(i);
                Destroy(queue.gameObject);
                UpdateQueuePositions();
            }
        }
    }
Esempio n. 3
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Creates the building's personal queue widget
    //  (the widget will not display anything until there are items in the queue.
    /// </summary>
    public void CreateQueueWidget()
    {
        // Create queue widget
        if (_BuildingQueueUI == null)
        {
            _BuildingQueueUI = Instantiate(UI_BuildingQueueWrapper.Instance.BuildingQueueStencil);
            _BuildingQueueUI.SetBuildingAttached(this);
        }

        // Add to wrapper singleton list
        if (!UI_BuildingQueueWrapper.Instance.ContainsQueue(_BuildingQueueUI))
        {
            UI_BuildingQueueWrapper.Instance.AddNewQueue(_BuildingQueueUI);
        }
        _BuildingQueueUI.transform.SetParent(UI_BuildingQueueWrapper.Instance.QueueListTransform);
        _BuildingQueueUI.gameObject.SetActive(true);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //
    /// </summary>
    /// <param name="queue"></param>
    public void AddNewQueue(UI_BuildingQueue queue)
    {
        _Queues.Add(queue);
        UpdateQueuePositions();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Static function that compares the item count's between 2 UI_BuildingQueues.
    /// </summary>
    /// <param name="queue1"></param>
    /// <param name="queue2"></param>
    /// <returns>
    //  static int
    /// </returns>
    static int SortQueueLength(UI_BuildingQueue queue1, UI_BuildingQueue queue2)
    {
        return(queue2.GetQueueSize().CompareTo(queue1.GetQueueSize()));
    }