コード例 #1
0
        private void OnGetPresenceOfFriendsSuccess(string in_stringData, object in_obj)
        {
            GStateManager.Instance.EnableLoadingSpinner(false);
            GDebug.Log(string.Format("OnGetPresenceOfFriends Success | {0}", in_stringData));

            Friends.Clear();

            Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_stringData);
            Dictionary <string, object> jsonData    = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA];

            if (jsonData.ContainsKey(BrainCloudConsts.JSON_PRESENCE))
            {
                PlayerData pData   = null;
                object[]   friends = ((object[])jsonData[BrainCloudConsts.JSON_PRESENCE]);
                if (friends.Length > 0)
                {
                    for (int it = 0; it < friends.Length; ++it)
                    {
                        pData = new PlayerData();
                        pData.ReadPresencePlayerData(friends[it]);
                        Friends.Add(pData);
                    }
                }
            }

            GEventManager.TriggerEvent(ON_FRIENDS_LIST_UPDATED);
        }
コード例 #2
0
 private void LerpToPage(int aPageIndex)
 {
     aPageIndex    = Mathf.Clamp(aPageIndex, 0, m_pageCount - 1);
     m_lerpTo      = m_pagePositions[aPageIndex];
     m_lerp        = true;
     m_currentPage = aPageIndex;
     GEventManager.TriggerEvent(ScrollSnapPage.ON_SCROLL_SNAP_INCREMENT_PAGE);
 }
コード例 #3
0
 private void SetPage(int aPageIndex)
 {
     aPageIndex = Mathf.Clamp(aPageIndex, 0, m_pageCount - 1);
     if (m_pagePositions.Count != 0)
     {
         m_container.anchoredPosition = m_pagePositions[aPageIndex];
         m_currentPage = aPageIndex;
         GEventManager.TriggerEvent(ScrollSnapPage.ON_SCROLL_SNAP_INCREMENT_PAGE);
     }
 }
コード例 #4
0
        public void OnReadBrainCloudProperties(string in_jsonString, object in_object)
        {
            Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_jsonString);
            Dictionary <string, object> jsonData    = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA];

            for (int index = 0; index < jsonData.Count; index++)
            {
                var item = jsonData.ElementAt(index);
                m_objectConfig[item.Key] = ((Dictionary <string, object>)item.Value)[BrainCloudConsts.JSON_VALUE];
            }

            GEventManager.TriggerEvent("OnConfigPropertiesRead");
        }
コード例 #5
0
        public void OnInviteToLobby(string in_ProfileId, string in_originalUserName)
        {
            // send event to other person
            Dictionary <string, object> jsonData = new Dictionary <string, object>();

            jsonData[BrainCloudConsts.JSON_LAST_CONNECTION_ID] = GCore.Wrapper.Client.RTTConnectionID;
            jsonData[BrainCloudConsts.JSON_PROFILE_ID]         = GCore.Wrapper.Client.ProfileId;
            jsonData[BrainCloudConsts.JSON_USER_NAME]          = GPlayerMgr.Instance.PlayerData.PlayerName;
            OriginalUserName = in_originalUserName;

            GCore.Wrapper.Client.EventService.SendEvent(in_ProfileId, "OFFER_JOIN_LOBBY",
                                                        JsonWriter.Serialize(jsonData));

            GEventManager.TriggerEvent(GEventManager.ON_INVITED_FRIEND);
        }
コード例 #6
0
        public void OnReadGlobalFileList(string in_jsonString, object in_object)
        {
            Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_jsonString);
            Dictionary <string, object> jsonData    = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA];
            Array array = (Array)jsonData["fileDetails"];

            m_fileListDetails.Clear();
            for (int index = 0; index < array.Length; index++)
            {
                var item = array.GetValue(index) as Dictionary <string, object>;
                m_fileListDetails.Add(item);
            }

            GEventManager.TriggerEvent("OnGlobalFilesRead");
        }
コード例 #7
0
        /// <summary>
        /// Initialized callback
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="extensions"></param>
        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            // Purchasing has succeeded initializing. Collect our Purchasing references.
            if (m_enableDebug)
            {
                GDebug.Log("OnInitialized: PASS");
            }

            // Overall Purchasing system, configured with products for this application.
            m_StoreController = controller;
            // Store specific subsystem, for accessing device-specific store features.
            m_StoreExtensionProvider = extensions;

