Esempio n. 1
0
    //Call this with the opponent data.....sets pawns for opponent
    public void StartingPawnsPlaced(string data)
    {
        Debug.Log("Got Pawn Data: " + data);
        LoadingCanvas.Instance.HideLoadingPopUp();

        FirstPawnData opponentPawnPlacement = JsonUtility.FromJson <FirstPawnData>(JSON.Parse(data)["result"].ToString());

        BoardManager.instance.PlacePawnForOpponent(opponentPawnPlacement);
    }
Esempio n. 2
0
    //only for placing pawns and towers at the start of the game
    public void PlacePawnForOpponent(FirstPawnData pawnPlaced)
    {
        #region Old Code
        //#region Convert Square ID
        //pawnPlaced.positions[0] = 71 - pawnPlaced.positions[0];
        //pawnPlaced.positions[1] = 71 - pawnPlaced.positions[1];
        //pawnPlaced.positions[2] = 71 - pawnPlaced.positions[2];

        //#endregion
        //// PLACE STAR TOWER & STAR PAWN
        //int index = pawnPlaced.positions[0];
        //for (int i = 0; i < Constants.noOfSquarePerRow; i++)
        //{

        //    if (i == index)
        //        CreatePawn(players[1].firstThreeRowSquare[i].SquareId, players[1].allPawns, remotePawns[5]);
        //    else
        //        CreatePawn(players[1].firstThreeRowSquare[i].SquareId, players[1].allPawns, remotePawns[2]);
        //}

        //// PLACE PLUS AND CROSS TOWER & NORMAL PAWN
        //for (int j = 1; j <= 2; j++)
        //{
        //    int towerIndex = 0;
        //    int pawnIndex = 0;
        //    if (j == 2)
        //    {
        //        towerIndex = 4;
        //        pawnIndex = 0;
        //    }
        //    else
        //    {
        //        towerIndex = 3;
        //        pawnIndex = 1;
        //    }
        //    index = pawnPlaced.positions[j];//Random.Range(j * Constants.noOfSquarePerRow, (j + 1) * Constants.noOfSquarePerRow);
        //    CreatePawn(players[1].firstThreeRowSquare[index].SquareId, players[1].allPawns, remotePawns[towerIndex]);

        //    int startIndex = j * Constants.noOfSquarePerRow;
        //    int endIndex = (j + 1) * Constants.noOfSquarePerRow;

        //    for (int i = index + 1; i < endIndex; i++)
        //    {
        //        CreatePawn(players[1].firstThreeRowSquare[i].SquareId, players[1].allPawns, remotePawns[pawnIndex]);
        //        if (pawnIndex == 0)
        //            pawnIndex = 1;
        //        else
        //            pawnIndex = 0;
        //    }
        //    for (int i = startIndex; i < index; i++)
        //    {
        //        CreatePawn(players[1].firstThreeRowSquare[i].SquareId, players[1].allPawns, remotePawns[pawnIndex]);
        //        if (pawnIndex == 0)
        //            pawnIndex = 1;
        //        else
        //            pawnIndex = 0;
        //    }
        //}
        #endregion

        //FirstpawnData contains data of this player and opponent :(
        int index = 0;
        Debug.Log("User Id :" + pawnPlaced.pawnlist[0].user_id + "___" + Database.GetString(Database.Key.PLAYER_ID));
        string uid = Database.GetString(Database.Key.PLAYER_ID);
        if (pawnPlaced.pawnlist[0].user_id.Equals(uid))
        {
            index = 1;
        }
        else
        {
            index = 0;
        }
        Debug.Log("Got User Id :" + index + "<---index " + pawnPlaced.pawnlist[index].user_id + "___" + uid);
        List <GridData> opponentPlacementData = pawnPlaced.pawnlist[index].GridDatas;
        CreatePawnsOpponent(opponentPlacementData);
    }