Exemple #1
0
    void init()
    {
        GameBoard = new gameBoard[10][];
        for (int i = 0; i < 10; i++)
        {
            GameBoard[i] = new gameBoard[10];
        }
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                GameBoard[i][j] = new gameBoard();
            }
        }
        currentSelectedPiece = new gameBoard();
        validCoordinates     = new SC_DefiendVariables.Point[4];
        for (int i = 0; i < 4; i++)
        {
            validCoordinates[i] = new SC_DefiendVariables.Point();
        }
        enemyArray = new List <SC_PieceLogic>();



        currentTurn = (SC_DefiendVariables.Turn)UnityEngine.Random.Range(0, 2);
        print("CurrentTurn see if its working= " + currentTurn);
    }
Exemple #2
0
    void init()
    {
        gameBoard = new SC_MultiPlayer_gameBoard[10][];
        for (int i = 0; i < 10; i++)
        {
            gameBoard[i] = new SC_MultiPlayer_gameBoard[10];
        }
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                gameBoard[i][j] = new SC_MultiPlayer_gameBoard();
            }
        }
        currentSelectedPiece = new SC_MultiPlayer_gameBoard();
        validCoordinates     = new SC_DefiendVariables.Point[4];
        for (int i = 0; i < 4; i++)
        {
            validCoordinates[i] = new SC_DefiendVariables.Point();
        }
        enemyArray = new List <SC_MultiPlayer_PieceLogic>();



        currentTurn = (SC_DefiendVariables.Turn)UnityEngine.Random.Range(0, 2);     //change it later
        initMultiplayer();
    }
Exemple #3
0
    public void RedTurn()
    {
        int _row;
        int _col;

        ResetValidCoordinates();
        bool _catchedAvaliblePiece = true, _rnd = true;

        int[] _arrayOfOptions = new int[4];
        int   _rndNumber      = 0;
        int   randomMove      = 0;

        SC_DefiendVariables.Point moveTo;
        moveTo = new SC_DefiendVariables.Point();

        if (currentTurn == SC_DefiendVariables.Turn.RedTurn)
        {
            while (_catchedAvaliblePiece)
            {
                _rndNumber            = UnityEngine.Random.Range(0, enemyArray.Count);
                _catchedAvaliblePiece = HasValidMove(enemyArray[_rndNumber]);
            }
            currentSelectedPiece.piece = enemyArray[_rndNumber];

            while (_rnd)
            {
                randomMove = UnityEngine.Random.Range(0, 4);
                if (validCoordinates[randomMove].Row != -1)
                {
                    _rnd = false;
                }
            }
            //randomMove contain the currect coordinate to move to.
            moveTo.Col = validCoordinates[randomMove].Col;
            moveTo.Row = validCoordinates[randomMove].Row;

            _row = currentSelectedPiece.piece.currentTileRow;
            _col = currentSelectedPiece.piece.currentTileCol;

            if (GameBoard[moveTo.Row][moveTo.Col].tileStatus == SC_DefiendVariables.TileStatus.Empty)
            {
                GameBoard[_row][_col].piece                  = null;
                GameBoard[_row][_col].tileStatus             = SC_DefiendVariables.TileStatus.Empty;
                GameBoard[moveTo.Row][moveTo.Col].tileStatus = SC_DefiendVariables.TileStatus.RedOccupied;
                GameBoard[moveTo.Row][moveTo.Col].piece      = currentSelectedPiece.piece;
                currentSelectedPiece.piece.currentTileRow    = moveTo.Row;
                currentSelectedPiece.piece.currentTileCol    = moveTo.Col;
                SC_View.Instance.movePieceToNewLocation(currentSelectedPiece.piece, GameBoard[moveTo.Row][moveTo.Col].tile.GetComponent <SC_TileLogic>());
            }
            else if (GameBoard[moveTo.Row][moveTo.Col].tileStatus == SC_DefiendVariables.TileStatus.BlueOccupied)
            {
                fight(GameBoard[moveTo.Row][moveTo.Col].tile.GetComponent <SC_TileLogic>());
            }

            SC_View.Instance.HideValidPlacements();
            SwitchTurn();
        }
    }