private IEnumerator MoveRoutine(Direction direction, float delay = 0)
        {
            yield return(new WaitForSeconds(delay));

            switch (direction)
            {
            case Direction.Up:
                GridPosition = new Vector2Int(GridPosition.x, GridPosition.y - 1);
                break;

            case Direction.Down:
                GridPosition = new Vector2Int(GridPosition.x, GridPosition.y + 1);
                break;

            case Direction.Left:
                GridPosition = new Vector2Int(GridPosition.x - 1, GridPosition.y);
                break;

            case Direction.Right:
                GridPosition = new Vector2Int(GridPosition.x + 1, GridPosition.y);
                break;
            }

            var targetPosition = LevelGrid.ToWorldCoordinates(GridPosition.x, GridPosition.y);

            transform.DOJump(targetPosition, 0.25f, 1, 0.3f).SetEase(Ease.InQuint);
            Renderer.sortingOrder = LevelGrid.GetSortingOrder(GridPosition.x, GridPosition.y);
            audio.PlayMove();
        }
Exemplo n.º 2
0
        private IEnumerator MoveRoutine(Action movingCompleted)
        {
            var targetPosition = LevelGrid.ToWorldCoordinates(GridPosition.x, GridPosition.y);
            var jumpDuration   = 0.3f;

            transform.DOJump(targetPosition, 0.25f, 1, jumpDuration).SetEase(Ease.InQuint);
            Renderer.sortingOrder = LevelGrid.GetSortingOrder(GridPosition.x, GridPosition.y);
            audio.PlayMove();

            yield return(new WaitForSeconds(jumpDuration));

            movingCompleted();
        }
Exemplo n.º 3
0
        private void OnEntityStep(Vector2Int to, int stepIndex, float stepDuration)
        {
            Vector2 toPositionWorld = GridHelper.ToWorldCoordinates(to.x, to.y);

            transform.DOJump(toPositionWorld, 0.25f, 1, stepDuration).SetEase(Ease.InQuint)
            .SetDelay(stepDuration * stepIndex)
            .OnComplete(() =>
            {
                Renderer.sortingOrder = GridHelper.GetSortingOrder(to.x, to.y);
                audio.PlayMove();
            });
        }