#if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR
            updateStoreProductInfo();
#endif
            CheckAllSubscriptions();
            GEventManager.TriggerEvent(GEventManager.ON_IAP_PRODUCTS_UPDATED);
        }
コード例 #8
0
        private void onGetEntitySuccess(string in_jsonString, object in_object)
        {
            Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_jsonString);
            Dictionary <string, object> jsonData    = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA];

            try
            {
                Dictionary <string, object> jsonArray      = (Dictionary <string, object>)(((object[])jsonData[BrainCloudConsts.JSON_ENTITY_LIST])[0]);
                Dictionary <string, object> jsonLevelPacks = (Dictionary <string, object>)jsonArray[BrainCloudConsts.JSON_DATA];

                for (int i = 2; i <= jsonLevelPacks.Count + 1; ++i)
                {
                    parseLevelPackData(jsonLevelPacks, i);
                }

                GEventManager.TriggerEvent(GEventManager.ON_PLAYER_DATA_UPDATED);
            }
            catch (System.Exception) { }
        }
コード例 #9
0
        private void onReadMetaDataSuccess(string in_sJsonResponse, object in_cbObject)
        {
            Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_sJsonResponse);
            Dictionary <string, object> jsonData    = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA];

            if (jsonData.ContainsKey(XP_LEVELS))
            {
                try
                {
                    Dictionary <string, object>[] jsonLevels = (Dictionary <string, object>[])jsonData[XP_LEVELS];

                    LevelUpRewards reward;
                    for (int i = 0; i < jsonLevels.Length; i++)
                    {
                        reward = new LevelUpRewards(jsonLevels[i]);
                        Rewards.Add(reward);
                    }
                    GCore.Wrapper.GlobalEntityService.GetListByIndexedId("playerLevelUp", 1, onGetEntitySuccess);
                }
                catch (System.Exception) { GEventManager.TriggerEvent(GEventManager.ON_PLAYER_DATA_UPDATED); }
            }
        }
コード例 #10
0
        /// <summary>
        /// Callback for succesful ProductService.GetSalesInventory
        /// </summary>
        /// <param name="in_jsonString"></param>
        /// <param name="in_object"></param>
        public void OnReadInventory(string in_jsonString, object in_object)
        {
            //Build IAPProducts based on all platform responses
            // ios and google play store now supported [smrj]

            m_productInventory.Clear(); // Clearing to fill with fresh data

            Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_jsonString);
            Dictionary <string, object> jsonData    = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA];
            var jsonArray = jsonData[JSON_PRODUCT_INVENTORY] as Array;
            Dictionary <string, object> product;
            Dictionary <string, object> priceData;

#if UNITY_IOS
            Dictionary <string, object> idsObject; //itunes may have an array of ids for iphone, ipad and appletv
#endif
            Dictionary <string, object> currencyRewards;

            IAPProduct iapProduct = null;

