Exemplo n.º 1
0
    private void TryActivateCurrentControlHandler(BaseProjectileControlHandler previousControlHandler)
    {
        _currentBaseProjectileControlHandler = _controlHandlers.Peek();

        while (_currentBaseProjectileControlHandler != null &&
               !_currentBaseProjectileControlHandler.TryActivate(previousControlHandler))
        {
            previousControlHandler = _controlHandlers.Pop();
            Logger.Info("Popped handler: " + previousControlHandler.ToString());
            previousControlHandler.Dispose();

            _currentBaseProjectileControlHandler = _controlHandlers.Peek();
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Exchanges the control handler.
    /// </summary>
    /// <param name="index">The index.</param>
    /// <param name="controlHandler">The control handler.</param>
    public void ExchangeControlHandler(int index, BaseProjectileControlHandler controlHandler)
    {
        Logger.Info("Exchanging handler " + _controlHandlers[index].ToString() + " (index: " + index + ") with " + controlHandler.ToString());

        if (_controlHandlers[index] == _currentBaseProjectileControlHandler)
        {
            BaseProjectileControlHandler poppedHandler = _controlHandlers.Exchange(index, controlHandler);
            poppedHandler.Dispose();

            TryActivateCurrentControlHandler(poppedHandler);
        }
        else
        {
            _controlHandlers.Exchange(index, controlHandler);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Removes the control handler.
    /// </summary>
    /// <param name="controlHandler">The control handler.</param>
    public void RemoveControlHandler(BaseProjectileControlHandler controlHandler)
    {
        Logger.Info("Removing handler: " + controlHandler.ToString());

        if (controlHandler == _currentBaseProjectileControlHandler)
        {
            BaseProjectileControlHandler poppedHandler = _controlHandlers.Pop();
            poppedHandler.Dispose();

            TryActivateCurrentControlHandler(poppedHandler);
        }
        else
        {
            _controlHandlers.Remove(controlHandler);
            controlHandler.Dispose();
        }
    }
Exemplo n.º 4
0
    void Update()
    {
        try
        {
            while (!_currentBaseProjectileControlHandler.Update())
            {
                BaseProjectileControlHandler poppedHandler = _controlHandlers.Pop();
                poppedHandler.Dispose();

                Logger.Info("Popped handler: " + poppedHandler.ToString());
                TryActivateCurrentControlHandler(poppedHandler);
            }
        }
        catch (Exception err)
        {
            Logger.Error("Game object " + this.name + " misses default control handler.", err);
            throw;
        }
    }