Example #1
0
 private void FinishTrigger(GachaTrigger trigger, NPNFError error)
 {
     if (trigger != null)
     {
         trigger.FinishTriggeredAction(this, trigger, error);
     }
 }
Example #2
0
 private void TriggerHandler(GachaTrigger trigger)
 {
     if (User.IsCurrentProfileExist())
     {
         GachaTrigger gachaTrigger = (GachaTrigger)trigger;
         Play(gachaTrigger.priceName, gachaTrigger.purchaseCount, gachaTrigger);
     }
 }
Example #3
0
        private void Play(string priceName, int purchaseCount, GachaTrigger trigger)
        {
            if (!IsInitialized)
            {
                NPNFError error = NPNFError.GetGameError(NPNFError.GameCode.GACHA_NOT_INITIALIZED);
                if (OnPlayError != null)
                {
                    OnPlayError(this, trigger, error);
                }
                FinishTrigger(trigger, error);
                return;
            }

            User.CurrentProfile.Gacha.Play(Name, priceName, purchaseCount, (FormulaResult result, NPNFError error) => {
                if (error == null)
                {
                    List <Entitlement> entitlements = new List <Entitlement>();

                    foreach (var entitlement in result.AddedEntitlements)
                    {
                        entitlements.Add(User.CurrentProfile.Entitlements.GetCached(entitlement.Id));
                    }

                    if (OnPlayDone != null)
                    {
                        OnPlayDone(this, trigger, entitlements);
                    }
                }
                else
                {
                    if (OnPlayError != null)
                    {
                        OnPlayError(this, trigger, error);
                    }
                }
                FinishTrigger(trigger, error);
            });
        }
Example #4
0
 protected abstract void PlayErrorHandler(Gacha gacha, GachaTrigger trigger, NPNFError error);
Example #5
0
 protected abstract void PlayDoneHandler(Gacha gacha, GachaTrigger trigger, List <Entitlement> results);