Example #1
0
        private void OnPositionSelected(Vector2Int position)
        {
            if (EntitySelection.SelectedUnity != null && EntitySelection.SelectedUnity.ActionsRemaining > 0 && EntitySelection.SelectedUnity.Position != position)
            {
                if (_validMoves.Contains(position))
                {
                    BreadcrumbsHandler.HideAllBreadCrumbs();

                    EntitySelection.SelectedUnity.Move(position, () =>
                    {
                        EntitySelection.SelectEntity(position);
                    });
                }
            }
        }
Example #2
0
        private void OnSelectedEntityChanged(UnitModel unit)
        {
            BreadcrumbsHandler.HideAllBreadCrumbs();

            if (unit?.Type == Type && unit.ActionsRemaining > 0)
            {
                _validMoves = new List <Vector2Int>();
                var possibleMoves = MovementResolver.ShowPossibleMove(unit.Position, unit.Config.MovementRange);

                foreach (var pos in possibleMoves)
                {
                    var tileIsFree = !LevelDataProvider.LevelData.Entities.Exists(e => e.GridPosition == pos);

                    if (tileIsFree)
                    {
                        _validMoves.Add(pos);
                        BreadcrumbsHandler.ShowBreadCrumb(pos.x, pos.y, true);
                    }
                }
            }
        }