Exemple #1
0
    //changes the ID from GBTBM and also changes its values
    public void SetMyPlayerInformationAndItsValues(string id)
    {
        Debug.Log("Seeting playerinformation and its values from GPTBM data");
        myID = id;
        GameDataGooglePlay currentData = Common.roundInformation.gameData;
        int foundNumber = FindMyPlayerNumber(currentData, id);

        playerNumber = foundNumber;                                                //FindMyPlayerNumber(currentData, myGPID);
        ready        = Common.roundInformation.gameData.readyStates[playerNumber]; //added 16.11 addding r eady state and imagepath from googleplay data.
        // if (ready && Common.roundInformation.gameData.AreWeOnPictureState())
        // {
        myCloudImagePath = Common.roundInformation.gameData.roundImageURLs[playerNumber];
        if (ready)
        {
            pickGallery.SetActive(false);
            pickImageFromCamera.SetActive(false);
        }
        else
        {
            if (Common.roundInformation.gameData.gameState == (int)GameStates.PickingPics)
            {
                pickGallery.SetActive(true);
                pickImageFromCamera.SetActive(true);
            }
            else
            {
                pickGallery.SetActive(false);
                pickImageFromCamera.SetActive(false);
            }
        }
        //}
        //  AN_PoupsProxy.showMessage("Playerinformation setmyplayerinfo", "myID "+myGPID+" player number "+playerNumber.ToString());
    }
    public byte[] InitializeGameData(List <string> playerIdS, string matchID)
    {
        GameDataGooglePlay newData = new GameDataGooglePlay();

        newData.playerAmount            = playerIdS.Count;
        newData.hostID                  = playerIdS[0];
        newData.gameStartTime           = Common.usefulFunctions.GetLongTime();
        newData.roundDeciderPID         = 0;
        newData.roundWinnerPlayerNumber = -1;
        newData.guestion                = "Haven't been set yet";
        foreach (string id in playerIdS)
        {
            newData.playerPoints.Add(0);
            newData.winnerVotes.Add(0);
            newData.roundImageURLs.Add("9");
            newData.readyStates.Add(false);
            newData.playerIDS.Add(id);
            newData.matchID = matchID;
            //AndroidMessage.Create("Addingthingies initializing game data", "playerIDS "+id);
        }
        newData.gameState             = 0; //(int)GameStates.ChoosingQuestions;
        gameData                      = newData;
        Common.playerInformation.myID = newData.hostID;
        // Common.playerInformation.playerNumber = 0;

        return(GetByteArrayFromData(newData));
    }
Exemple #3
0
    public void ChangeGameDataValuesAccordingToMyData()
    {
        GameDataGooglePlay data = Common.roundInformation.gameData;

        data.readyStates[playerNumber]    = ready;
        data.roundImageURLs[playerNumber] = myCloudImagePath;
        data.winnerVotes[playerNumber]    = myVote;
    }
    private byte[] GetByteArrayFromData(GameDataGooglePlay data)
    {
        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
        string mTurnData = CreateGameDataString(data);

        byte[] byteArray = encoding.GetBytes(mTurnData);
        return(byteArray);
    }
    public void AddPhotoToGallery()
    {
        // cloudImageManagerToUse.UploadFileToCloud(fileName, "matti", filePath);
        PlayerInformation  pi       = Common.playerInformation;
        GameDataGooglePlay gameData = Common.roundInformation.gameData;

        Common.galleryManager.AddPhoto(gameData.hostID, gameData.matchID, GetPhotoName(pi), Common.gameMaster.currenctGuestion, pi.myLocalImagePath);
    }
Exemple #6
0
    IEnumerator LoadGameRoutine()
    {
        Debug.Log("First lets load wanted scene based on gamestate");
        LoadSceneBasedOnState();
        while (loadingScene)
        {
            yield return(new WaitForSeconds(0.1f));
        }
        Debug.Log("Scene has been loaded set values");
        GameDataGooglePlay gameData = Common.roundInformation.gameData;
        //FIrst load scene based on data
        RoundInformation  ri = Common.roundInformation;
        PlayerInformation pi = Common.playerInformation;

        if (pi.isOnGame)
        {
            Common.infoGUI.setNewGuestion(ri.gameData.guestion);
            if (gameData.gameState == (int)GameStates.PickingPics)
            {
                if (pi.ready)
                {
                    if (pi.myCloudImagePath.Length > 5)
                    {
                        Common.infoGUI.DisableReadyPressing();
                        Debug.Log("Loading image from cloud");
                        pi.LoadMyImageFromURL();
                        pi.SetReady();
                        Common.infoGUI.ChangeReadyButtonState(true);
                    }
                    else if (pi.myLocalImagePath.Length > 5)
                    {
                        Debug.Log("Loading image from local");
                        pi.LoadMyImageFromURL(pi.myLocalImagePath);
                        pi.ready = false;
                    }
                    else
                    {
                        pi.ready = false;
                    }
                }
            }
            if (gameData.gameState == (int)GameStates.PickingWinner)
            {
                Debug.Log("Creating picking winner scene");
                Common.DebugPopUp("GameLoader loadinggameroutine gamestate is picking winner Gonna create elements and load all images");
                Common.showWinnerMaster.CreateElements(Common.roundInformation.gameData.playerAmount);
                Common.showWinnerMaster.LoadAllImagesFromPlayerURLS();
            }
        }
        else
        {
            //LOAD MENU
        }
        yield return(new WaitForEndOfFrame());
    }