#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
#endif
            for (int index = 0; index < jsonArray.Length; index++)
            {
                product   = ((Dictionary <string, object>)jsonArray.GetValue(index));
                priceData = ((Dictionary <string, object>)product[KEY_PRICEDATA]);

#if UNITY_ANDROID
                var storeId = (string)priceData[KEY_ANDROIDID];
#elif UNITY_WEBGL
                var storeId = (string)product[KEY_PRODUCT_FBURL];
#elif UNITY_IOS
                var idsArray = priceData[KEY_IDS] as Array;
                idsObject = ((Dictionary <string, object>)idsArray.GetValue(0));
                var storeId = (string)idsObject[KEY_ITUNESID];
#elif STEAMWORKS_ENABLED
                var storeId = ((int)priceData[KEY_PRODUCTID]).ToString();
#else
                var storeId = "";
                try
                {
                    // TODO add more store integration here [SMRJ]
                    storeId = (string)priceData[KEY_ANDROIDID];
                }
                catch (Exception)
                {
                    continue;
                }
#endif
                var braincloudID   = (string)product[KEY_PRODUCTID];
                var category       = (string)product[KEY_CATEGORY];
                var title          = (string)product[KEY_TITLE];
                var description    = (string)product[KEY_DESCRIPTION];
                var imageUrl       = (string)product[KEY_IMAGEURL];
                var referencePrice = Convert.ToDecimal(priceData[KEY_REFERENCEPRICE]);
                var price          = referencePrice / 100;
                var isPromotion    = (bool)priceData[KEY_ISPROMOTION];

                //get the value of the currency with the same name as the category
                currencyRewards = (Dictionary <string, object>)product[KEY_CURRENCY];

                // merge the peer / parent currencies within this dictionary as well
                if (product.ContainsKey(KEY_PARENT_CURRENCY))
                {
                    foreach (var item in product[KEY_PARENT_CURRENCY] as Dictionary <string, object> )
                    {
                        foreach (var currencyReward in item.Value as Dictionary <string, object> )
                        {
                            currencyRewards.Add(currencyReward.Key, currencyReward.Value);
                        }
                    }
                }

                if (product.ContainsKey(KEY_PEER_CURRENCY))
                {
                    foreach (var item in product[KEY_PEER_CURRENCY] as Dictionary <string, object> )
                    {
                        foreach (var currencyReward in item.Value as Dictionary <string, object> )
                        {
                            currencyRewards.Add(currencyReward.Key, currencyReward.Value);
                        }
                    }
                }

                object currencyVal;
                currencyRewards.TryGetValue(category, out currencyVal);

                var currencyValue = Convert.ToInt32(currencyVal);
                var type          = (string)product[KEY_TYPE];

#if BUY_CURRENCY_ENABLED
                var productType = ProductType.Consumable;

                switch (type.ToLower())
                {
                case PRODUCT_TYPE_SUBSCRIPTION:
                    productType = ProductType.Subscription;
                    break;

                case PRODUCT_TYPE_NON_CONSUMABLE:
                    productType = ProductType.NonConsumable;
                    break;

                case PRODUCT_TYPE_CONSUMABLE:
                default:
                    //productType = ProductType.Consumable; -> Already set as default value
                    break;
                }
#endif

                Dictionary <string, object> packRewards = (Dictionary <string, object>)product[BrainCloudConsts.JSON_DATA];

#if BUY_CURRENCY_ENABLED
                iapProduct = new IAPProduct(braincloudID, storeId, productType, category, title, description, imageUrl, referencePrice, price, isPromotion, currencyValue, currencyRewards, packRewards);
#else
                iapProduct = new IAPProduct(braincloudID, storeId, category, title, description, imageUrl, referencePrice, price, isPromotion, currencyValue, currencyRewards, packRewards);
#endif

                iapProduct.PriceString = String.Format("{0:c}", referencePrice / 100);

                //update the regular price on sale items
                if (isPromotion && product.ContainsKey(KEY_DEFAULTPRICEDATA))
                {
                    var defaultPriceData = ((Dictionary <string, object>)product[KEY_DEFAULTPRICEDATA]);
                    var refPrice         = Convert.ToDecimal(defaultPriceData[KEY_REFERENCEPRICE]);
#if UNITY_ANDROID
                    var regularId = (string)defaultPriceData[KEY_ANDROIDID];
#elif UNITY_WEBGL
                    var regularId = (string)product[KEY_PRODUCT_FBURL];
#elif STEAMWORKS_ENABLED
                    var regularId = ((int)defaultPriceData[KEY_PRODUCTID]).ToString();
#else
                    var ids       = defaultPriceData[KEY_IDS] as Array;
                    var regIdVal  = ((Dictionary <string, object>)ids.GetValue(0));
                    var regularId = (string)regIdVal[KEY_ITUNESID];
#endif

                    iapProduct.RegularPriceID     = regularId;
                    iapProduct.RegularPrice       = refPrice / 100;
                    iapProduct.RegularPriceString = String.Format("{0:c}", refPrice / 100);
#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED                 // unity does not support steam works iap
                    builder.AddProduct(regularId, productType); //add this as a reference to the regular priced item
#endif
                }
#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED                             // unity does not support steam works iap
                builder.AddProduct(iapProduct.StoreProductId, productType); //add to ConfigurationBuilder
#endif
                m_productInventory.Add(iapProduct);                         //add to List of products
            }
#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED                             // unity does not support steam works iap
            UnityPurchasing.Initialize(this, builder);
#else
            GEventManager.TriggerEvent(GEventManager.ON_IAP_PRODUCTS_UPDATED);
#endif
        }