Exemple #1
0
    protected override void OnViewUpdate()
    {
        base.OnViewUpdate();

        if (IsInvalid(InvalidationFlag.DYNAMIC_DATA))
        {
            if (_icon != null)
            {
                _icon.color = _getColor(_boardPosition.type);
            }

            transform.localPosition = BoardPositionUtil.GetViewPosition(_boardPosition);

            // DebugInfo
            _positionType = _boardPosition.type;
            _trackIndex   = _boardPosition.trackIndex;
            _ownerIndex   = _boardPosition.ownerIndex;

            if (_debugNumber != null)
            {
                _debugNumber.text  = _trackIndex.ToString();
                _debugNumber.color = _trackIndex % 2 == 0 ? Color.green : Color.red;
            }
        }
    }
Exemple #2
0
    protected override void OnViewUpdate()
    {
        base.OnViewUpdate();

        if (IsInvalid(InvalidationFlag.DYNAMIC_DATA))
        {
            if (_icon != null)
            {
                _icon.color = PlayerUtil.GetColor(piece.ownerIndex);
            }

            transform.localPosition = BoardPositionUtil.GetViewPosition(boardPosition);
            // DebugInfo
            _positionType = boardPosition.type;
            _trackIndex   = boardPosition.trackIndex;
            _ownerIndex   = piece.ownerIndex;
        }
    }
Exemple #3
0
    public bool GetNextPositions(BoardPosition position, int playerIndex, bool forward, ref List <BoardPosition> result)
    {
        bool          positionsFound = false;
        BoardPosition goalPos;

        int nextIndex        = (forward) ? 1 : -1;
        int nextWrappedIndex = BoardPositionUtil.GetWrappedMainTrackIndex(position.trackIndex + nextIndex);

        bool          isBlockingTrack = false;
        BoardPosition mainTrackPos    = _mainTrack[nextWrappedIndex];

        BoardPiece blockingPiece;

        if (IsPositionOccupied(mainTrackPos, out blockingPiece))
        {
            isBlockingTrack = mainTrackPos.type == PositionType.START_PEG && blockingPiece.justLeftHome;
        }

        switch (position.type)
        {
        case PositionType.GOAL_TRACK_ENTRANCE:
        {
            if (position.ownerIndex == playerIndex && forward)
            {
                goalPos = _goalTrack[playerIndex][0];
                result.Add(goalPos);
            }

            if (!isBlockingTrack)
            {
                result.Add(mainTrackPos);
                positionsFound = true;
            }
        }
        break;

        case PositionType.MAIN_TRACK:
        case PositionType.START_PEG:
        {
            if (!isBlockingTrack)
            {
                result.Add(mainTrackPos);
                positionsFound = true;
            }
        }
        break;

        case PositionType.GOAL_TRACK:
        {
            if (position.trackIndex < kPerPlayerGoalCount - 1 && forward)
            {
                int goalIndex = position.trackIndex + nextIndex;
                goalPos = _goalTrack[playerIndex][goalIndex];

                BoardPiece tmpPiece;
                if (!IsPositionOccupied(goalPos, out tmpPiece))
                {
                    result.Add(goalPos);
                    positionsFound = true;
                }
            }
        }
        break;
        }
        return(positionsFound);
    }