示例#1
0
    public void ApplyTimeDelta(float delta)
    {
        if (_elementsInProgress.Count == 0)
        {
            return;
        }

        var inProgress = _elementsInProgress.Peek();

        inProgress.ApplyDelta(delta);

        if (OnTimeProductionChange != null)
        {
            OnTimeProductionChange.Invoke(inProgress);
        }

        if (inProgress.NormalizedProductionTime >= 1)
        {
            _elementsInProgress.Dequeue();
            if (OnProductionChange != null)
            {
                OnProductionChange.Invoke();
            }
            if (OnDone != null)
            {
                OnDone.Invoke(inProgress.Element);
            }
        }
    }
示例#2
0
 public void RemoveFromProduction(InProduction inProgress)
 {
     _elementsInProgress = new Queue <InProduction>(_elementsInProgress.Where((x) => x != inProgress));
     if (OnProductionChange != null)
     {
         OnProductionChange.Invoke();
     }
 }
示例#3
0
    public void AddInProduction(ProductionElement element)
    {
        if (!_possibleProduction.Contains(element))
        {
            throw new System.InvalidOperationException();
        }

        _elementsInProgress.Enqueue(new InProduction(element, 0));

        if (OnProductionChange != null)
        {
            OnProductionChange.Invoke();
        }
    }