Exemplo n.º 1
0
        private void UpdateCommandProviderViews(IMoveCommandProvider <Piece> moveCommandProvider)
        {
            if (_pool == null)
            {
                _pool = GetComponent <ObjectPool>();
            }

            foreach (var moveComandView in _moveComandsViews)
            {
                moveComandView.gameObject.SetActive(false);
            }

            _moveComandsViews.Clear();

            if (moveCommandProvider != null)
            {
                foreach (var moveComand in moveCommandProvider.MoveCommands())
                {
                    var go   = _pool.GetPooledObject();
                    var view = go.GetComponent <MoveComandView>();

                    view.Modal = moveComand;
                    _moveComandsViews.Add(view);
                }
            }
        }
Exemplo n.º 2
0
        public void Excecute(TPiece piece, Tile tile)
        {
            if (_validTile.Contains(tile))
            {
                var foundCommand = _activeProvider.MoveCommands().Find((command) => command.Tiles(_board, piece).Contains(tile));

                if (foundCommand == null)
                {
                    return;
                }

                foundCommand.Execute(_board, piece, tile);
                _activeProvider = null;
            }
        }
Exemplo n.º 3
0
        public void ActivateFor(TPiece currentPiece)
        {
            _activeProvider = Provider(currentPiece);

            if (_activeProvider != null)
            {
                _validTile = _activeProvider.MoveCommands()
                             .Where((command) => command.CanExecute(_board, currentPiece))
                             .SelectMany((command) => command.Tiles(_board, currentPiece)).ToList();
            }
            else
            {
                _validTile.Clear();
            }


            OnMoveComandProviderChanged(new MoveCommandProviderChanged <TPiece>(_activeProvider));
        }