protected override DateTime _getLastGivenTime(Reward reward) { string rewardJson = seqReward.toJSONObject().ToString(); long lastTime = rewardStorage_GetLastGivenTimeMillis(rewardJson); TimeSpan time = TimeSpan.FromMilliseconds(lastTime); return new DateTime(time.Ticks); }
public void ConstructRitual(int length, Difficulty difficulty) { reward = Reward.GetReward(length); ritual = new List<RitualKey>(); List<KeyCodes> keyCodesPool = new List<KeyCodes>() { KeyCodes.A, KeyCodes.B, KeyCodes.X, KeyCodes.Y }; if (difficulty == Difficulty.Medium) { keyCodesPool.AddRange(new KeyCodes[4]{ KeyCodes.Left, KeyCodes.Right, KeyCodes.Up, KeyCodes.Down }); } if (difficulty == Difficulty.Hard) { keyCodesPool.AddRange(new KeyCodes[4] { KeyCodes.LT, KeyCodes.RT, KeyCodes.LB, KeyCodes.RB }); } for (int i = 0; i < length; ++i) { RitualKey ritualKey = new RitualKey(keyCodesPool[Random.Range(0, keyCodesPool.Count)]); ritual.Add(ritualKey); } PostChangedEvent(); }
protected override int _getTimesGiven(Reward reward) { string rewardJson = reward.toJSONObject().ToString(); int times = rewardStorage_GetTimesGiven(rewardJson); SoomlaUtils.LogDebug("SOOMLA/UNITY RewardStorageIOS", string.Format("reward {0} given={1}", reward.ID, times)); return times; }
/// <summary> /// Updates the Q-Value /// </summary> /// <param name="st">The state at `t`</param> /// <param name="a">The action at `t`</param> /// <param name="r">The awarded reward at `t+1`</param> /// <param name="stplus">The state at `t+1`</param> /// <returns>The updated Q-Value</returns> protected override EligVal __update_q_value(State st, Action a, Reward r, State stplus, params object[] aplus) { if (aplus.Length == 0 || !(aplus[0] is Action)) throw new ArgumentException("Expecting an action as last comment", "aplus"); var qt = this.__get_q_value(st, a); // if a' ties for the max, the a* ← a' Action astar = (Action)aplus[0]; // Q(s', a') QVal v = this.__get_q_value(stplus, astar); // argmaxQ(s', b) foreach (var __a in this.Actions) { var __q = this.__get_q_value(stplus, __a); if (v < __q) { v = __q; astar = __a; } } // δ ← r + γ * Q(s', a*) - Q(s, a) var delta = (r + this.Gamma * this.__get_q_value(stplus, astar) - this.__get_q_value(st, a)); // e(s, a) ← e(s, a) + 1 this.__set_elig_value(st, a, this.__get_elig_value(st, a) + 1); var keys = this.QTable.Keys.Cast<KeyValuePair<State, Action>>().ToArray(); // for each s,a for (int i = 0; i < keys.Length; i++) { var sa = (KeyValuePair<State, Action>)keys[i]; // Q(s, a) ← Q(s, a) + αδe(s, a) this.__set_q_value(sa.Key, sa.Value, (QVal)this.QTable[sa] + this.Alpha * delta * this.__get_elig_value(sa.Key, sa.Value)); // if a' = a* if ((Action)aplus[0] == astar) // e(s, a) ← γλe(s, a) this.__set_elig_value(sa.Key, sa.Value, this.Gamma * this.Lambda * this.__get_elig_value(sa.Key, sa.Value)); else // e(s, a) ← 0 this.__set_elig_value(sa.Key, sa.Value, 0); } // return the updated Q-Value return this.__get_q_value(st, a); }
void Start() { _instance = this; base.Init (); missionId = 14; reward = new Reward (false, 2); animated = false; }
public static Reward getRandomReward(int value) { List<string> list = new List<string>(); string[] arr; arr = new string[]{"Copper","Iron","Silver","Gold","Demonite","Meteorite","Hellstone"}; foreach (string s in arr) list.Add(s+" Bar"); arr = new string[]{"Amethyst","Topaz","Sapphire","Emerald","Ruby","Diamond"}; foreach (string s in arr) list.Add(s); if (Main.hardMode) { arr = new string[]{"Cobalt","Mythril","Adamantite"}; foreach (string s in arr) list.Add(s+" Bar"); } while (true) { if (Main.rand.Next(3) >= 1) { string name = list[Main.rand.Next(list.Count)]; Item item = Config.itemDefs.byName[name]; if (item.value > value) continue; Reward r = new Reward(name,(int)(value/item.value)); if (r.amount <= Config.itemDefs.byName[r.itemName].maxStack) return r; } else { string type = "Copper Coin"; if (value >= 100) {value /= 100; type = "Silver Coin";} if (value >= 100) {value /= 100; type = "Gold Coin";} if (value >= 100) {value /= 100; type = "Platinum Coin";} return new Reward(type,value); } } }
protected override void _setTimesGiven(Reward reward, bool up, bool notify) { AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniRewardStorage = new AndroidJavaClass("com.soomla.data.RewardStorage")) { jniRewardStorage.CallStatic("setTimesGiven", reward.toJNIObject(), up, notify); } AndroidJNI.PopLocalFrame(IntPtr.Zero); }
override protected int _getTimesGiven(Reward reward) { int times = 0; AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniRewardStorage = new AndroidJavaClass("com.soomla.data.RewardStorage")) { times = jniRewardStorage.CallStatic<int>("getTimesGiven", reward.ID); } AndroidJNI.PopLocalFrame(IntPtr.Zero); return times; }
public void SetReward(Reward reward) { title.text = reward.name; tier.text = "Tier: " + reward.tier; type.text = "Type: " + reward.type; points.text = reward.ToString (); this.url = reward.url; StartCoroutine (DownloadImage (reward.imageURL)); }
/// <summary> /// Plays a video ad and grants the user a reward for watching it. /// </summary> /// <param name="reward">The reward that will be given to users for watching the video ad.</param> /// <param name="enableBackButton">Determines whether you would like to give the user the /// option to skip out of the video. <c>true</c> means a close button will be displayed.</param> public static void PlayAd(Reward reward, bool enableBackButton) { SoomlaUtils.LogDebug(TAG, "Playing Vungle Ad"); #if UNITY_ANDROID && !UNITY_EDITOR AndroidJNI.PushLocalFrame(100); jniSoomlaVungle.Call("playIncentivisedAd", enableBackButton, true, (reward == null ? null : reward.toJNIObject())); AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS && !UNITY_EDITOR soomlaVungle_PlayAd(enableBackButton, (reward == null ? null : reward.toJSONObject().print())); #endif }
void Start() { _instance = this; bf = BattlefieldScript.Instance; //bfc = bf.bf; su = Submarine.Instance; sh = Ship.Instance; //la = LanguageScript.Instance; mo = move.Instance; reward = new Reward (false, 2); }
public bool ForceNextRewardToGive(Reward reward) { for (int i = 0; i < Rewards.Count; i++) { if (Rewards[i].GetId() == reward.GetId()) { RewardStorage.SetLastSeqIdxGiven(mID, i - 1); return true; } } return false; }
/// <summary> /// Updates the Q-Value /// </summary> /// <param name="st">The state at `t`</param> /// <param name="a">The action at `t`</param> /// <param name="r">The awarded reward at `t+1`</param> /// <param name="stplus">The state at `t+1`</param> /// <param name="aplus">The action at `t+1`</param> /// <returns>The updated Q-Value</returns> protected override QVal __update_q_value(State st, Action a, Reward r, State stplus, params object[] aplus) { if (aplus.Length == 0 || !(aplus[0] is Action)) throw new ArgumentException("Expecting an action as last comment", "aplus"); var qt = this.__get_q_value(st, a); var v = this.__get_q_value(stplus, (Action)aplus[0]); // Q(s, a) ← (1 - α)Q(s, a) + α[r + γ * Q(s', a')] qt = (1 - this.Alpha) * qt + this.Alpha * (r + this.Gamma * v); this.__set_q_value(st, a, qt); return qt; }
void Start() { Debug.Log ("!!! MULTIPLAYER INITIATED !!!"); _instance = this; bf = BattlefieldScript.Instance; bfc = bf.bf; su = Submarine.Instance; sh = Ship.Instance; la = LanguageScript.Instance; mo = move.Instance; reward = new Reward (false, 5); }
override protected DateTime _getLastGivenTime(Reward reward) { long lastTime = 0; AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniRewardStorage = new AndroidJavaClass("com.soomla.data.RewardStorage")) { lastTime = jniRewardStorage.CallStatic<long>("getLastGivenTimeMillis", reward.ID); } AndroidJNI.PopLocalFrame(IntPtr.Zero); TimeSpan time = TimeSpan.FromMilliseconds(lastTime); return new DateTime(time.Ticks); }
public void OnPopulateRewards(Reward[] rewards) { int childCount = rewardsGrid.transform.childCount; for (int i = childCount - 1; i >= 0; i--) { Debug.Log("Deleting i: " + i); GameObject.DestroyImmediate(rewardsGrid.transform.GetChild(i).gameObject); } for (int i = 0; i < rewards.Length; i++) { Reward reward = rewards[i]; RewardObject rewardGO = (RewardObject) GameObject.Instantiate (rewardObjectPrefab); rewardGO.transform.SetParent(rewardsGrid.transform); rewardGO.transform.localScale = Vector3.one; rewardGO.SetReward (reward); } }
/// <summary> /// Updates the Q-Value /// </summary> /// <param name="st">The state at `t`</param> /// <param name="a">The action at `t`</param> /// <param name="r">The awarded reward at `t+1`</param> /// <param name="stplus">The state at `t+1`</param> /// <returns>The updated Q-Value</returns> protected override QVal __update_q_value(State st, Action a, Reward r, State stplus, params object[] o) { var qt = this.__get_q_value(st, a); QVal v = QVal.MinValue; // argmaxQ(s', b) foreach (var __a in this.Actions) { var __q = this.__get_q_value(stplus, __a); if (v < __q) v = __q; } // Q(s, a) ← (1 - α)Q(s, a) + α[r + γ * argmaxQ(s', b)] qt = (1 - this.Alpha) * qt + this.Alpha * (r + this.Gamma * v); this.__set_q_value(st, a, qt); return qt; }
protected override void OnCreate(Bundle bundle) { Log.Info("CreateRewardForm", "Create Reward Form created"); base.OnCreate(bundle); SetContentView(Resource.Layout.CreateRewardForm); var layout = FindViewById<LinearLayout>(Resource.Id.CreateRewardFormLayout); layout.SetBackgroundResource(Resource.Color.darkblue); var customRewardTitle = FindViewById<EditText>(Resource.Id.CustomRewardTitle); var customRewardContent = FindViewById<EditText>(Resource.Id.CustomRewardContent); var customRewardAddGoalButton = FindViewById<Button>(Resource.Id.CustomRewardAddGoalButton); customRewardAddGoalButton.Click += delegate { StartActivity(typeof (SelectCustomRewardGoal)); }; var submitCustomRewardButton = FindViewById<Button>(Resource.Id.SubmitCustomRewardButton); submitCustomRewardButton.Click += delegate { var title = customRewardTitle.Text; var content = customRewardContent.Text; if (_goalsList.Count != 0) { var reward = new Reward(title, content, _goalsList); var storedRewards = JavaIO.LoadData<List<Reward>>(this, "Rewards.zad"); storedRewards.Add(reward); var successfulSave = JavaIO.SaveData(this, "Rewards.zad", storedRewards); if (successfulSave) { Toast.MakeText(this, "Reward Saved", ToastLength.Long).Show(); Finish(); } else { Log.Error("CreateRewardForm", "Save reward error"); Toast.MakeText(this, "Error saving reward", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Must select a goal", ToastLength.Long).Show(); } }; }
void Start() { oh = objcHandlerObj.GetComponent<ObjectiveHandler> (); pv = player.GetComponent<PlayerVolume> (); sQstring = startQuestText.text; fQstring = finishQuestText.text; char[] delimitingChars = {'\n'}; sQLines = sQstring.Split (delimitingChars); fQLines = fQstring.Split (delimitingChars); ch = chatHandlerObject.GetComponent<ChatHandler> (); npcb = this.GetComponent<NPCBehaviour> (); objectContainer = questObjectContainer.transform; questStarted = false; questFinished = false; r = new Reward (0, levelReward); q = new Quest (this.gameObject, r, quest_name, quest_description); }
/// <summary> /// Plays a video ad and grants the user a reward for watching it. /// </summary> /// <param name="reward">The reward that will be given to users for watching the video ad.</param> /// <param name="enableBackButton">Determines whether you would like to give the user the /// option to skip out of the video. <c>true</c> means a close button will be displayed.</param> public static void PlayAd(Reward reward, bool enableBackButton) { SoomlaUtils.LogDebug(TAG, "Playing Vungle Ad"); savedReward = reward; #if UNITY_ANDROID && !UNITY_EDITOR AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniSoomlaVungleClass = new AndroidJavaClass("com.soomla.plugins.ads.vungle.SoomlaVungle")) { using(AndroidJavaObject jniSoomlaVungle = jniSoomlaVungleClass.CallStatic<AndroidJavaObject>("getInstance")) { jniSoomlaVungle.Call("playIncentivisedAd", enableBackButton, true, null); } } AndroidJNI.PopLocalFrame(IntPtr.Zero); #elif UNITY_IOS && !UNITY_EDITOR soomlaVungle_PlayAd(enableBackButton); #endif }
protected override bool Check() { if (Game.runtimeData.user.currentStamina > MyGame.config.automation.recovery.threshold) { MyLog.Debug("目前體力 [{0}] 大於設定值 [{1}],暫時不補充體力", Game.runtimeData.user.currentStamina, MyGame.config.automation.recovery.threshold); return false; } if (MyGame.config.automation.recovery.reward) { foreach (var candidate in Game.runtimeData.rewards) { if (candidate.rewardType == Reward.Type.RECOVERY && candidate.isAvailable && !candidate.claimed) { usage = RecoveryKind.Reward; reward = candidate; return true; } } MyLog.Debug("獎勵不足,無法回復體力"); } else { MyLog.Debug("未允許使用獎勵回復體力"); } if (MyGame.config.automation.recovery.diamond) { if (Game.runtimeData.user.diamond > 0) { usage = RecoveryKind.Diamond; return true; } MyLog.Debug("魔法石不足,無法回復體力"); } else { MyLog.Debug("未允許使用魔法石回復體力"); } return false; }
/// <summary> /// Updates the Q-Value /// </summary> /// <param name="st">The state at `t`</param> /// <param name="a">The action at `t`</param> /// <param name="r">The awarded reward at `t+1`</param> /// <param name="stplus">The state at `t+1`</param> /// <param name="aplus">The action at `t+1`</param> /// <returns>The updated Q-Value</returns> protected override EligVal __update_q_value(State st, Action a, Reward r, State stplus, params object[] aplus) { if (aplus.Length == 0 || !(aplus[0] is Action)) throw new ArgumentException("Expecting an action as last comment", "aplus"); // δ ← r + γ * Q(s', a') - Q(s, a) var delta = (r + this.Gamma * this.__get_q_value(stplus, (Action)aplus[0]) - this.__get_q_value(st, a)); // e(s, a) ← e(s, a) + 1 this.__set_elig_value(st, a, this.__get_elig_value(st, a) + 1); var keys = this.QTable.Keys.Cast<KeyValuePair<State, Action>>().ToArray(); // for each s,a for (int i = 0; i < keys.Length; i++) { var sa = (KeyValuePair<State, Action>)keys[i]; // Q(s, a) ← Q(s, a) + αδe(s, a) this.__set_q_value(sa.Key, sa.Value, (QVal)this.QTable[sa] + this.Alpha * delta * this.__get_elig_value(sa.Key, sa.Value)); // e(s, a) ← γλe(s, a) this.__set_elig_value(sa.Key, sa.Value, this.Gamma * this.Lambda * this.__get_elig_value(sa.Key, sa.Value)); } return this.__get_q_value(st, a); }
private void DropEachReward(Reward reward) { Vector3 dropLocation; Transform playerTransform = transform.FindChild("Player"); Player player = (playerTransform != null) ? playerTransform.GetComponent<Player>() : null; Tile tile = gameObject.GetComponent<Tile>(); if (player != null) { Vector3 pos = player.transform.position; dropLocation = pos += new Vector3(Random.Range(-1, 1), Random.Range(-1, 1), transform.position.z); } else { dropLocation = transform.position; } Reward rewardGo = (Reward)Instantiate(reward, dropLocation, Quaternion.identity); rewardGo.transform.parent = transform; SpriteRenderer rewardSr = rewardGo.GetComponent<SpriteRenderer>(); Debug.Log(rewardSr.sortingOrder); rewardSr = Util.SetTopOrder(transform, rewardSr); Debug.Log(rewardSr.sortingOrder); }
//Reward events void RewardAd_OnUserEarnedReward(object sender, Reward e) { rewardBox.isAdWatched = true; }
public override bool Failure() { return(Reward.Get() < -1.8F); }
/// <summary> /// Initializes the SOOMLA Profile Module. /// /// NOTE: This function must be called before any of the class methods can be used. /// </summary> public static void Initialize() { Dictionary <Provider, Dictionary <string, string> > customParams = GetCustomParamsDict(); instance._initialize(GetCustomParamsJson(customParams)); //add parameters #if SOOMLA_FACEBOOK unreadyProviders++; providers.Add(Provider.FACEBOOK, new FBSocialProvider()); #endif #if SOOMLA_GOOGLE unreadyProviders++; providers.Add(Provider.GOOGLE, new GPSocialProvider()); #endif #if SOOMLA_TWITTER unreadyProviders++; providers.Add(Provider.TWITTER, new TwitterSocialProvider()); #endif // pass params to non-native providers foreach (KeyValuePair <Provider, SocialProvider> entry in providers) { if (!entry.Value.IsNativelyImplemented()) { entry.Value.Configure(customParams[entry.Key]); } } ProfileEvents.OnSoomlaProfileInitialized += () => { // auto login non-native providers foreach (KeyValuePair <Provider, SocialProvider> entry in providers) { if (!entry.Value.IsNativelyImplemented()) { if (entry.Value.IsAutoLogin()) { Provider provider = entry.Key; if (wasLoggedInWithProvider(provider)) { string payload = ""; Reward reward = null; if (entry.Value.IsLoggedIn()) { entry.Value.GetUserProfile((UserProfile userProfile) => { setLoggedInForProvider(provider, false); ProfileEvents.OnLoginStarted(provider, true, payload); StoreUserProfile(userProfile); setLoggedInForProvider(provider, true); ProfileEvents.OnLoginFinished(userProfile, true, payload); if (reward != null) { reward.Give(); } }, (string message) => { ProfileEvents.OnLoginFailed(provider, message, true, payload); }); } else { login(provider, true, payload, reward); } } } } } }; #if UNITY_EDITOR TryFireProfileInitialized(); #endif }
public void HandleRewardBasedVideoRewarded(object sender, Reward args) { }
/// <summary> /// Uploads an image to the user's social page on the given Provider. /// Supported platforms: Facebook, Twitter, Google+ /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param> /// <param name="message">Message to post with the image.</param> /// <param name="fileName">Name of image file with extension (jpeg/pgn).</param> /// <param name="tex2D">Texture2D for image.</param> /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param> public static void UploadImage(Provider provider, string message, string fileName, Texture2D tex2D, string payload = "", Reward reward = null) { UploadImage(provider, message, fileName, GetImageBytesFromTexture(fileName, tex2D), 100, payload, reward); }
/// <summary> /// Uploads the current screen shot image to the user's social page on the given Provider. /// Supported platforms: Facebook /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="mb">Mb.</param> /// <param name="provider">The <c>Provider</c> the given screenshot should be uploaded to.</param> /// <param name="title">The title of the screenshot.</param> /// <param name="message">Message to post with the screenshot.</param> /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param> public static void UploadCurrentScreenShot(MonoBehaviour mb, Provider provider, string title, string message, string payload = "", Reward reward = null) { mb.StartCoroutine(TakeScreenshot(provider, title, message, payload, reward)); }
void OnAdRewarded(object sender, Reward e) { Debug.Log("OnAdRewarded"); }
private static void login(Provider provider, bool autoLogin, string payload = "", Reward reward = null) { SoomlaUtils.LogDebug(TAG, "Trying to login with provider " + provider.ToString()); SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) { SoomlaUtils.LogError(TAG, "Provider not supported or not set as active: " + provider.ToString()); return; } if (targetProvider.IsNativelyImplemented()) { //fallback to native string rewardId = reward != null ? reward.ID : ""; instance._login(provider, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString()); } else { setLoggedInForProvider(provider, false); ProfileEvents.OnLoginStarted(provider, autoLogin, userPayload); targetProvider.Login( /* success */ () => { targetProvider.GetUserProfile((UserProfile userProfile) => { StoreUserProfile(userProfile); setLoggedInForProvider(provider, true); ProfileEvents.OnLoginFinished(userProfile, autoLogin, userPayload); if (reward != null) { reward.Give(); } }, (string message) => { ProfileEvents.OnLoginFailed(provider, message, autoLogin, userPayload); }); }, /* fail */ (string message) => { ProfileEvents.OnLoginFailed(provider, message, autoLogin, userPayload); }, /* cancel */ () => { ProfileEvents.OnLoginCancelled(provider, autoLogin, userPayload); } ); } }
/// <summary> /// Uploads the current screen shot image to the user's social page on the given Provider. /// Supported platforms: Facebook /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="mb">Mb.</param> /// <param name="provider">The <c>Provider</c> the given screenshot should be uploaded to.</param> /// <param name="title">The title of the screenshot.</param> /// <param name="message">Message to post with the screenshot.</param> /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param> public static void UploadCurrentScreenShot(MonoBehaviour mb, Provider provider, string title, string message, string payload="", Reward reward = null) { mb.StartCoroutine(TakeScreenshot(provider, title, message, payload, reward)); }
public static void Invite(Provider provider, string inviteMessage, string dialogTitle = null, string payload="", Reward reward = null) { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) return; if (targetProvider.IsNativelyImplemented()) { //fallback to native string rewardId = reward != null ? reward.ID: ""; //TODO: add invite implementation when implemented in native instance._invite(provider, inviteMessage, dialogTitle, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString()); } else { ProfileEvents.OnInviteStarted(provider, userPayload); targetProvider.Invite(inviteMessage, dialogTitle, /* success */ (string requestId, List<string> invitedIds) => { if (reward != null) { reward.Give(); } ProfileEvents.OnInviteFinished(provider, requestId, invitedIds, userPayload); }, /* fail */ (string message) => { ProfileEvents.OnInviteFailed(provider, message, userPayload); }, /* cancel */ () => { ProfileEvents.OnInviteCancelled(provider, userPayload); }); } }
/// <summary> /// Uploads an image to the user's social page on the given Provider. /// Supported platforms: Facebook, Twitter, Google+ /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param> /// <param name="message">Message to post with the image.</param> /// <param name="fileName">Name of image file with extension (jpeg/pgn).</param> /// <param name="imageBytes">Image bytes.</param> /// <param name="jpegQuality">Image quality, number from 0 to 100. 0 meaning compress for small size, 100 meaning compress for max quality. /// Some formats, like PNG which is lossless, will ignore the quality setting /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param> public static void UploadImage(Provider provider, string message, string fileName, byte[] imageBytes, int jpegQuality, string payload="", Reward reward = null) { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) return; if (targetProvider.IsNativelyImplemented()) { string rewardId = reward != null ? reward.ID: ""; instance._uploadImage(provider, message, fileName, imageBytes, jpegQuality, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString(), false, null); } else { ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPLOAD_IMAGE, userPayload); targetProvider.UploadImage(imageBytes, fileName, message, /* success */ () => { if (reward != null) { reward.Give(); } ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPLOAD_IMAGE, userPayload); }, /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed (provider, SocialActionType.UPLOAD_IMAGE, error, userPayload); }, /* cancel */ () => { ProfileEvents.OnSocialActionCancelled(provider, SocialActionType.UPLOAD_IMAGE, userPayload); } ); } }
public static void OnRewardObtained(Reward reward) { current.rewards.Add(reward); }
//TODO: Add discounts public MissionResult(HumanPlayer player, double progression, Mission.Mission lastMission, List <Armour> loot, string closeButtonText) { InitializeComponent(); this.player = player; nextMission.Text = closeButtonText; //Enable level up levelUpButton.Enabled = player.storedLevelUps != 0; levelUpButton.Text = $"Level up x{player.storedLevelUps}"; //Generate reward Reward _reward = lastMission.Reward(); if (_reward.jewelryReward != null) { if (_reward.jewelryReward.jewelries != null) { reward.AddRange(_reward.jewelryReward.jewelries); } while (_reward.jewelryReward.number != 0) { //Determine the quality MathNet.Numerics.Distributions.Normal normal = new MathNet.Numerics.Distributions.Normal(); int offset = (int)normal.InverseCumulativeDistribution(World.random.NextDouble()); int num = E.GetQualityPos(_reward.jewelryReward.quality) + offset; num = Math.Min(Math.Max(num, 0), Enum.GetNames(typeof(Quality)).Length); //Bound the value Quality quality = E.GetQuality(num); reward.Add(Jewelry.GenerateJewelry(quality)); _reward.jewelryReward.number--; } } if (!(_reward.weaponReward is null)) { reward.Add(Campaign.CalculateWeaponReward(_reward.weaponReward, (int)(progression * 10), 10)); } if (!(_reward.spellReward is null)) { Spell spell = _reward.spellReward.spell; if (spell != null && !player.spells.Exists(s => spell.name == s.name)) { reward.Add(spell); } } if (_reward.Money != 0) { reward.Add(new Coin(_reward.Money)); } if (_reward.itemReward != null) { reward.Add(_reward.itemReward.reward); } reward.AddRange(loot); //Populate reward list foreach (var item in reward) { lootList.Items.Add(item); } playerView.Activate(player, null, false); Render(); }
public void AddReward(Reward reward) { reward.RewardId = id++; rewards.Add(reward); }
public void OnRewarded(Reward reward) { Debug.Log("[HMS] AdsDemoManager rewarded!"); }
/// <summary> /// Logs the user into the given provider. /// Supported platforms: Facebook, Twitter, Google+ /// </summary> /// <param name="provider">The provider to log in to.</param> /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful login.</param> public static void Login(Provider provider, string payload = "", Reward reward = null) { login(provider, false, payload, reward); }
public BaseSeason(IUExport export, string assetFolder) : this() { if (export.GetExport <TextProperty>("DisplayName") is TextProperty displayName) { DisplayName = Text.GetTextPropertyBase(displayName); } if (export.GetExport <StructProperty>("SeasonFirstWinRewards") is StructProperty s && s.Value is UObject seasonFirstWinRewards && seasonFirstWinRewards.GetExport <ArrayProperty>("Rewards") is ArrayProperty rewards) { foreach (StructProperty reward in rewards.Value) { if (reward.Value is UObject o && o.GetExport <SoftObjectProperty>("ItemDefinition") is SoftObjectProperty itemDefinition && o.GetExport <IntProperty>("Quantity") is IntProperty quantity) { FirstWinReward = new Reward(quantity, itemDefinition.Value); } } } if (export.GetExport <StructProperty>("BookXpScheduleFree") is StructProperty r2 && r2.Value is UObject bookXpScheduleFree && bookXpScheduleFree.GetExport <ArrayProperty>("Levels") is ArrayProperty levels2) { for (int i = 0; i < levels2.Value.Length; i++) { BookXpSchedule[i] = new List <Reward>(); // init list for all reward index and once if (levels2.Value[i] is StructProperty level && level.Value is UObject l && l.GetExport <ArrayProperty>("Rewards") is ArrayProperty elRewards && elRewards.Value.Length > 0) { foreach (StructProperty reward in elRewards.Value) { if (reward.Value is UObject o && o.GetExport <SoftObjectProperty>("ItemDefinition") is SoftObjectProperty itemDefinition && !itemDefinition.Value.AssetPathName.String.StartsWith("/Game/Items/Tokens/") && !itemDefinition.Value.AssetPathName.String.StartsWith("/BattlepassS15/Items/Tokens/") && o.GetExport <IntProperty>("Quantity") is IntProperty quantity) { BookXpSchedule[i].Add(new Reward(quantity, itemDefinition.Value)); } } } } } if (export.GetExport <StructProperty>("BookXpSchedulePaid") is StructProperty r1 && r1.Value is UObject bookXpSchedulePaid && bookXpSchedulePaid.GetExport <ArrayProperty>("Levels") is ArrayProperty levels1) { for (int i = 0; i < levels1.Value.Length; i++) { if (levels1.Value[i] is StructProperty level && level.Value is UObject l && l.GetExport <ArrayProperty>("Rewards") is ArrayProperty elRewards && elRewards.Value.Length > 0) { foreach (StructProperty reward in elRewards.Value) { if (reward.Value is UObject o && o.GetExport <SoftObjectProperty>("ItemDefinition") is SoftObjectProperty itemDefinition && //!itemDefinition.Value.AssetPathName.String.StartsWith("/Game/Items/Tokens/") && o.GetExport <IntProperty>("Quantity") is IntProperty quantity) { BookXpSchedule[i].Add(new Reward(quantity, itemDefinition.Value)); } } } } } FolderName = assetFolder; AdditionalSize += 100 * (BookXpSchedule.Count / 10); }
/// <summary> /// Updates the user's status with confirmation dialog on the given provider. /// Supported platforms: Facebook, Twitter, Google+ /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> the given status should be posted to.</param> /// <param name="status">The actual status text.</param> /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful post.</param> /// <param name="customMessage">The message to show in the dialog</param> public static void UpdateStatusWithConfirmation(Provider provider, string status, string payload = "", Reward reward = null, string customMessage = null) { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) { return; } if (targetProvider.IsNativelyImplemented()) { //fallback to native string rewardId = reward != null ? reward.ID : ""; instance._updateStatus(provider, status, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString(), true, customMessage); } else { // TODO: Support showConfirmation ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPDATE_STATUS, userPayload); targetProvider.UpdateStatus(status, /* success */ () => { if (reward != null) { reward.Give(); } ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPDATE_STATUS, userPayload); }, /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed(provider, SocialActionType.UPDATE_STATUS, error, userPayload); } ); } }
private void HandleUserEarnedReward(object sender, Reward e) { _playerData.Cash += _runtimeData.CalculatedCash * _configuration.AdCashCoefficient; SceneManager.LoadScene(0); }
/// <summary> /// Uploads an image to the user's social page on the given Provider with confirmation dialog. /// Supported platforms: Facebook, Twitter, Google+ /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param> /// <param name="message">Message to post with the image.</param> /// <param name="fileName">Name of image file with extension (jpeg/pgn).</param> /// <param name="imageBytes">Image bytes.</param> /// <param name="jpegQuality">Image quality, number from 0 to 100. 0 meaning compress for small size, 100 meaning compress for max quality. /// Some formats, like PNG which is lossless, will ignore the quality setting /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param> /// <param name="customMessage">The message to show in the dialog</param> public static void UploadImageWithConfirmation(Provider provider, string message, string fileName, byte[] imageBytes, int jpegQuality, string payload = "", Reward reward = null, string customMessage = null) { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) { return; } if (targetProvider.IsNativelyImplemented()) { string rewardId = reward != null ? reward.ID: ""; instance._uploadImage(provider, message, fileName, imageBytes, jpegQuality, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString(), true, customMessage); } else { // TODO: Support showConfirmation ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPLOAD_IMAGE, userPayload); targetProvider.UploadImage(imageBytes, fileName, message, /* success */ () => { if (reward != null) { reward.Give(); } ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPLOAD_IMAGE, userPayload); }, /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed(provider, SocialActionType.UPLOAD_IMAGE, error, userPayload); }, /* cancel */ () => { ProfileEvents.OnSocialActionCancelled(provider, SocialActionType.UPLOAD_IMAGE, userPayload); } ); } }
static void RewardBasedVideo_OnAdRewarded(object sender, Reward e) { Debug.Log("**********************\n**********************\nUSER HAS BEEN REWARDED! \n "); // NOTE: We don't give extra lifes or virtual coins here. We use RewardedAdClose to reward // the user even if he didn't watch the full video ad }
public static void Invite(Provider provider, string inviteMessage, string dialogTitle = null, string payload = "", Reward reward = null) { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) { return; } if (targetProvider.IsNativelyImplemented()) { //fallback to native string rewardId = reward != null ? reward.ID: ""; //TODO: add invite implementation when implemented in native instance._invite(provider, inviteMessage, dialogTitle, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString()); } else { ProfileEvents.OnInviteStarted(provider, userPayload); targetProvider.Invite(inviteMessage, dialogTitle, /* success */ (string requestId, List <string> invitedIds) => { if (reward != null) { reward.Give(); } ProfileEvents.OnInviteFinished(provider, requestId, invitedIds, userPayload); }, /* fail */ (string message) => { ProfileEvents.OnInviteFailed(provider, message, userPayload); }, /* cancel */ () => { ProfileEvents.OnInviteCancelled(provider, userPayload); }); } }
public override string ToString() { return($"{Outcome.OutcomeString!}:{Reward.ToString(false, true)}"); }
private static IEnumerator TakeScreenshot(Provider provider, string title, string message, string payload, Reward reward) { yield return(new WaitForEndOfFrame()); var width = Screen.width; var height = Screen.height; var tex = new Texture2D(width, height, TextureFormat.RGB24, false); // Read screen contents into the texture tex.ReadPixels(new Rect(0, 0, width, height), 0, 0); tex.Apply(); UploadImage(provider, message, "current_screenshot.jpeg", tex, payload, reward); }
public void AddReward(Reward reward) { Gold += reward.Gold; XP += reward.XP; }
public void HandleRewardBasedVideoRewarded(object sender, Reward args) { print("print-HandleRewardBasedVideoRewarded"); Debug.Log("Debug-HandleRewardBasedVideoRewarded"); }
public void HandleReward(object sender, Reward args) { reward = true; }
private void RewardOnOnAdRewarded(object sender, Reward e) { IsRewardValid = true; }
private void HandleUserEarnedReward(object sender, Reward e) { // 광고를 다 봤을 때 rewarded = true; // 변수 true GoldRobotManager.ticket_AD--; }
/// <summary> /// Uploads an image to the user's social page on the given Provider. /// Supported platforms: Facebook, Twitter, Google+ /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param> /// <param name="message">Message to post with the image.</param> /// <param name="fileName">Name of image file with extension (jpeg/pgn).</param> /// <param name="tex2D">Texture2D for image.</param> /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param> public static void UploadImage(Provider provider, string message, string fileName, Texture2D tex2D, string payload="", Reward reward = null) { UploadImage (provider, message, fileName, GetImageBytesFromTexture (fileName, tex2D), 100, payload, reward); }
public SpawnPlayerParamsBuilder PendingReward(Reward pendingReward) { this.pendingReward = pendingReward; return(this); }
/// <summary> /// Uploads an image to the user's social page on the given Provider with confirmation dialog. /// Supported platforms: Facebook, Twitter, Google+ /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param> /// <param name="message">Message to post with the image.</param> /// <param name="fileName">Name of image file with extension (jpeg/pgn).</param> /// <param name="imageBytes">Image bytes.</param> /// <param name="jpegQuality">Image quality, number from 0 to 100. 0 meaning compress for small size, 100 meaning compress for max quality. /// Some formats, like PNG which is lossless, will ignore the quality setting /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param> /// <param name="customMessage">The message to show in the dialog</param> public static void UploadImageWithConfirmation(Provider provider, string message, string fileName, byte[] imageBytes, int jpegQuality, string payload="", Reward reward = null, string customMessage = null) { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) return; if (targetProvider.IsNativelyImplemented()) { string rewardId = reward != null ? reward.ID: ""; instance._uploadImage(provider, message, fileName, imageBytes, jpegQuality, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString(), true, customMessage); } else { ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPLOAD_IMAGE, userPayload); ModalDialog.CreateModalWindow("Click 'Post' to proceed with image upload.", () => targetProvider.UploadImage(imageBytes, fileName, message, /* success */ () => { if (reward != null) { reward.Give(); } ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPLOAD_IMAGE, userPayload); }, /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed (provider, SocialActionType.UPLOAD_IMAGE, error, userPayload); }, /* cancel */ () => { ProfileEvents.OnSocialActionCancelled(provider, SocialActionType.UPLOAD_IMAGE, userPayload); } ) ); } }
private SpawnPlayerParams(Vector3 position, Quaternion rotation, ZoneDefinition zone, string sceneName, SpawnedAction spawnedAction, bool nudgePlayer, bool getOutOfSwimming, Reward pendingReward) { Position = position; Rotation = rotation; Zone = zone; SceneName = sceneName; SpawnedAction = spawnedAction; NudgePlayer = nudgePlayer; GetOutOfSwimming = getOutOfSwimming; PendingReward = pendingReward; }
/// <summary> /// Retrieves a list of the user's feed entries from the supplied provider. /// Upon a successful retrieval of feed entries the user will be granted the supplied reward. /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> on which to retrieve a list of feed entries.</param> /// <param name="fromStart">Should we reset pagination or request the next page.</param> /// <param name="payload">A string to receive when the function returns.</param> /// <param name="reward">The reward which will be granted to the user upon a successful retrieval of feed.</param> public static void GetFeed(Provider provider, bool fromStart = false, string payload = "", Reward reward = null) { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) return; if (targetProvider.IsNativelyImplemented()) { string rewardId = reward != null ? reward.ID: ""; //fallback to native instance._getFeed(provider, fromStart, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString()); } else { ProfileEvents.OnGetFeedStarted(provider); targetProvider.GetFeed(fromStart, /* success */ (SocialPageData<String> feeds) => { if (reward != null) { reward.Give(); } ProfileEvents.OnGetFeedFinished(provider, feeds); }, /* fail */ (string message) => { ProfileEvents.OnGetFeedFailed(provider, message); }); } }
private void goToLocationInZone(CellPhoneLocationActivityDefinition definition, Reward reward) { goToLocationInZone(definition.LocationInZone, definition.Scene.SceneName, definition, reward); }
// TODO: this is irrelevant for now. Will be updated soon. // public static void AddAppRequest(Provider provider, string message, string[] to, string extraData, string dialogTitle) { // providers[provider].AppRequest(message, to, extraData, dialogTitle, // /* success */ (string requestId, List<string> recipients) => { // string requestsStr = KeyValueStorage.GetValue("soomla.profile.apprequests"); // List<string> requests = new List<string>(); // if (!string.IsNullOrEmpty(requestsStr)) { // requests = requestsStr.Split(',').ToList(); // } // requests.Add(requestId); // KeyValueStorage.SetValue("soomla.profile.apprequests", string.Join(",", requests.ToArray())); // KeyValueStorage.SetValue(requestId, string.Join(",", recipients.ToArray())); // ProfileEvents.OnAddAppRequestFinished(provider, requestId); // }, // /* fail */ (string errMsg) => { // ProfileEvents.OnAddAppRequestFailed(provider, errMsg); // }); // } /// <summary> /// Will fetch posts from user feed /// /// </summary> /// <param name="provider">Provider.</param> /// <param name="reward">Reward.</param> // public static void GetFeed(Provider provider, Reward reward) { // // // TODO: implement with FB SDK // // } /// <summary> /// Likes the page (with the given name) of the given provider. /// Supported platforms: Facebook, Twitter, Google+. /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The provider that the page belongs to.</param> /// <param name="pageName">The name of the page to like.</param> /// <param name="reward">A <c>Reward</c> to give the user after he/she likes the page.</param> public static void Like(Provider provider, string pageId, Reward reward=null) { SocialProvider targetProvider = GetSocialProvider(provider); if (targetProvider != null) { targetProvider.Like(pageId); if (reward != null) { reward.Give(); } } }
private void goToLocationInZone(Vector3 location, string sceneName, CellPhoneActivityDefinition definition, Reward reward) { PlayerSpawnPositionManager component = SceneRefs.ZoneLocalPlayerManager.LocalPlayerGameObject.GetComponent <PlayerSpawnPositionManager>(); if (component != null) { SpawnedAction spawnedAction = new SpawnedAction(); spawnedAction.Action = SpawnedAction.SPAWNED_ACTION.None; component.SpawnPlayer(new SpawnPlayerParams.SpawnPlayerParamsBuilder(location).SceneName(sceneName).SpawnedAction(spawnedAction).PendingReward(reward) .Build()); } Service.Get <ICPSwrveService>().Action("activity_tracker", "quick_go", definition.GetType().ToString(), definition.name); }