Example #1
0
    private void UpdateGridCellClick()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var screenRay       = Camera.main.ScreenPointToRay(Input.mousePosition);
            var clickedGridCell = _grid.GetCells().FirstOrDefault(_ => _.IntersectsRay(screenRay));

            if (clickedGridCell != null && _currentCharacter != null)
            {
                _currentCharacter.SetDestination(clickedGridCell.X, clickedGridCell.Y);

                EventSystem.RaiseEvent(new Clicked {
                    ClickTarget = clickedGridCell
                });
            }
        }
    }