public static void Initialize() { if (Instance == null) { Instance = GetSynchronousCodeGeneratedInstance<CoreEvents>(); SoomlaUtils.LogDebug(TAG, "Initializing CoreEvents and Soomla Core ..."); #if UNITY_ANDROID && !UNITY_EDITOR AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniStoreConfigClass = new AndroidJavaClass("com.soomla.SoomlaConfig")) { jniStoreConfigClass.SetStatic("logDebug", CoreSettings.DebugMessages); } // Initializing SoomlaEventHandler using(AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.core.unity.SoomlaEventHandler")) { jniEventHandler.CallStatic("initialize"); } // Initializing Soomla Secret using(AndroidJavaClass jniSoomlaClass = new AndroidJavaClass("com.soomla.Soomla")) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = jc.GetStatic<AndroidJavaObject>("currentActivity"); jniSoomlaClass.CallStatic("initialize", currentActivity, CoreSettings.SoomlaSecret); } AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS && !UNITY_EDITOR soomlaCore_Init(CoreSettings.SoomlaSecret, CoreSettings.DebugMessages); #elif UNITY_WP8 && !UNITY_EDITOR SoomlaWpCore.SoomlaConfig.logDebug = CoreSettings.DebugMessages; SoomlaWpCore.Soomla.initialize(CoreSettings.SoomlaSecret); BusProvider.Instance.Register(CoreEvents.instance); #endif } }
public void onRewardTaken(RewardTakenEvent _Event) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onRewardTaken:" + _Event.RewardId); string rewardId = _Event.RewardId; CoreEvents.OnRewardTaken(Reward.GetReward(rewardId)); }
virtual protected void _setTimesGiven(Reward reward, bool up, bool notify) { #if UNITY_EDITOR int total = _getTimesGiven(reward) + (up ? 1 : -1); if (total < 0) { total = 0; } string key = keyRewardTimesGiven(reward.ID); PlayerPrefs.SetString(key, total.ToString()); if (up) { key = keyRewardLastGiven(reward.ID); PlayerPrefs.SetString(key, (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond).ToString()); } if (notify) { if (up) { CoreEvents.OnRewardGiven(reward); } else { CoreEvents.OnRewardTaken(reward); } } #endif }
public static void Initialize() { if (Instance == null) { Instance = GetSynchronousCodeGeneratedInstance <CoreEvents>(); SoomlaUtils.LogDebug(TAG, "Initializing CoreEvents and Soomla Core ..."); #if UNITY_ANDROID && !UNITY_EDITOR AndroidJNI.PushLocalFrame(100); using (AndroidJavaClass jniStoreConfigClass = new AndroidJavaClass("com.soomla.SoomlaConfig")) { jniStoreConfigClass.SetStatic("logDebug", CoreSettings.DebugMessages); } // Initializing SoomlaEventHandler using (AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.core.unity.SoomlaEventHandler")) { jniEventHandler.CallStatic("initialize"); } // Initializing Soomla Secret using (AndroidJavaClass jniSoomlaClass = new AndroidJavaClass("com.soomla.Soomla")) { jniSoomlaClass.CallStatic("initialize", CoreSettings.SoomlaSecret); } AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS && !UNITY_EDITOR soomlaCore_Init(CoreSettings.SoomlaSecret, CoreSettings.DebugMessages); #elif UNITY_WP8 && !UNITY_EDITOR SoomlaWpCore.SoomlaConfig.logDebug = CoreSettings.DebugMessages; SoomlaWpCore.Soomla.initialize(CoreSettings.SoomlaSecret); BusProvider.Instance.Register(CoreEvents.instance); #endif } }
/// <summary> /// Initializes game state before the game starts. /// </summary> void Awake(){ if(instance == null){ // making sure we only initialize one instance. instance = this; GameObject.DontDestroyOnLoad(this.gameObject); Initialize(); } else { // Destroying unused instances. GameObject.Destroy(this.gameObject); } }
/// <summary> /// Will be called when a reward was given to the user. /// </summary> /// <param name="message">Will contain a JSON representation of a <c>Reward</c> and a flag saying if it's a Badge or not.</param> public void onRewardTaken(string message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onRewardTaken:" + message); JSONObject eventJSON = new JSONObject(message); string rewardId = eventJSON["rewardId"].str; CoreEvents.OnRewardTaken(Reward.GetReward(rewardId)); }
/// <summary> /// Will be called on custom events. Used for internal operations. /// </summary> public void onCustomEvent(string message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onCustomEvent:" + message); JSONObject eventJSON = new JSONObject(message); string name = eventJSON["name"].str; Dictionary <string, string> extra = eventJSON["extra"].ToDictionary(); CoreEvents.OnCustomEvent(name, extra); }
/// <summary> /// Initializes game state before the game starts. /// </summary> void Awake() { if (instance == null) // making sure we only initialize one instance. { instance = this; GameObject.DontDestroyOnLoad(this.gameObject); Initialize(this.name); } else // Destroying unused instances. { GameObject.Destroy(this.gameObject); } }