Inheritance: MonoBehaviour
Esempio n. 1
0
    // Test buttons to SendTags and SendPurchase to test segments on gamethrive.com
    void OnGUI()
    {
        GUIStyle customTextSize = new GUIStyle("button");

        customTextSize.fontSize = 30;

        GUIStyle customBoxSize = new GUIStyle("box");

        customBoxSize.fontSize = 30;

        GUI.Box(new Rect(10, 10, 390, 250), "Test Menu", customBoxSize);

        if (GUI.Button(new Rect(60, 80, 300, 60), "SendTags", customTextSize))
        {
            GameThrive.SendTag("UnityTestKey", "TestValue");
        }

        if (GUI.Button(new Rect(60, 170, 300, 60), "SendPurchase", customTextSize))
        {
            GameThrive.SendPurchase(2.57d);
        }

        if (extraMessage != null)
        {
            GUI.Box(new Rect(60, 300, 400, 60), extraMessage, customBoxSize);
        }
    }
Esempio n. 2
0
 void Start()
 {
     extraMessage = null;
     textStatic   = text;
     // Call before using any other methods on GameThrive.
     // Should only be called once when your game is loaded.
     GameThrive.Init("7159e91c-aae9-11e4-a836-1b616324191f", "1038037127124", HandleNotification);
 }
	public void FireNotificationReceivedEvent(string jsonString, GameThrive.NotificationReceived notificationReceived) {
		var dict = Json.Deserialize(jsonString) as Dictionary<string, object>;
		Dictionary<string, object> additionalData = null;
		if (dict.ContainsKey("custom"))
			additionalData = dict["custom"] as Dictionary<string, object>;

		notificationReceived((string)(dict["alert"]), additionalData, (bool)dict["isActive"]);
	}
Esempio n. 4
0
    void Start()
    {
        extraMessage = null;

        // Call before using any other methods on GameThrive.
        // Should only be called once when your game is loaded.
        GameThrive.Init("b49e69ca-d0b8-11e3-97bf-c3d1433e8bc1", "703322744261", HandleNotification);
    }
Esempio n. 5
0
 public GameThriveWP(string appId)
 {
     GameThriveSDK.GameThrive.Init(appId, (additionalData, isActive) => {
         if (GameThrive.notificationDelegate != null)
         {
             GameThrive.notificationDelegate("", additionalData.ToDictionary(pair => pair.Key, pair => (object)pair.Value), isActive);
         }
     });
 }
Esempio n. 6
0
    void Start()
    {
        extraMessage = null;

        // The only required method you need to call to setup GameThrive to recieve push notifications.
        // Call before using any other methods on GameThrive.
        // Should only be called once when your game is loaded.
        // GameThrive.Init(GameThrive_AppId, GoogleProjectNumber, NotificationReceivedHandler(optional));
        GameThrive.Init("b49e69ca-d0b8-11e3-97bf-c3d1433e8bc1", "703322744261", HandleNotification);
    }
Esempio n. 7
0
    void Start()
    {
        extraMessage = null;

        // The only required method you need to call to setup GameThrive to recieve push notifications.
        // Call before using any other methods on GameThrive.
        // Should only be called once when your game is loaded.
        // GameThrive.Init(GameThrive_AppId, GoogleProjectNumber, NotificationReceivedHandler(optional));
        GameThrive.Init("0e3f3ad6-c7ee-11e4-9aca-47e056863935", "660292827653", HandleNotification);
    }
