public void UpgradeTier(string troopId)
    {
        Debug.Log("Upgrading Tier for " + troopId);
        var troopInfo = DataLayer.Instance.GetTable <TroopData>().Where(y => y.Name == troopId).SingleOrDefault();

        var playerTroopInfo = MetaDataState.GetCurrent().TroopsData.Where(y => y.TroopId == troopId).SingleOrDefault();

        TierData nextTierInfo;

        if (playerTroopInfo != null)
        {
            nextTierInfo = DataLayer.Instance.GetTable <TierData>().Where(y => (int)y.Tier == (int)troopInfo.StartTier + 1).SingleOrDefault();
        }
        else
        {
            nextTierInfo = DataLayer.Instance.GetTable <TierData>().First();
        }

        if (MetaDataState.Current.Consumables.CheckBalances(nextTierInfo.Cost.ConsumableCostItems))
        {
            CloudScriptMethod upgradeTier = new CloudScriptMethod("UpgradeTier");
            upgradeTier.Params.Add("troopId", troopId);
            PlayFabManager.Instance.InvokeBackOffice(upgradeTier, (CloudScriptResponse r, CloudScriptMethod m) => OnUpgradeTierResult(r, troopId));
        }
    }
Beispiel #2
0
        public void Init(MetaLoopGameManager metaLoopGameManager)
        {
            if (!isInit)
            {
                this.metaLoopGameManager = metaLoopGameManager;

                methodPlayerStatus             = new CloudScriptMethod();
                methodPlayerStatus.Method      = "PlayerStatus";
                methodPlayerStatus.IgnoreError = true;

                timerPlayerStatus          = new Timer(timerPlayerStatus_Interval);
                timerPlayerStatus.Elapsed += TimerStatusCheck_Elapsed;
                timerPlayerStatus.Enabled  = true;

                timerServerStatus          = new Timer(timerServerStatus_Interval);
                timerServerStatus.Elapsed += timerServerStatus_Elapsed;
                timerServerStatus.Enabled  = true;

                timerInboxStatus          = new Timer(timerInboxStatus_Interval);
                timerInboxStatus.Elapsed += timerInboxStatus_Elapsed;
                timerInboxStatus.Enabled  = true;

                isInit = true;
            }
        }
        public static void ValidateIAP(MetaDataStateBase metaDataState, string internalId, string receiptID, bool isOffer, Action <ShopRequestResult> callBack)
        {
            ShopTransactionItem shopTransactionItem = new ShopTransactionItem(ShopItemType.HardCurrency, internalId);
            string            platformType          = UnityEngine.Application.platform.ToString();
            CloudScriptMethod cloudScriptMethod     = new CloudScriptMethod("Shop/ValidateIAP", false);

            cloudScriptMethod.Params.Add("internalId", internalId);
            cloudScriptMethod.Params.Add("receiptID", receiptID);
            cloudScriptMethod.Params.Add("platformType", platformType);
            PlayFabManager.Instance.InvokeBackOffice(cloudScriptMethod, (CloudScriptResponse r, CloudScriptMethod m) => HandleShopResult(r, metaDataState, shopTransactionItem, callBack, true));
        }
Beispiel #4
0
        protected virtual void BackOfficeLogin()
        {
            CloudScriptMethod method = new CloudScriptMethod();

            method.Method = "PlayerLogin";
            //Use case only valid for BOTS//Impersonates
            if (!PlayFabManager.IsImpersonating)
            {
                method.Params.Add("DisplayName", PlayFabManager.Instance.PlayerName);
            }

            method.Params.Add("UniqueId", SystemInfo.deviceUniqueIdentifier);
            PlayFabManager.Instance.InvokeBackOffice(method, OnBackOfficePlayerLoginComplete);
        }