Exemple #7
0
    void LoadNewState(int gameState)
    {
        GameDataGooglePlay gameData = Common.roundInformation.gameData;
        //FIrst load scene based on data
        RoundInformation  ri = Common.roundInformation;
        PlayerInformation pi = Common.playerInformation;

        if (gameData.AreWeOnPictureState())
        {
            Debug.Log("Setting new guestion");
            Common.infoGUI.setNewGuestion(ri.gameData.guestion);
            Debug.Log("new guestion has been set");
            if (gameState == (int)GameStates.PickingPics)
            {
                Common.DebugPopUp("GameLoader loadingNewState routine", "Picking pics is the game state gonna check if we are ready and preload image if it exists");
                if (pi.ready)
                {
                    if (pi.myCloudImagePath.Length > 5)
                    {
                        Common.infoGUI.DisableReadyPressing();
                        Debug.Log("Loading image from cloud");
                        pi.LoadMyImageFromURL();
                        pi.SetReady();
                        Common.infoGUI.ChangeReadyButtonState(true);
                    }
                    else if (pi.myLocalImagePath.Length > 5)
                    {
                        Debug.Log("Loading image from local");
                        pi.LoadMyImageFromURL(pi.myLocalImagePath);
                        pi.ready = false;
                    }
                    else
                    {
                        pi.ready = false;
                    }
                }
            }
            if (gameData.gameState == (int)GameStates.PickingWinner)
            {
                // Common.showWinnerMaster.ClearPossiblePreviousElements();
                Debug.Log("Creating picking winner scene");
                Common.DebugPopUp("GameLoader loadinggameroutine gamestate is picking winner Gonna create elements and load all images");
                Common.showWinnerMaster.CreateElements(Common.roundInformation.gameData.playerAmount);
                Debug.Log("Loading all images from playuer URL");
                Common.showWinnerMaster.LoadAllImagesFromPlayerURLS();
            }
            if (gameData.gameState == (int)GameStates.ShowingWinner)
            {
                Common.gameMaster.DetermineWinnerAndLoadTheSceneUI();
            }
        }
    }