Esempio n. 8
0
    // Use this for initialization
    void Start()
    {
        GameThrive.Init("7159e91c-aae9-11e4-a836-1b616324191f", "1038037127124", HandleNotification, true);
        ActivityInfo currentActivity = DataStore.LoadLastActivity();

        if (currentActivity != null)
        {
            activity          = currentActivity;
            textDistance.text = "" + activity.distance + " KM";
            textTime.text     = "" + "" + getValue((int)(activity.time / 3600)) + ":" + getValue((int)(activity.time / 60) % 60) + ":" + getValue((int)(activity.time % 60));
            currentTime       = activity.time;
        }
        if (googleLogout != null)
        {
            googleLogout.gameObject.SetActive(false);
        }
        if (googleAchievements != null)
        {
            googleAchievements.gameObject.SetActive(false);
        }
        if (googleLeadersBoard != null)
        {
            googleLeadersBoard.gameObject.SetActive(false);
        }
                #if UNITY_ANDROID && !UNITY_EDITOR
        staticText = text;
        try{
            if (androidPlugin == null)
            {
                using (AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                {
                    activityContext = activityClass.GetStatic <AndroidJavaObject>("currentActivity");
                }
                using (AndroidJavaClass pluginClass = new AndroidJavaClass("udea.telesalud.artica.com.plugin.AndroidPlugin"))
                {
                    if (pluginClass != null)
                    {
                        androidPlugin = pluginClass.CallStatic <AndroidJavaObject>("instance");
                        activityContext.Call("runOnUiThread", new AndroidJavaRunnable(() => {
                            androidPlugin.Call("setContext", activityContext);
                            androidPlugin.Call("setCurrentDistance", activity.distance);
                        }));
                    }
                }
            }
        }
        catch (UnityException ex) {
            staticText.text = ex.Message.ToString();
        }
        catch (AndroidJavaException ex)
        {
            staticText.text = ex.Message.ToString();
        }
                #endif
    }
    public void FireNotificationReceivedEvent(string jsonString, GameThrive.NotificationReceived notificationReceived)
    {
        var dict = Json.Deserialize(jsonString) as Dictionary<string, object>;

        string message = (string)(dict["alertMessage"]);
        dict.Remove("alertMessage");

        bool isActive = (bool)dict["isActive"];
        dict.Remove("isActive");

        notificationReceived(message, dict, isActive);
    }
Esempio n. 10
0
    // Test Menu
    // Includes SendTag/SendTags and getting the playerID and pushToken
    void OnGUI()
    {
        GUIStyle customTextSize = new GUIStyle("button");

        customTextSize.fontSize = 30;

        GUIStyle guiBoxStyle = new GUIStyle("box");

        guiBoxStyle.fontSize = 30;

        GUI.Box(new Rect(10, 10, 390, 250), "Test Menu", guiBoxStyle);

        if (GUI.Button(new Rect(60, 80, 300, 60), "SendTags", customTextSize))
        {
            // You can tags users with key value pairs like this:
            GameThrive.SendTag("UnityTestKey", "TestValue");
            // Or use an IDictionary if you need to set more than one tag.
            GameThrive.SendTags(new Dictionary <string, string>()
            {
                { "UnityTestKey2", "value2" }, { "UnityTestKey3", "value3" }
            });

            // You can delete a single tag with it's key.
            // GameThrive.DeleteTag("UnityTestKey");
            // Or delete many with an IList.
            // GameThrive.DeleteTags(new List<string>() {"UnityTestKey2", "UnityTestKey3" });
        }

        if (GUI.Button(new Rect(60, 170, 300, 60), "GetIds", customTextSize))
        {
            GameThrive.GetIdsAvailable((playerId, pushToken) => {
                extraMessage = "PlayerID:\n" + playerId + "\n\nPushToken:\n" + pushToken;
            });
        }

        if (extraMessage != null)
        {
            guiBoxStyle.alignment = TextAnchor.UpperLeft;
            guiBoxStyle.wordWrap  = true;
            GUI.Box(new Rect(10, 300, Screen.width - 20, Screen.height - 310), extraMessage, guiBoxStyle);
        }
    }
 // Doesn't apply to Windows Phone: The Callback is setup in the constructor so this is never called.
 public void FireNotificationReceivedEvent(string jsonString, GameThrive.NotificationReceived notificationReceived) {}
Esempio n. 12
0
    void Start()
    {
        GameThrive.Init("7159e91c-aae9-11e4-a836-1b616324191f", "1038037127124", HandleNotification, true);

        if (googleLogout != null)
        {
            googleLogout.gameObject.SetActive(false);
        }
        if (googleAchievements != null)
        {
            googleAchievements.gameObject.SetActive(false);
        }
        if (googleLeadersBoard != null)
        {
            googleLeadersBoard.gameObject.SetActive(false);
        }
        if (googleQuests != null)
        {
            googleQuests.gameObject.SetActive(false);
        }
        if (googleInbox != null)
        {
            googleInbox.gameObject.SetActive(false);
        }

        if (googleGifts != null)
        {
            googleGifts.gameObject.SetActive(false);
        }
        if (googleRequests != null)
        {
            googleRequests.gameObject.SetActive(false);
        }
        if (googleSavedGames != null)
        {
            googleSavedGames.gameObject.SetActive(false);
        }
                #if UNITY_ANDROID && !UNITY_EDITOR
        staticText = text;
        try{
            if (androidPlugin == null)
            {
                using (AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                {
                    activityContext = activityClass.GetStatic <AndroidJavaObject>("currentActivity");
                }
                using (AndroidJavaClass pluginClass = new AndroidJavaClass("com.artica.juegohabitos.androidplugins.GooglePlayServicesPlugin"))
                {
                    if (pluginClass != null)
                    {
                        androidPlugin = pluginClass.CallStatic <AndroidJavaObject>("instance");
                        activityContext.Call("runOnUiThread", new AndroidJavaRunnable(() => {
                            androidPlugin.Call("setContext", activityContext);
                        }));
                    }
                }
            }
        }
        catch (UnityException ex) {
            staticText.text = ex.Message.ToString();
        }
        catch (AndroidJavaException ex)
        {
            staticText.text = ex.Message.ToString();
        }
                #endif
    }
Esempio n. 13
0
 public void IdsAvailable()
 {
     GameThriveSDK.GameThrive.GetIdsAvailable((playerId, channelUri) => {
         GameThrive.idsAvailableDelegate(playerId, channelUri);
     });
 }
Esempio n. 14
0
 public void GetTags()
 {
     GameThriveSDK.GameThrive.GetTags((tags) => {
         GameThrive.tagsReceivedDelegate(tags.ToDictionary(pair => pair.Key, pair => (object)pair.Value));
     });
 }
Esempio n. 15
0
    //private int LastNotificationId = 0;


    // Use this for initialization
    void Start()
    {
        if (progress.Count == 0)
        {
            getProgress();
            staticClass.initLevels();
            market.SetActive(true);
            if (progress["sound"] == 0)
            {
                setSound(false);
            }
            if (progress["music"] == 1)
            {
                GameObject.Find("music").GetComponent <AudioSource>().enabled = true;
            }
            //опции
            GameObject.Find("settings folder").transform.GetChild(0).gameObject.SetActive(true);
            GameObject.Find(Localization.language).GetComponent <UIToggle>().value = true;
            GameObject.Find("settings folder").transform.GetChild(0).gameObject.SetActive(false);
            //
            //push
            GameThrive.Init("0e3f3ad6-c7ee-11e4-9aca-47e056863935", "660292827653", HandleNotification);
            GoogleCloudMessageService.instance.InitPushNotifications();
            Debug.Log("......................................");
            //AndroidNotificationManager.instance.ScheduleLocalNotification(Localization.Get("notiferTitleDay"), "notiferTitleDay", 600);
            //AndroidNotificationManager.instance.OnNotificationIdLoaded += OnNotificationIdLoaded;
            //AndroidNotificationManager.instance.LocadAppLaunchNotificationId();

            List <LocalNotificationTemplate> PendingNotifications;
            PendingNotifications = AndroidNotificationManager.instance.LoadPendingNotifications();
            bool flagNotifer = false;
            foreach (var PendingNotification in PendingNotifications)
            {
                if (PendingNotification.title == Localization.Get("notiferTitleDay"))
                {
                    if (PendingNotification.fireDate.Day == DateTime.Now.Day)
                    {
                        AndroidNotificationManager.instance.CancelLocalNotification(PendingNotification.id);
                        AndroidNotificationManager.instance.ScheduleLocalNotification(Localization.Get("notiferTitleDay"), Localization.Get("notiferMessageDay"), 60 * 60 * 24);
                    }
                    flagNotifer = true;
                }
            }
            if (!flagNotifer)
            {
                AndroidNotificationManager.instance.ScheduleLocalNotification(Localization.Get("notiferTitleDay"), Localization.Get("notiferMesssageDay"), 60 * 60 * 24);
            }

            Debug.Log("......................................");
            //
        }


        if (GooglePlayConnection.state == GPConnectionState.STATE_CONNECTED)
        {
            achievements.SetActive(true);
            leaderboards.SetActive(true);
            googlePlus.SetActive(false);
        }
        else if (progress["googlePlay"] == 1)
        {
            GooglePlayConnection.instance.connect();
        }

        //listen for GooglePlayConnection events
        GooglePlayConnection.instance.addEventListener(GooglePlayConnection.PLAYER_CONNECTED, OnPlayerConnected);
        GooglePlayConnection.instance.addEventListener(GooglePlayConnection.PLAYER_DISCONNECTED, OnPlayerDisconnected);
    }