Beispiel #5
0
        public void MarkAsShown(string offerId, ShopOfferPlacementType placement, ShopOffer shopOffer, bool popup)
        {
            OfferDataStateEntry entry          = AllOffersState.Where(y => y.OfferId == offerId).SingleOrDefault();
            PlacementTypeState  entryPlacement = AllPlacementTypeState.Where(y => y.PlacementType == placement).SingleOrDefault();

            if (entry == null)
            {
                entry                = new OfferDataStateEntry();
                entry.OfferId        = offerId;
                entry.ActivationDate = DateTime.UtcNow;
                entry.LastTimeShown  = DateTime.MinValue;
                AllOffersState.Add(entry);
            }
            else
            {
                if (shopOffer.Duration > 0)
                {
                    if (DateTime.UtcNow > entry.ActivationDate.AddHours(shopOffer.Duration))
                    {
                        entry.ActivationDate = DateTime.UtcNow;
                    }
                }
            }

            if (popup)
            {
                if (entryPlacement == null)
                {
                    entryPlacement = new PlacementTypeState();
                    entryPlacement.PlacementType = placement;
                    AllPlacementTypeState.Add(entryPlacement);
                }
                entryPlacement.LastTimeShown = DateTime.UtcNow;

                entry.LastTimeShown = DateTime.UtcNow;
            }



#if !BACKOFFICE
            CloudScriptMethod cloudScriptMethod = new CloudScriptMethod("RegisterOfferState", false);
            cloudScriptMethod.Params.Add("offerId", offerId);
            cloudScriptMethod.Params.Add("placement", placement.ToString());
            cloudScriptMethod.Params.Add("popup", popup.ToString());
            PlayFabManager.Instance.AddToStack("RegisterOfferState", cloudScriptMethod);
#endif
        }
Beispiel #6
0
        private void OnPlayerStatusReceived(CloudScriptResponse arg1, CloudScriptMethod arg2)
        {
            if (!Running)
            {
                return;
            }
            UnityEngine.Debug.Log("ROUTINE TASK MANAGER - PLAYER STATUS RECEIVED");

            if (arg1.ResponseCode == ResponseCode.Success)
            {
                if (arg1.Params.ContainsKey("EnergyBalance"))
                {
                    int newBalance = Convert.ToInt32(arg1.Params["EnergyBalance"]);
                    MetaDataStateBase.Current.Consumables.SetConsumableAmount(Consumable.GetByName(MetaStateSettings._EnergyId), newBalance);
                }

                MetaDataStateBase.Current.SyncLoginCalendar();

                if (arg1.Params.ContainsKey("UniqueId") && !string.IsNullOrEmpty(arg1.Params["UniqueId"]))
                {
                    if (arg1.Params["UniqueId"] != UnityEngine.SystemInfo.deviceUniqueIdentifier)
                    {
                        this.metaLoopGameManager.ShowUnavailableMessage(GameUnavailableMessageType.LOGIN_MISMATCH);
                    }
                }

                if (arg1.Params.ContainsKey("ApplyDailyReset"))
                {
                    if (arg1.Params["ApplyDailyReset"].ToLower() == "true")
                    {
                        MetaDataStateBase.Current.ApplyDailyReset();
                    }
                }

                if (OnPlayerStatusUpdate != null)
                {
                    UnityMainThreadDispatcher.Instance().Enqueue(() => OnPlayerStatusUpdate.Invoke());
                }
            }
        }
        public void SetTutorialProgress(string stepId, bool completed)
        {
            if (!TutorialProgress.ContainsKey(stepId))
            {
                TutorialProgress.Add(stepId, completed);
            }
            else
            {
                TutorialProgress[stepId] = completed;
            }

#if !BACKOFFICE
            if (MetaStateSettings._IsServerAuthoritative)
            {
                CloudScriptMethod cloudScriptMethod = new CloudScriptMethod("SetSetting", false);
                cloudScriptMethod.Params.Add("type", "tutorial");
                cloudScriptMethod.Params.Add("key", stepId);
                cloudScriptMethod.Params.Add("value", completed.ToString());
                PlayFabManager.Instance.AddToStack("Settings", cloudScriptMethod);
            }
#endif
        }
        public void SetSetting(string settingId, int value)
        {
            if (!Settings.ContainsKey(settingId))
            {
                Settings.Add(settingId, value);
            }
            else
            {
                Settings[settingId] = value;
            }


#if !BACKOFFICE
            if (MetaStateSettings._IsServerAuthoritative)
            {
                CloudScriptMethod cloudScriptMethod = new CloudScriptMethod("SetSetting", false);
                cloudScriptMethod.Params.Add("type", "setting");
                cloudScriptMethod.Params.Add("key", settingId);
                cloudScriptMethod.Params.Add("value", value.ToString());
                PlayFabManager.Instance.AddToStack("Settings", cloudScriptMethod);
            }
#endif
        }
Beispiel #9
0
        protected virtual void OnBackOfficePlayerLoginComplete(CloudScriptResponse response, CloudScriptMethod method)
        {
            Debug.Log("MetaLoopGameManager BackOffice Logged In, Downloading User Data...");
            List <string> keys    = MetaStateSettings._UserDataToDownload;
            var           request = new GetUserDataRequest {
                Keys = keys
            };

            PlayFabClientAPI.GetUserReadOnlyData(request, OnUserDataComplete, OnUserDataError);
        }