Beispiel #1
0
        private void DrawSubCategoryLine(int index)
        {
            SubCategorySkinData sub = GetSubCategory(config.subCategoriesSkin[index]);

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(SmallPacing);
                EditorGUI.BeginChangeCheck();
                {
                    sub = EditorGUILayout.ObjectField(sub, typeof(SubCategorySkinData), false) as SubCategorySkinData;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    config.subCategoriesSkin[index] = sub.id;
                    EditorUtility.SetDirty(config);
                }
                GUILayout.Space(SmallPacing);

                if (GUILayout.Button("X", GUILayout.Width(SmallField)))
                {
                    indexToRemove = index;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Beispiel #2
0
        private void UnBuyItem(Item _item)
        {
            if (_item != null && _item is Skin skin && skin.IsCollected)
            {
                SkinManager.LoseSkin(skin);

                //reduce cost value
                SubCategorySkinData subCategoryData = GetSubCategoryDataSkin(skin);
                if (subCategoryData != null && subCategoryData.payment is PaymentCurrency paymentCurrency)
                {
                    if (paymentCurrency.NumberOfPurchaseDone > 0)
                    {
                        paymentCurrency.NumberOfPurchaseDone--;
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Get a random available skin in _subCategoryDataSkin.
        /// Returns null if there is none.
        /// </summary>
        /// <param name="subCategorySkinData"></param>
        /// <returns></returns>
        public Skin GetSkin(SubCategorySkinData subCategorySkinData)
        {
            Skin skin = null;

            foreach (var category in shopData.categories)
            {
                if (category.subCategories.Contains(subCategorySkinData))
                {
                    List <Skin> subCategorySkins = new List <Skin>(subCategorySkinData.skins);
                    subCategorySkins.RemoveAll(x => x.IsCollected);

                    if (subCategorySkins.Count <= 0)
                    {
                        continue;
                    }

                    skin = subCategorySkins.GetRandomValue();
                }
            }

            return(skin);
        }