示例#1
0
    protected void CreateCellPath(int xDirection, int yDirection, int movement)
    {
        int currentXPos = currentCell.mBoardPos.x;
        int currentYPos = currentCell.mBoardPos.y;

        for (int i = 1; i <= movement; i++)
        {
            currentXPos += xDirection;
            currentYPos += yDirection;

            //GET STATE OF TARGET CELL
            CellSate cellState = CellSate.None;
            cellState = currentCell.mBoard.ValidateCell(currentXPos, currentYPos, this);

            if (cellState == CellSate.Enemy)
            {
                mHighLightedCells.Add(currentCell.mBoard.mAllCells[currentXPos, currentYPos]);
                break;
            }

            if (cellState != CellSate.Free)
            {
                break;
            }


            mHighLightedCells.Add(currentCell.mBoard.mAllCells[currentXPos, currentYPos]);
        }
    }
示例#2
0
    private void MatchesState(int targetX, int targetY)
    {
        CellSate cellState = CellSate.None;

        cellState = currentCell.mBoard.ValidateCell(targetX, targetY, this);

        if (cellState != CellSate.Friendly && cellState != CellSate.OutOfBounds)
        {
            mHighLightedCells.Add(currentCell.mBoard.mAllCells[targetX, targetY]);
        }
    }
示例#3
0
    private bool MatchesState(int targetX, int targetY, CellSate targetState)
    {
        CellSate cellstate = CellSate.None;

        cellstate = currentCell.mBoard.ValidateCell(targetX, targetY, this);

        if (cellstate == targetState)
        {
            mHighLightedCells.Add(currentCell.mBoard.mAllCells[targetX, targetY]);
            return(true);
        }
        return(false);
    }
示例#4
0
    /*
     * public override void OnBeginDrag(PointerEventData eventData)
     * {
     *  Debug.Log("piece level " + level);
     *  base.OnBeginDrag(eventData);
     *  //test for cells
     *  CheckPathing();
     *  //show cells
     *  ShowCells();
     * }
     */
    public virtual void Move()
    {
        //if enemy piece, remove & level up piece
        CellSate takenCell = targetCell.mBoard.ValidateCell(targetCell.mBoardPos.x, targetCell.mBoardPos.y, targetCell.mCurrentPiece);

        targetCell.RemovePiece();
        if (takenCell == CellSate.Friendly)  // Friendly cause it compares the piece color to the color of the piece on the square
        {
            currentCell.mCurrentPiece.LevelUp();
        }

        //clear current cell
        currentCell.mCurrentPiece = null;
        //switch cells
        currentCell = targetCell;
        currentCell.mCurrentPiece = this;
        //move on board
        transform.position = currentCell.transform.position;
        targetCell         = null;
    }