Ejemplo n.º 1
0
    private IEnumerator Move(Coord dest)
    {
        // Remove branches entering the stages not chosen in the next column and grey them out
        for (int i = 0; i < _currMap[dest.col].Length; i++)
        {
            StageNode stage = _currMap[dest.col][i];
            // Ignore null stages and the current stage
            if (stage == null || i == dest.row)
            {
                continue;
            }
            stage.SetInaccessible();
            stage.DestroyEntryBranch();
        }

        // Readjust length of vertical path leading to next column
        PositionVerticalPath(GetCurrStage().GetVerticalPath(), GetCurrStage(), _currMap[dest.col][dest.row]);

        SetPlayerCoord(dest);
        _canMove = false;

        // TODO: move animation?
        yield return(new WaitForSeconds(1f));

        GetCurrStage().EnterStage();
        _mapDisplay.SetActive(false);
    }
Ejemplo n.º 2
0
    private void EnableNextPaths()
    {
        _mapDisplay.SetActive(true);
        if (_currCoord == null)
        {
            return;
        }
        if (_currCoord.col + 1 >= _currMap.Length)
        {
            NextMap();
            return;
        }
        _canMove = true;

        // Create branch leaving current node
        CreateBranch(GetCurrStage(), false);

        // Go through next column and find the topmost and bottommost stages that can be reached
        // Also, grey out unreachable stages
        int topBranchIndex    = -1;
        int bottomBranchIndex = -1;

        for (int i = 0; i < _currMap[_currCoord.col + 1].Length; i++)
        {
            StageNode stage = _currMap[_currCoord.col + 1][i];
            if (stage == null)
            {
                continue;
            }
            if (i < _currCoord.row - _moveRange || i > _currCoord.row + _moveRange)
            {
                stage.SetInaccessible();
            }
            else
            {
                if (topBranchIndex == -1)
                {
                    topBranchIndex = i;
                }
                if (bottomBranchIndex == -1 || i > bottomBranchIndex)
                {
                    bottomBranchIndex = i;
                }
            }
        }

        // Create branches entering each of the next nodes
        for (int i = topBranchIndex; i <= bottomBranchIndex; i++)
        {
            StageNode stage = _currMap[_currCoord.col + 1][i];
            if (stage != null)
            {
                CreateBranch(stage, true);
            }
        }

        // Connect all the branches with one vertical path
        StageNode stageA = _currMap[_currCoord.col + 1][topBranchIndex];
        StageNode stageB = _currMap[_currCoord.col + 1][bottomBranchIndex];

        if (_currCoord.row < topBranchIndex)
        {
            stageA = GetCurrStage();
        }
        else if (_currCoord.row > bottomBranchIndex)
        {
            stageB = GetCurrStage();
        }
        RectTransform verticalPath = Instantiate(_pathPrefab, GetCurrStage().transform).GetComponent <RectTransform>();

        verticalPath.anchoredPosition += new Vector2(_horizontalPadding / 2, 0);
        GetCurrStage().SetVerticalPath(verticalPath);
        PositionVerticalPath(verticalPath, stageA, stageB);
    }