public void RemoveTargetFromList(Delivery_End _target)
    {
        // Get the index of the target
        int targetIndex = m_possibleTargets.IndexOf(_target);

        // Remove the target from the list
        m_possibleTargets.Remove(_target);

        // If the target is the active one, we need to switch to a different one
        // Otherwise, we can stay focused on the same one
        if (_target == m_currentTarget)
        {
            // If there is another target we can instantly jump to, do that. Otherwise, change the target to null
            if (m_possibleTargets.Count > 0)
            {
                // Go back to the previous target
                PrevTarget();
            }
            else
            {
                // There is no new target
                CurrentTarget = null;
            }
        }

        // Invoke the event since the list changed
        OnTargetListChanged.Invoke(m_possibleTargets.Count);

        // We completed another delivery so increase the counter and invoke the UI update as well
        m_numComplete++;
        OnCounterChanged.Invoke(m_numComplete, m_numTotal);
    }
    //--- Unity Methods ---//
    private void Start()
    {
        // Init the private variables
        m_possibleTargets = new List <Delivery_End>();
        CurrentTarget     = null;
        m_numComplete     = 0;
        m_numTotal        = GameObject.FindObjectsOfType <Delivery_Start>().Length;

        // Trigger the UI update to show the counter for the number of deliveries
        OnCounterChanged.Invoke(m_numComplete, m_numTotal);
    }
Пример #3
0
 public void IncreaseCounter()
 {
     _count++;
     OnCounterChanged?.Invoke(_count);
 }