Beispiel #1
0
    IEnumerator CreateNewUser_Coroutine(string inUserName,
                                        string inPasswordHash,
                                        string inNickName,
                                        string inEmail,
                                        bool inIWantNews,
                                        E_UserAcctKind inKind,
                                        E_AppProvider inAppProvider,
                                        System.Action <bool> callback)
    {
        // create user
        {
            _CreateNewUser action = new _CreateNewUser(inUserName, inPasswordHash, productID);
            GameCloudManager.AddAction(action);

            while (action.isDone == false)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (action.isFailed == true)
            {
                callback(false);
                yield break;
            }
        }

        // get primary key
        UnigueUserID userID;

        {
            UserGetPrimaryKey action = new UserGetPrimaryKey(inUserName);
            GameCloudManager.AddAction(action);

            while (action.isDone == false)
            {
                yield return(new WaitForEndOfFrame());
            }

            userID = new UnigueUserID(action.primaryKey, inPasswordHash, productID);
        }

        // set user data
        {
            Dictionary <string, string> userData = new Dictionary <string, string>();

            userData.Add(CloudServices.PROP_ID_NICK_NAME, inNickName);
            userData.Add(CloudServices.PROP_ID_EMAIL, inEmail);
            userData.Add(CloudServices.PROP_ID_I_WANT_NEWS, inIWantNews.ToString());
            userData.Add(CloudServices.PROP_ID_ACCT_KIND, inKind.ToString());

            List <BaseCloudAction> actions = new List <BaseCloudAction>();

            actions.Add(new SetUserDataList(userID, userData));

            if (inAppProvider != E_AppProvider.Madfinger)
            {
                actions.Add(new SetUserProductData(userID, CloudServices.PROP_ID_APP_PROVIDER, inAppProvider.ToString()));
            }

            CloudActionSerial action = new CloudActionSerial(null, BaseCloudAction.NoTimeOut, actions.ToArray());
            GameCloudManager.AddAction(action);

            while (action.isDone == false)
            {
                yield return(new WaitForEndOfFrame());
            }
        }

        callback(true);
    }
Beispiel #2
0
    IEnumerator PairGuestAccountWithVendorID_Coroutine(UnigueUserID userID)
    {
        List <BaseCloudAction> actions = new List <BaseCloudAction>();

        // it can happen that iOSVendorID is null
        // so we need to try it again
        int    guard    = 100;
        string vendorID = string.Empty;

        while (guard > 0)
        {
            vendorID = MFNativeUtils.IOS.VendorId;
            if (string.IsNullOrEmpty(vendorID) == false)
            {
                break;
            }

            yield return(new WaitForEndOfFrame());

            guard -= 1;
        }
        if (string.IsNullOrEmpty(vendorID) == false)
        {
            actions.Add(new SetiOSVendorId(userID, vendorID));
        }

        // it can happen that iOSAdvertisingID is null
        // so we need to try it again
        guard = 100;
        string advertID = string.Empty;

        while (guard > 0)
        {
            advertID = MFNativeUtils.IOS.AdvertisingId;
            if (string.IsNullOrEmpty(advertID) == false)
            {
                break;
            }

            yield return(new WaitForEndOfFrame());

            guard -= 1;
        }
        if (string.IsNullOrEmpty(advertID) == false)
        {
            actions.Add(new SetiOSAdvertisingId(userID, advertID));
        }

        //Debug.Log(">>>> AUTHENTICATE :: vendorID="+vendorID+", advertID="+advertID);

        if (actions.Count > 0)
        {
            CloudActionSerial action = new CloudActionSerial(null, BaseCloudAction.NoTimeOut, actions.ToArray());
            GameCloudManager.AddAction(action);

            while (action.isDone == false)
            {
                yield return(new WaitForEndOfFrame());
            }
        }
    }