Exemple #8
0
    public int FindMyPlayerNumber(GameDataGooglePlay data, string idToFind)
    {
        int counter = 0;

        foreach (string id in data.playerIDS)
        {
            if (id.Contains(idToFind))
            {
                AN_PoupsProxy.showMessage("FindMyPlayerNumber in playerinformation", "found player number " + counter.ToString());
                return(counter);
            }
            counter++;
        }
        AN_PoupsProxy.showMessage("FindMyPlayerNumber didn't find player number", "Giving new pn " + counter.ToString());
        return(counter);
    }
    string CreateGameDataString(GameDataGooglePlay data)
    {
        JsonArray  jsonArray = new JsonArray();
        JsonObject obj0      = Create1Object(data.playerAmount);
        JsonObject obj1      = Create1Object(data.hostID);
        JsonObject obj2      = Create1Object(data.roundImageURLs);
        JsonObject obj3      = Create1Object(data.readyStates);
        JsonObject obj4      = Create1Object(data.gameStartTime);
        JsonObject obj5      = Create1Object(data.gameState);
        JsonObject obj6      = Create1Object(data.playerPoints);
        JsonObject obj7      = Create1Object(data.playerIDS);
        JsonObject obj8      = Create1Object(data.round);
        JsonObject obj9      = Create1Object(data.matchID);
        JsonObject obj10     = Create1Object(data.roundWinnerPlayerNumber);
        JsonObject obj11     = Create1Object(data.roundDeciderPID);
        JsonObject obj12     = Create1Object(data.guestion);
        JsonObject obj13     = Create1Object(data.winnerVotes); //added 17.11

        jsonArray.Add(obj0);
        jsonArray.Add(obj1);
        jsonArray.Add(obj2);
        jsonArray.Add(obj3);
        jsonArray.Add(obj4);
        jsonArray.Add(obj5);
        jsonArray.Add(obj6);
        jsonArray.Add(obj7);
        jsonArray.Add(obj8);
        jsonArray.Add(obj9);
        jsonArray.Add(obj10);
        jsonArray.Add(obj11);
        jsonArray.Add(obj12);
        jsonArray.Add(obj13);
        Debug.Log(obj1.ToString());
        Debug.Log(jsonArray.ToJsonPrettyPrintString());
        return(jsonArray.ToJsonString());
    }
    // Use this for initialization
    void Start()
    {
        Common.roundInformation = this;

        /*
         * cst = CreateGameDataString(testData);
         * System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
         *
         * byte[] byteArray = encoding.GetBytes(cst);
         * JsonArray objects = (JsonArray)JsonNode.ParseJsonString(cst);
         * createdTestData = GetGameDataFromJson(byteArray);
         */
        if (initializeTestData)
        {
            Invoke("CreateTestData", 0.3f);
        }
        else
        {
            if (useTestDataAsGameData)
            {
                gameData = testData;
            }
        }
    }
    GameDataGooglePlay GetGameDataFromJson(byte[] gameData)
    {
        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
        string             stringData     = encoding.GetString(gameData, 0, gameData.Length);
        GameDataGooglePlay newGameData    = new GameDataGooglePlay();
        JsonArray          objects        = (JsonArray)JsonNode.ParseJsonString(stringData);
        int counter = 0;

        foreach (JsonObject valueObject in objects)
        {
            int caseSwitch = counter;
            Debug.Log(valueObject.ToJsonString());
            // Debug.Log(valueObject[0]);
            GameDataVariables gdv = (GameDataVariables)counter;
            switch (gdv)
            {
            case GameDataVariables.playerAmount:
                newGameData.playerAmount = valueObject["value"];
                playerAmount             = newGameData.playerAmount;
                break;

            case GameDataVariables.hostID:
                newGameData.hostID = valueObject["value"];
                Debug.Log("Host ID is " + newGameData.hostID);
                break;

            case GameDataVariables.gameState:
                newGameData.gameState = valueObject["value"];
                break;

            case GameDataVariables.gameStartTime:
                newGameData.gameStartTime = valueObject["value"];
                break;

            case GameDataVariables.matchID:
                newGameData.matchID = valueObject["value"];
                break;

            case GameDataVariables.roundWinnerPlayerNumber:
                newGameData.roundWinnerPlayerNumber = valueObject["value"];
                break;

            case GameDataVariables.round:
                newGameData.round = valueObject["value"];
                break;

            case GameDataVariables.guestion:
                newGameData.guestion = valueObject["value"];
                break;

            case GameDataVariables.roundDeciderPID:
                newGameData.roundDeciderPID = valueObject["value"];
                break;

            case GameDataVariables.readyStates:
                List <string> stringList = getListValue(playerAmount, valueObject);
                newGameData.readyStates = ListStringConvert(stringList, true);
                break;

            case GameDataVariables.playerIDS:
                List <string> stringList2 = getListValue(playerAmount, valueObject);
                newGameData.playerIDS = stringList2;
                break;

            case GameDataVariables.playerPoints:
                List <string> stringList3 = getListValue(playerAmount, valueObject);
                newGameData.playerPoints = ListStringConvert(stringList3);
                break;

            case GameDataVariables.roundImageURLs:
                List <string> stringList4 = getListValue(playerAmount, valueObject);
                newGameData.roundImageURLs = stringList4;
                break;

            case GameDataVariables.winnerVotes:
                List <string> stringList5 = getListValue(playerAmount, valueObject);
                newGameData.winnerVotes = ListStringConvert(stringList5);
                break;
            }
            counter++;
        }

        return(newGameData);
    }
 public void SetNewGameDataFromGooglePlay(byte[] newData)
 {
     Debug.Log("setting new game data from googleplay gamedata"); //TODO maybe need to add some parsin to see if it contradicts with myown data.
     gameData = GetGameDataFromJson(newData);
 }
    public void CreateAlbumOnGameStarted()
    {
        GameDataGooglePlay gameData = Common.roundInformation.gameData;

        Common.galleryManager.CreateAlbum(gameData.hostID, gameData.matchID);
    }
 public void GoToGameStateBasedOnData(GameDataGooglePlay givenData)
 {
 }