/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="baseItem">Item base</param>
        public VirtualGoodDecorator(VirtualGood baseItem)
            : base(baseItem)
        {
            // Valores por defecto
            UpgradeLevel = 0;
            UpgradesIDs = new List<string>();

            try
            {
                // Obtengo las mejoras
                List<UpgradeVG> upgrades = StoreInfo.GetUpgradesForVirtualGood(ID);

                if (upgrades != null && upgrades.Count > 0)
                {
                    // Guardo los IDs
                    foreach (UpgradeVG u in upgrades)
                        UpgradesIDs.Add(u.ItemId);

                    // Obtengo el nivel actual
                    UpgradeLevel = StoreInventory.GetGoodUpgradeLevel(ID);
                }
            }
            catch (Exception e)
            {
                Debug.LogWarning("GOOD " + ID + ": " + e.Message);
            }
        }
        public override Dictionary<string, int> GetCurrenctPrice(VirtualGood vg)
        {
            int balance = StoreInventory.GetGoodBalance(vg.ItemId);

            if (balance >= currencyValuePerBalance.Count) {
                return currencyValuePerBalance[currencyValuePerBalance.Count - 1];
            }
            return currencyValuePerBalance[balance];
        }
Exemple #3
0
        public void onGoodUpgrade(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodUpgrade:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            VirtualGood vg  = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]);
            UpgradeVG   vgu = (UpgradeVG)StoreInfo.GetItemByItemId(vars[1]);

            Events.OnGoodUpgrade(vg, vgu);
        }
Exemple #4
0
        public void onGoodBalanceChanged(string message)
        {
            StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodBalanceChanged:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            VirtualGood vg          = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]);
            int         balance     = int.Parse(vars[1]);
            int         amountAdded = int.Parse(vars[2]);

            Events.OnGoodBalanceChanged(vg, balance, amountAdded);
        }
 /// <summary>
 /// Disparado al cambiar el balance de un item
 /// </summary>
 /// <param name="good">Item cambiado</param>
 /// <param name="balance">Balance</param>
 /// <param name="amountAdded">Cantidad agregada</param>
 public void OnGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
     LocalStoreInfo.UpdateBalance(good.ItemId, balance);
 }
 /// <summary>
 /// Disparado al mejorar un item
 /// </summary>
 /// <param name="good">Item mejorado</param>
 /// <param name="currentUpgrade">Mejora actual</param>
 public void OnGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade)
 {
     LocalStoreInfo.UpgradeItem(good.ItemId);
 }
 public abstract Dictionary<string, int> GetCurrenctPrice(VirtualGood vg);
Exemple #8
0
        public static VirtualGood GetVirtualGoodByItemId(string itemId)
        {
            #if UNITY_ANDROID
            VirtualGood vg = null;
            AndroidJNI.PushLocalFrame(100);
            using(AndroidJavaObject jniVirtualGood = AndroidJNIHandler.CallStatic<AndroidJavaObject>(
                new AndroidJavaClass("com.soomla.unity.StoreInfo"),"getVirtualGoodByItemId", itemId)) {
                vg = new VirtualGood(jniVirtualGood);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
            return vg;
            #elif UNITY_IOS
            IntPtr p = IntPtr.Zero;
            int err = storeInfo_GetGoodByItemId(itemId, out p);

            IOS_ErrorCodes.CheckAndThrowException(err);

            string json = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);

            JSONObject obj = new JSONObject(json);
            return new VirtualGood(obj);
            #else
            return null;
            #endif
        }
 public override Dictionary<string, int> GetCurrenctPrice(VirtualGood vg)
 {
     return currencyValue;
 }