Beispiel #3
0
    //Funkce pro fixnuti equipu na ppi
    //Projdeme casti equipu ktere by nemuseli byt validni a vytvorime seznam akci ktere je treba vykonat aby byl zase v poradku.
    //Pokud je vse v poradku, vraci null, jinak serial cloud action ktera se ma provest
    public static BaseCloudAction ValidateEquip()
    {
        List <BaseCloudAction> outActions = new List <BaseCloudAction>();
        PlayerPersistantInfo   ppi        = ShopDataBridge.Instance.PPI;
        UnigueUserID           userID     = CloudUser.instance.authenticatedUserID;

        //weapons:
        //bool anyWeaponEquipped = false;
        foreach (PPIWeaponData w in ppi.EquipList.Weapons)
        {
            //ignoruj prazdna id
            if (w.ID == E_WeaponID.None)
            {
                continue;
            }

            //pokud je item zakazany, nebo ma locknuty slot, odstran ho z equipu.
            WeaponSettings s = WeaponSettingsManager.Instance.Get(w.ID);
            if (s.DISABLED || ShopDataBridge.Instance.IsWeaponSlotLocked(w.EquipSlotIdx))
            {
                //unequip it
                outActions.Add(new SlotEquipAction(userID, s.GUID, w.EquipSlotIdx, false));
                continue;
            }

            //	anyWeaponEquipped = true;
        }

        /* we don't need this functionality right now,
         * because we don't allow player to spawn without any weapon now
         * //pokud nemame equpnutou zadnou zbran, pridej nejakou do prvniho slotu
         * if(!anyWeaponEquipped)
         * {
         *      List<ShopItemId> ownedWeapons = ShopDataBridge.Instance.GetOwnedWeapons();
         *      if(ownedWeapons.Count > 0)
         *      {
         *              int guid = ShopDataBridge.Instance.GetShopItemGUID(ownedWeapons[0]);
         *              outActions.Add(new SlotEquipAction(userID, guid, 0, true ));
         *      }
         * }*/

        //items:
        foreach (PPIItemData w in ppi.EquipList.Items)
        {
            //ignoruj prazdna id
            if (w.ID == E_ItemID.None)
            {
                continue;
            }

            //pokud je item zakazany, nebo ma locknuty slot, odstran ho z equipu.
            ItemSettings s = ItemSettingsManager.Instance.Get(w.ID);
            if (s.DISABLED || ShopDataBridge.Instance.IsItemSlotLocked(w.EquipSlotIdx))
            {
                //unequip it
                outActions.Add(new SlotEquipAction(userID, s.GUID, w.EquipSlotIdx, false));
                continue;
            }

            //pokud mame od itemu v inventari lepsi nebo naopak horsi verzi, updatni jej ve slotu.
            E_ItemID bestVersion = ShopDataBridge.Instance.FindBestItemUpgrade(w.ID);
            if (w.ID != bestVersion)
            {
                //replace it with actual version from inventory
                int bestVersionGUID = ItemSettingsManager.Instance.Get(bestVersion).GUID;
                outActions.Add(new SlotEquipAction(userID, bestVersionGUID, w.EquipSlotIdx, true));
                continue;
            }
        }

        //perk:
        if (ppi.EquipList.Perk != E_PerkID.None)
        {
            E_PerkID perk        = ppi.EquipList.Perk;
            E_PerkID bestVersion = ShopDataBridge.Instance.FindBestPerkUpgrade(ppi.EquipList.Perk);

            //pokud je zakazany, odstran jej ze slotu
            PerkSettings s = PerkSettingsManager.Instance.Get(perk);
            if (s.DISABLED)
            {
                //unequip it
                outActions.Add(new SlotEquipAction(userID, s.GUID, 0, false));
            }
            else if (perk != bestVersion)
            {
                //replace it with actual version from inventory
                int bestVersionGUID = PerkSettingsManager.Instance.Get(bestVersion).GUID;
                outActions.Add(new SlotEquipAction(userID, bestVersionGUID, 0, true));
            }
        }

        //skins:
        {
            ShopItemId        currSkin   = new ShopItemId((int)ppi.EquipList.Outfits.Skin, GuiShop.E_ItemType.Skin);
            List <ShopItemId> ownedSkins = ShopDataBridge.Instance.GetOwnedSkins();
            if (!ownedSkins.Contains(currSkin))
            {
                //Debug.Log("Equiped skin " + currSkin + " is not in inventory, switching to: " + ( (ownedSkins.Count > 0) ? ownedSkins[0].ToString() : "-none-") );

                if (ownedSkins.Count > 0)
                {
                    //equipnuty skin neni v inventari, vyber misto neho nejaky jiny
                    ownedSkins.Sort();
                    int guid = ShopDataBridge.Instance.GetShopItemGUID(ownedSkins[0]);
                    outActions.Add(new SlotEquipAction(userID, guid, 0, true));
                }
                else
                {
                    Debug.LogError("No skins in inventory!");
                }
            }
        }

        //upgrades:
        {
            List <PPIUpgradeList.UpgradeData> upgs = ppi.Upgrades.Upgrades;
            if (upgs.Find(u => u.ID == E_UpgradeID.ItemSlot2).ID != E_UpgradeID.ItemSlot2)
            {
                int guid = ShopDataBridge.Instance.GetShopItemGUID(new ShopItemId((int)E_UpgradeID.ItemSlot2, GuiShop.E_ItemType.Upgrade));
                outActions.Add(new ShopBuyAction(userID, guid));
            }

            if (upgs.Find(u => u.ID == E_UpgradeID.WeaponSlot2).ID != E_UpgradeID.WeaponSlot2)
            {
                int guid = ShopDataBridge.Instance.GetShopItemGUID(new ShopItemId((int)E_UpgradeID.WeaponSlot2, GuiShop.E_ItemType.Upgrade));
                outActions.Add(new ShopBuyAction(userID, guid));
            }
        }

        //pokud jsme neco zmenili, updatuj na zaver PPI
        if (outActions.Count > 0)
        {
            outActions.Add(new FetchPlayerPersistantInfo(userID));
            BaseCloudAction resultAction = new CloudActionSerial(userID, BaseCloudAction.NoTimeOut, outActions.ToArray());
            return(resultAction);
        }
        else
        {
            return(null);
        }
    }