protected void DataLoadedFromGoogle(object sender, GameEventArgs e) { #if UNITY_ANDROID && !UNITY_EDITOR var json = e.str; if (!string.IsNullOrEmpty(json)) { var newUserData = JsonUtility.FromJson <UserDataModel>(json); Debug.Log(string.Format("Old time stamp: {0}; New time stamp: {1}", UserData.StringDateTime, newUserData.StringDateTime)); if (System.DateTime.Parse(newUserData.StringDateTime) > System.DateTime.Parse(UserData.StringDateTime)) { SetNewData(json); DataWasLoaded = true; } else { SaveData(); } } else { SaveData(); } #endif isLoading = false; EventManager.Notify(this, new GameEventArgs(Events.SaveData.NEW_DATA_APPLIED)); }
public static IEnumerator GetServerTime() { string url = "https://api.backmobi.pro/session/timestamp"; UnityWebRequest www = UnityWebRequest.Get(url); yield return(www.SendWebRequest()); if (!www.isNetworkError) { string time = www.downloadHandler.text; time = time.Remove(0, ('"' + "{timestamp" + '"' + ':').Length); time = time.Remove(time.Length - 1); DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); dtDateTime = dtDateTime.AddSeconds(double.Parse(time, System.Globalization.CultureInfo.InvariantCulture.NumberFormat)); UrmobiServerDT = dtDateTime; LocalUrmobiServerDT = UrmobiServerDT.ToLocalTime(); EventManager.Notify(null, new GameEventArgs(Events.DateTime.URMOBI_DATE_GOTTEN)); ServerTimeInited = true; Debug.LogError($"Server Time: {dtDateTime}"); Debug.LogError($"Local Time: {dtDateTime.ToLocalTime()}"); } else { Debug.LogError($"ERROR {www.error}"); } }
protected void DataLoadedFromGameCenter(object sender, GameEventArgs e) { #if UNITY_IOS //Debug.Log("Event notyfied: " + e.type); var json = e.str; if (!string.IsNullOrEmpty(json)) { var newUserData = JsonUtility.FromJson <UserDataModel>(json); //Debug.Log(string.Format("Old time stamp: {0}; New time stamp: {1}", UserData.stringDateTime, newUserData.stringDateTime)); if (System.DateTime.Parse(newUserData.StringDateTime) > System.DateTime.Parse(UserData.StringDateTime)) { SetNewData(json); DataWasLoaded = true; } else { SaveData(); } } else { //Debug.Log("JSON is null or empty"); SaveData(); } #endif EventManager.Notify(this, new GameEventArgs(Events.SaveData.NEW_DATA_APPLIED)); isLoading = false; }
private void OnMouseDown() { foreach (var e in eventsToNotify) { EventManager.Notify(e, null); } }
void OnGUI() { GUI.BeginGroup(new Rect(0, 300, 350, 500)); //if (GUILayout.Button("Stop Game", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) //{ // GameplayManager.Instance.StopGame(); //} if (GUILayout.Button("Show DEFAULT AD", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { EventManager.Notify(this, new GameEventArgs(Events.ADEvents.SHOW_AD, (int)InterstitialType.Default)); } if (GUILayout.Button("Show VIDEO AD", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { EventManager.Notify(this, new GameEventArgs(Events.ADEvents.SHOW_AD, (int)InterstitialType.Video)); } if (GUILayout.Button("Show REWARD AD", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { EventManager.Notify(this, new GameEventArgs(Events.ADEvents.SHOW_AD, (int)InterstitialType.Reward)); } if (GUILayout.Button("On/Off FPS", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { fps.SetActive(!fps.activeInHierarchy); } if (GUILayout.Button("PostScore", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { GooglePlayLeaderboard.Instance.PostScore(1); } if (GUILayout.Button("LoadScore", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { GooglePlayLeaderboard.Instance.LoadScores(); } if (GUILayout.Button("LoadSingleScore", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { GooglePlayLeaderboard.Instance.LoadSingleScore(); } if (GUILayout.Button("ShowUI", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { GooglePlayLeaderboard.Instance.ShowLeaderboardUI(); } if (GUILayout.Button("load board", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) { GooglePlayLeaderboard.Instance.LoadBoard(GPGSIds.leaderboard_test_leaderboard); } //if (GUILayout.Button("Refresh Field buster", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) //{ // EventManager.Notify(new GameEvent(GameplayEvents.USE_BUSTER, (int)BusterType.ShuffleBooster), this); //} //if (GUILayout.Button("Clear Tiles of type buster", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) //{ // EventManager.Notify(new GameEvent(GameplayEvents.USE_BUSTER, (int)BusterType.BomdBooster), this); //} //if (GUILayout.Button("ADD BOMB BUSTER", GUILayout.Width(Screen.width * 0.2f), GUILayout.Height(Screen.height * 0.03f))) //{ // UserDataControl.Instance.AddBombBooster(5); //} GUI.EndGroup(); }
private static void AuthenticateSuccess_Callback(string userID, string name, string underage, string isAuthenticated, string userAlias) { //GotAuth += CreateLocalVars; onlineId = userID; userName = name; isUnderage = (underage == "true"); isSignedIn = (isAuthenticated == "true"); alias = userAlias; //Debug.Log("UserIdentifierIOS.AuthenticateSuccess_Callback() \n" //+"ID = " + userID + "\n" //+ "NAME = " + userName + "\n" //+ "UNDERAGE = " + isUnderage + "\n" //+ "SIGNED IG = " + isSignedIn + "\n" //+ "ALIAS = " + alias + "\n" //+ "CAN SAVE = " + canSave); //GetAvatar(AvatarDownloaded_Callback); //GotAuth(); EventManager.Notify(new GameEvent(GameCenterEvents.SIGNED_IN), null); }
private void MakeClickSound() { EventManager.Notify(this, new GameEventArgs(EventManager_Input.UI_TAPPED)); }
private static void DataLoaded_Callback(string json) { //Debug.Log("Loaded JSON from GC: " + json); EventManager.Notify(new GameEvent(GameCenterEvents.DATA_LOADED, json), null); }
public static void GetNISTDate() { try { System.Threading.Tasks.Task ss = System.Threading.Tasks.Task.Run( () => { System.Random ran = new System.Random(DateTime.Now.Millisecond); string serverResponse = string.Empty; // Represents the list of NIST servers string[] servers = new string[] { "129.6.15.28", "129.6.15.28", "132.163.96.1", "132.163.96.2", "64.113.32.5", "64.147.116.229", "64.125.78.85", "128.138.140.44" }; // Try each server in random order to avoid blocked requests due to too frequent request for (int i = 0; i < 5; i++) { try { // Open a StreamReader to a random time server StreamReader reader = new StreamReader(new System.Net.Sockets.TcpClient(servers[ran.Next(0, servers.Length)], 13).GetStream()); serverResponse = reader.ReadToEnd(); reader.Close(); // Check to see that the signiture is there if (serverResponse.Length > 47 && serverResponse.Substring(38, 9).Equals("UTC(NIST)")) { // Parse the date int jd = int.Parse(serverResponse.Substring(1, 5)); int yr = int.Parse(serverResponse.Substring(7, 2)); int mo = int.Parse(serverResponse.Substring(10, 2)); int dy = int.Parse(serverResponse.Substring(13, 2)); int hr = int.Parse(serverResponse.Substring(16, 2)); int mm = int.Parse(serverResponse.Substring(19, 2)); int sc = int.Parse(serverResponse.Substring(22, 2)); if (jd > 51544) { yr += 2000; } else { yr += 1999; } NIST_Date = new DateTime(yr, mo, dy, hr, mm, sc); Local_NIST_Date = NIST_Date.ToLocalTime(); EventManager.Notify(null, new GameEventArgs(Events.DateTime.NIST_DATE_GOTTEN)); break; } } catch (Exception ex) { Debug.Log($"Exception [{ex}]. Iteration [{i}] failed."); } } }); } catch (System.Exception ex) { Debug.LogError(ex); } }