예제 #1
0
    private void SwipeTiles(Vector2Int current, Vector2Int target)
    {
        TileBackground currentTileBackground = GetTileBackgroundAtIndex(current);
        TileBackground targetTileBackground  = GetTileBackgroundAtIndex(target);

        if (currentTileBackground == null || targetTileBackground == null)
        {
            return;
        }

        _currentTile = currentTileBackground.GetTile();
        _targetTile  = targetTileBackground.GetTile();

        if (_targetTile.IsCompleted)
        {
            return;
        }

        OnSwipeStartEvent.Invoke();
        currentTileBackground.SetTile(_targetTile);
        targetTileBackground.SetTile(_currentTile);

        _currentTile.SetArrayIndex(target.x, target.y);
        _targetTile.SetArrayIndex(current.x, current.y);
        _currentTile.SetParent(targetTileBackground.transform);
        _targetTile.SetParent(currentTileBackground.transform);

        _currentTile.DoMove(tweenTime);
        _targetTile.DoMove(tweenTime);
        StartCoroutine(WaitForSwipe(tweenTime * 1.05f));
    }
예제 #2
0
    private void LoadLevel()
    {
        OnSwipeStartEvent.AddListener(OnSwipeStart);
        OnSwipeEndEvent.AddListener(OnSwipeEnd);

        moveCount = _currentLevel.MoveCount;
        CreateBoard(_currentLevel.Width, _currentLevel.Height);
    }
예제 #3
0
    private void UnLoadLevel()
    {
        moveCount   = 0;
        totalPoints = 0;

        transform.position = Vector3.zero;

        OnResetTileBackgroundEvent.Invoke();

        OnSwipeEndEvent.RemoveAllListeners();
        OnSwipeStartEvent.RemoveAllListeners();
        OnTileInteractableChangedEvent.RemoveAllListeners();
        OnResetTileBackgroundEvent.RemoveAllListeners();
        StopAllCoroutines();
    }