Ejemplo n.º 1
0
        public void LogoutCommand()
        {
            IRegion mainRegion = RegionManager.Regions["MainRegion"];
            User    usermodel  = new User();

            Container.RegisterInstance(usermodel);
            TileCommand.RaiseCanExecuteChanged();
            SetCommand.RaiseCanExecuteChanged();

            mainRegion.RemoveAll();

            RegionManager.RequestNavigate("MainRegion", "HomeTilesView");
        }
Ejemplo n.º 2
0
        public void WhenCommandIsExecutedThenNotificationIsSended()
        {
            var tilePosition = new TilePosition(1, 2);

            var inputMessenger = new MessengerFake();

            var tileCommand = new TileCommand(inputMessenger, tilePosition);

            tileCommand.Execute(null);

            Assert.IsNotNull(inputMessenger.SendedMessage);
            Assert.AreEqual(tilePosition, inputMessenger.SendedMessage.First());
        }
Ejemplo n.º 3
0
        internal bool IsCommandVisible(TileCommand command)
        {
            bool value;

            switch (command)
            {
            case TileCommand.Typing:
                value = LastTile is HeadWordItem;
                break;

            case TileCommand.Code:
                value = true;
                break;

            default:
                value = false;
                break;
            }

            return(value);
        }
Ejemplo n.º 4
0
        internal void ExecuteCommand(TileCommand command)
        {
            switch (command)
            {
            default:
                throw new NotImplementedException();

            case TileCommand.Typing:
            {
                var source = new CaseWordVocabularySource(Model, this, (HeadWordItem)LastTile);
                source.SetSuggestionsView();
            }
            break;

            case TileCommand.Code:
            {
                var source = new CodeVocabularySource(this);
                source.SetSuggestionsView();
            }
            break;
            }
        }
Ejemplo n.º 5
0
 void SetCurrentTile(TileCommand cmd)
 {
     SetCurrentTile(cmd, FindObjectOfType<Player>());
 }
Ejemplo n.º 6
0
    void CheckTileClick()
    {
        RaycastHit hit;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Input.GetMouseButtonUp(0) && Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Grid")))
        {
            var coord = Grid.PositionToCoord(hit.transform.position);

            if (_currentTile == null)
            {
                if ((_currentTile = Guess(coord)) == null)
                {
                    return;
                }
            }

            if (_currentTile.CanApply(coord))
            {
                _currentTile.Apply(coord);
            }

            _playerPromise.Fulfill();
            _currentTile = null;
        }
    }
Ejemplo n.º 7
0
    void SetCurrentTile(TileCommand cmd, Agent src)
    {
        _currentTile = cmd;
        _currentTile.SetSource(src);

        if (cmd.Range == 0)
        {
            _acceptAny = true;
        }
        else
        {
            var tiles = Level.CurrentLevel.Get(src.Position, cmd.Range);
            _possibleTiles = tiles.Where(tile => cmd.CanApply(tile.Coordinate)).ToArray();

            foreach (var tile in _possibleTiles)
            {
                Vector3 topCenter = Level.CurrentLevel.Grid.CoordSurfacePosition(tile.Coordinate);
                Vector3 dir = Camera.main.transform.position - topCenter;

                Ray r = new Ray(topCenter, dir);

                foreach (var hit in Physics.RaycastAll(r))
                {
                    if (hit.transform.gameObject.GetComponent<TileWorks>() == null)
                    {
                        continue;
                    }

                    Debug.Log(string.Format("Tile at {0} blocks movement to {1}", Grid.PositionToCoord(hit.transform.position), tile.Coordinate));
                    hit.transform.gameObject.GetComponent<TileWorks>().FadeOut();
                }
            }
        }

        cmd.CommandComplete += CmdOnCommandComplete;
    }
Ejemplo n.º 8
0
 public void LoginCommand(User usermodel)
 {
     Container.RegisterInstance(usermodel);
     TileCommand.RaiseCanExecuteChanged();
     SetCommand.RaiseCanExecuteChanged();
 }
Ejemplo n.º 9
0
 internal CommandItem(ITile predecessor, WordVocabularySource source, TileCommand command)
     : base(predecessor, source)
 {
     _command = command;
 }