public IEnumerator RequestGameRecordUpdate(NetworkedGames.GameInfoBase info) { if (info.id == -1) { WWWForm form = new WWWForm(); WWW www = new WWW(baseURL + "GameDataIndexer.php", form); yield return(www); if (checkError(www)) { Debug.Log(www.text); info.id = Int32.Parse(www.text); } } #region www handling WWWForm formU = new WWWForm(); formU.AddField("gameID", info.id); formU.AddField("json", JsonUtility.ToJson(info)); WWW wwwU = new WWW(baseURL + "GameDataUpdater.php", formU); yield return(wwwU); #endregion Debug.Log(wwwU.text); }
public void OnStartRandomGame() { int randomPackPosition = Random.Range(0, clientState.gamePacks.Count); while (!(clientState.gamePacks[randomPackPosition].IsAvailable(clientState) && !clientState.gamePacks[randomPackPosition].blocked && clientState.gamePacks[randomPackPosition].packType == GamePack.PackType.RANDOM )) { randomPackPosition++; randomPackPosition = randomPackPosition % clientState.gamePacks.Count; } int randomGamePosition = Random.Range(0, clientState.gamePacks[randomPackPosition].gameIDPairs.Count); NetworkedGames.GameInfoBase randomGame = clientState.gamePacks[randomPackPosition].gameIDPairs[randomGamePosition].gameInfo; clientState.moneyMaker = true; clientState.currentGame = randomGame as NetworkedGames.GameInfoExtended; sceneManagement.LoadGameScreen(randomGame.gameType); }
public static GameInfoBase FromJson(string json) { GameInfoBase unkownGameInfo = ScriptableObject.CreateInstance <GameInfoBase>(); JsonUtility.FromJsonOverwrite(json, unkownGameInfo); switch (unkownGameInfo.gameType) { case GameType.VISUALPROGRAMMING: GameInfoVisualProgramming gameInfoVisualProgramming = ScriptableObject.CreateInstance <GameInfoVisualProgramming>(); JsonUtility.FromJsonOverwrite(json, gameInfoVisualProgramming); //Debug.Log(gameInfoVisualProgramming.title); return(gameInfoVisualProgramming); case GameType.MESSAGEDISPLAY: GameInfoMessageDisplay gameInfoMessageDisplay = ScriptableObject.CreateInstance <GameInfoMessageDisplay>(); JsonUtility.FromJsonOverwrite(json, gameInfoMessageDisplay); return(gameInfoMessageDisplay); case GameType.HACK: GameInfoHacked gameInfoHacked = CreateInstance <GameInfoHacked>(); JsonUtility.FromJsonOverwrite(json, gameInfoHacked); return(gameInfoHacked); case GameType.ANSWERBOX: GameInfoAnswerBox gameInfoAnswerBox = CreateInstance <GameInfoAnswerBox>(); JsonUtility.FromJsonOverwrite(json, gameInfoAnswerBox); return(gameInfoAnswerBox); case GameType.NATO: GameInfoNato gameInfoNato = CreateInstance <GameInfoNato>(); JsonUtility.FromJsonOverwrite(json, gameInfoNato); return(gameInfoNato); default: throw new NotImplementedException(); } }
public static void UpdateGameData(NetworkedGames.GameInfoBase info) { ServerConnection con = Resources.Load("ServerConnection") as ServerConnection; CoroutineSupport.CoroutineComponent.StartCoroutine(con.RequestGameRecordUpdate(info)); }