示例#1
0
 public void unsubscribeFromAllInputGroups(IUserInputListener listener)
 {
     // Remove from all user group listeners
     foreach (EInputGroup group in inputGroupListeners.Keys)
     {
         if (inputGroupListeners[group].Contains(listener))
         {
             inputGroupListeners[group].Remove(listener);
         }
     }
 }
        public GameEngine(Size fieldSize, IUserInputListener listener, IRenderer renderer, Action onGameOver = null)
        {
            _inputQueue = new InputQueue(HandleMovement);
            _timer = new GranularTimer(OnTimerCallback, 1000, 4);
            _onGameOver = onGameOver;
            var gameField = new GameField(fieldSize, _inputQueue);
            _moveHandler = new MoveHandler(gameField, renderer);

            _inputListener = listener;
            _inputListener.BindInputSerializer(_inputQueue);

            _log = new Logger();
            _log.Init(string.Format("width:{0};height:{1}", fieldSize.Width, fieldSize.Height));
        }
示例#3
0
    public bool unsubscribeFromInputGroup(EInputGroup group, IUserInputListener listener)
    {
        // Check if that input group is currently supported
        if (!inputGroupListeners.ContainsKey(group))
        {
            return(false);
        }

        if (inputGroupListeners[group].Contains(listener))
        {
            inputGroupListeners[group].Remove(listener);
        }

        return(true);
    }
示例#4
0
    // --- Input event subscription ---

    public bool subscribeToInputGroup(EInputGroup group, IUserInputListener listener)
    {
        // Check if that input group is currently supported
        if (!inputGroupListeners.ContainsKey(group))
        {
            return(false);
        }

        // Make sure we don't add a duplicate listener
        if (!inputGroupListeners[group].Contains(listener))
        {
            inputGroupListeners[group].Add(listener);
        }

        return(true);
    }