コード例 #1
0
        void DressBodyParts(CombinedWearables combinedWearable)
        {
            if (combinedWearable == null)
            {
                return;
            }

            //put on the different clothing parts on the different body parts
            foreach (var wearable in combinedWearable.wearable)
            {
                foreach (var bodyPart in bodyParts.Where(bodyPart => wearable.ClothingType.name == bodyPart.name))
                {
                    foreach (var material in bodyPart.GetComponent <MeshRenderer>().materials)
                    {
                        material.mainTexture = wearable.Texture;
                    }
                }
            }

            //Special case: When putting on a jacket -> Deactivate shirt sleeves
            if (combinedWearable.clothingType.name == "Jackets")
            {
                //deactivate the correct shirt sleeves (actually, de-activate all shirt sleeves, no-one will tell a difference)
                EnableDisableTshirtSleeves(false);
            }
        }
コード例 #2
0
 void AssignCombinedWearableData(CombinedWearables wearableInstance, Dictionary <string, object> wearablesStatsDictionary)
 {
     wearableInstance.Amount       = Convert.ToInt32(wearablesStatsDictionary[InventoryData.Amount]);
     wearableInstance.stylePoints  = Convert.ToInt32(wearablesStatsDictionary[InventoryData.StylePoints]);
     wearableInstance.rarity       = inventoryData.allRarities[wearablesStatsDictionary[InventoryData.Rarity].ToString()];
     wearableInstance.clothingType = inventoryData.allClothingTypes[wearablesStatsDictionary[InventoryData.ClothingType].ToString()];
 }
コード例 #3
0
ファイル: IconUpdate.cs プロジェクト: forsbergsskola-se/Cred
        public void UpdateImages()
        {
            wearables       = GetComponent <CombinedWearables>();
            backgroundImage = GetComponent <Image>();
            theAmount       = wearables.Amount;
            //print($"{wearables.ToString()}  the amount is {wearables.Amount}");
            DisableImages();
            ValidateRarity();

            switch (wearables.wearable.Count)
            {
            case 1:
                images[0].sprite = wearables.wearable[0].Sprite;
                ActivateImage(1);
                break;

            case 2:
                images[1].sprite = wearables.wearable[1].Sprite;
                images[2].sprite = wearables.wearable[0].Sprite;
                ActivateImage(2);
                break;

            case 3:
                images[0].sprite = wearables.wearable[0].Sprite;
                images[1].sprite = wearables.wearable[2].Sprite;
                images[2].sprite = wearables.wearable[1].Sprite;
                ActivateImage(3);
                break;
            }

            UpdateInformation();
        }
コード例 #4
0
 void RecordAnalytics(CombinedWearables instance)
 {
     UnityEngine.Analytics.Analytics.CustomEvent(
         "Confirm up cycle",
         new Dictionary <string, object> {
         { "Confirm", instance.clothingType.name }
     });
 }
コード例 #5
0
        void AddOrReplaceClothingType(CombinedWearables combinedWearables)
        {
            if (wearablesOnClient.ContainsKey(combinedWearables.clothingType))
            {
                wearablesOnClient[combinedWearables.clothingType] = combinedWearables;
                return;
            }

            wearablesOnClient.Add(combinedWearables.clothingType, combinedWearables);
        }
コード例 #6
0
        public EventMysteryBoxOpened(CombinedWearables reward)
        {
            this.reward = reward;

            UnityEngine.Analytics.Analytics.CustomEvent(
                "MysteryBoxOpened",
                new Dictionary <string, object> {
                { "Mystery Box Reward", reward.ToString() }
            });
        }
コード例 #7
0
        CombinedWearables GenerateNewCombinedWearable(CombinedWearables wearable)
        {
            var instance = InstantiateCombinedWearables();

            instance.wearable     = wearable.wearable;
            instance.rarity       = wearable.rarity;
            instance.clothingType = wearable.clothingType;
            instance.stylePoints  = wearable.stylePoints;
            return(instance);
        }
コード例 #8
0
 void RemoveClothes(RemoveAllClothes allClothes)
 {
     //reset all last known clothes
     Shirts      = null;
     Pants       = null;
     Skirts      = null;
     Jackets     = null;
     Shoes       = null;
     Accessories = null;
 }
コード例 #9
0
        void SetLastKnownItemOfType(CombinedWearables combinedWearable)
        {
            var field = typeof(LastKnownClothes).GetField(combinedWearable.clothingType.name);

            if (field == null)
            {
                throw new Exception("can't find the clothing type in last known clothes!");
            }

            field.SetValue(lastKnownClothes, combinedWearable);
        }
コード例 #10
0
 public void ShowWarningPopUp(CombinedWearables combinedWearables)
 {
     if (combinedWearables.Amount < 2)
     {
         ToggleNoDuplicatesWarning();
     }
     if (combinedWearables.stylePoints >= combinedWearables.rarity.MaxValue)
     {
         ToggleMaxStylePointsWarning();
     }
 }
コード例 #11
0
        void EnableOrDisableCategory(CombinedWearables combinedWearable)
        {
            //enable/disable the clothes categories, based on the incoming new clothes
            //for example: we get basic pants
            //for example:first disable all pants
            foreach (var category in clothesCategories)
            {
                if (category.name == combinedWearable.clothingType.name)
                {
                    category.SetActive(false);
                }
            }

            //for example:enable basic pants
            var rarity         = clothingRarities.Find(i => i.name == combinedWearable.rarity.name);
            var categoryToShow = rarity.transform.Find(combinedWearable.clothingType.name);

            categoryToShow.gameObject.SetActive(true);

            //special case: not able to wear both skirts and pants at the same time
            //if incoming clothes is pants
            if (combinedWearable.clothingType.name == "Pants")
            {
                //then disable all skirts
                foreach (var category in clothesCategories)
                {
                    if (category.name == "Skirts")
                    {
                        category.SetActive(false);
                    }
                }
                //and remove skirts from last known
                lastKnownClothes.Skirts = null;
            }

            //if incoming clothes is skirts
            if (combinedWearable.clothingType.name == "Skirts")
            {
                //then disable all pants
                foreach (var category in clothesCategories)
                {
                    if (category.name == "Pants")
                    {
                        category.SetActive(false);
                    }
                }
                //and remove pants from last known
                lastKnownClothes.Pants = null;
            }
        }
コード例 #12
0
        static void AssignWearableSlots(List <CombinedWearables> wearableInSlots, CombinedWearables instance)
        {
            var count = wearableInSlots[0].wearable.Count;

            if (count < 3)
            {
                instance.wearable.Add(wearableInSlots[0].wearable[0]);
                instance.wearable.Add(wearableInSlots[1].wearable[1]);
            }
            else
            {
                instance.wearable.Add(wearableInSlots[0].wearable[0]);
                instance.wearable.Add(wearableInSlots[1].wearable[1]);
                instance.wearable.Add(wearableInSlots[1].wearable[2]);
            }
        }
コード例 #13
0
        bool IsNewWearable(CombinedWearables combinedWearables)
        {
            if (!wearablesOnClient.ContainsKey(combinedWearables.clothingType))
            {
                return(true);
            }
            if (PlayerInventory.GetName(wearablesOnClient[combinedWearables.clothingType]) !=
                PlayerInventory.GetName(combinedWearables))
            {
                return(true);
            }

            wearablesOnClient.Remove(combinedWearables.clothingType);
            print("Remove old clothing");
            return(false);
        }
コード例 #14
0
        bool CompareAndRemoveSelectedClothes(CombinedWearables combinedWearable)
        {
            if (GetLastKnownItemOfType(combinedWearable.clothingType.name) == combinedWearable && !BiggerThanZero())
            {
                RemoveClothesPiece(combinedWearable.rarity.name, combinedWearable.clothingType.name);

                //Special case: When removing a jacket -> activate shirt sleeves
                if (combinedWearable.clothingType.name == "Jackets")
                {
                    EnableDisableTshirtSleeves(true);
                }

                return(true);
            }

            return(false);
        }
コード例 #15
0
        void ShowItemToBuy(CombinedWearables reward)
        {
            var instance = Instantiate(reward, rectTransform);

            instance.GetComponent <RectTransform>().localPosition = Vector3.zero;
            foreach (var canvasGroup in instance.canvasGroups)
            {
                canvasGroup.alpha = 1;
            }

            for (var i = 1; i < instance.transform.childCount; i++)
            {
                instance.transform.GetChild(i).gameObject.SetActive(false);
            }

            Resize(instance, sizeToDisplayReward);
            instance.GetComponent <AssignCombinedWearableToUpCycle>().enabled = false;
        }
コード例 #16
0
        void BuyClothes(CombinedWearables wearable)
        {
            var coins = FindObjectOfType <Coin>();
            var price = clothingManager.GetPrice(wearable.rarity);

            if (coins.Coins < price)
            {
                FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/buttonSoundMenu");
                return;
            }

            FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/purchaseNewItem");
            coins.Coins -= price;
            UnityEngine.Analytics.Analytics.CustomEvent("Store", new Dictionary <string, object> {
                { "Purchased", wearable.ToString() }
            });
            EventBroker.Instance().SendMessage(new EventUpdatePlayerInventory(wearable, 1));
            EventBroker.Instance().SendMessage(new EventUpdateWearableHud());
        }
コード例 #17
0
        public Dictionary <string, object> StatList(CombinedWearables combinedWearables)
        {
            var statsDictionary = new Dictionary <string, object>();

            var sortIndex = 0;

            foreach (var data in combinedWearables.wearable)
            {
                statsDictionary.Add(data.ToString() + sortIndex, "");
                sortIndex++;
            }

            statsDictionary[WearableCount] = combinedWearables.wearable.Count;
            statsDictionary[Rarity]        = combinedWearables.rarity.name;
            statsDictionary[ClothingType]  = combinedWearables.clothingType.name;
            statsDictionary[StylePoints]   = combinedWearables.stylePoints;
            statsDictionary[Amount]        = 0;
            statsDictionary[IsPredefined]  = combinedWearables.isPredefined;
            return(statsDictionary);
        }
コード例 #18
0
        public void UpdatePlayerInventory2(CombinedWearables combinedWearable, int addOrSubtractAmount)
        {
            var id       = GetName(combinedWearable);
            var wearable = combinedWearable;

            if (!CombinedWearableExists(id))
            {
                wearable = GenerateNewCombinedWearable(wearable);
                combinedWearableDataToSave.Add(id, inventoryData.StatList(wearable));
                temporaryData.Add(id, inventoryData.StatList(wearable));
            }

            wearable.Amount += addOrSubtractAmount;

            EventBroker.Instance().SendMessage(new EventUpdateAmount(id, wearable.Amount));
            if (CombinedWearableAmountIsZero(wearable))
            {
                if (!Predefined(id))
                {
                    combinedWearableDataToSave.Remove(id);
                    temporaryData.Remove(id);
                    UpdateHud(wearable);
                    saveHandler.Save(this);
                    EventBroker.Instance().SendMessage(new EventDestroyCombinedWearable(id));
                    return;
                }
            }

            wearable.ShouldBeInteractable();

            AssignNewValues(id, wearable);

            wearable.ReduceAlpha();

            UpdateHud(wearable);

            combinedWearableDataToSave[id] = temporaryData[id];
            EventBroker.Instance().SendMessage(new EventSortInventory());
            EventBroker.Instance().SendMessage(new EventUpdateAmount(id, Convert.ToInt32(temporaryData[id][InventoryData.Amount])));
            // saveHandler.Save(this);
        }
コード例 #19
0
        void AssignToSlot(CombinedWearables combinedWearables)
        {
            if (combinedWearables.Amount <= 0)
            {
                return;
            }

            for (var i = 0; i < slots.Length; i++)
            {
                if (slots[i].transform.childCount > 0)
                {
                    if (!combineWearablesDic.ContainsValue(combinedWearables.rarity) || combineWearablesDic.ContainsKey(PlayerInventory.GetName(combinedWearables)))
                    {
                        break;
                    }
                }

                if (slots[i].transform.childCount < 1)
                {
                    var instance = Instantiate(combinedWearables, slots[i].transform, true);
                    instance.Amount      = combinedWearables.Amount;
                    instance.stylePoints = combinedWearables.stylePoints;
                    var scale = combinedWearables.GetComponent <RectTransform>().localScale;
                    instance.transform.localPosition = Vector2.zero;
                    instance.GetComponent <RectTransform>().localScale = scale;

                    instance.GetComponent <IconUpdate>().UpdateInformation();
                    Destroy(instance.GetComponent <AssignCombinedWearableToUpCycle>());
                    Destroy(instance.GetComponent <Button>());
                    combineWearablesDic[PlayerInventory.GetName(combinedWearables)] = combinedWearables.rarity;
                    break;
                }
            }

            EventBroker.Instance().SendMessage(new EventValidateConfirmButton(slots[0].transform.childCount > 0 && slots[1].transform.childCount > 0));
        }
コード例 #20
0
        public void DoesItemQualifyForDonation(EventAddToUpgradeSlot eventAddToUpgradeSlot)
        {
            if (!ValidateItem(eventAddToUpgradeSlot.combinedWearable))
            {
                donationPopUpWarnings.ShowWarningPopUp(eventAddToUpgradeSlot.combinedWearable);
                return;
            }

            donationPopUpWarnings.DisableWarning();
            TryRemoveChildren();

            originalWearable             = Instantiate(eventAddToUpgradeSlot.combinedWearable, itemToDonateSlot.transform, true);
            originalWearable.Amount      = eventAddToUpgradeSlot.combinedWearable.Amount;
            originalWearable.stylePoints = eventAddToUpgradeSlot.combinedWearable.stylePoints;
            originalWearable.GetComponent <IconUpdate>().UpdateInformation();
            var scale = itemToDonateSlot.GetComponent <RectTransform>().localScale;

            originalWearable.transform.localPosition = Vector2.zero;
            originalWearable.GetComponent <RectTransform>().localScale = scale;
            Destroy(originalWearable.GetComponent <Button>());
            originalWearable.GetComponent <CanvasGroup>().blocksRaycasts = false;

            upgradedWearable             = Instantiate(eventAddToUpgradeSlot.combinedWearable, upgradedItemSlot.transform, true);
            upgradedWearable.Amount      = 1;
            upgradedWearable.stylePoints = eventAddToUpgradeSlot.combinedWearable.stylePoints;
            upgradedOriginalStylePoints  = upgradedWearable.stylePoints;
            upgradedWearable.GetComponent <IconUpdate>().UpdateInformation();
            var scale2 = itemToDonateSlot.GetComponent <RectTransform>().localScale;

            upgradedWearable.transform.localPosition = Vector2.zero;
            upgradedWearable.GetComponent <RectTransform>().localScale   = scale2;
            upgradedWearable.GetComponent <CanvasGroup>().blocksRaycasts = false;
            Destroy(upgradedItemSlot.GetComponent <Button>());

            EventBroker.Instance().SendMessage(new EventUpdateAlternativesButtons());
        }
コード例 #21
0
        void Resize(CombinedWearables go, float newScale)
        {
            var newSize = new Vector2(newScale, newScale);

            go.GetComponent <RectTransform>().localScale = newSize;
        }
コード例 #22
0
 public EventClothesChanged(CombinedWearables combinedWearables)
 {
     CombinedWearables = combinedWearables;
 }
コード例 #23
0
 void ShowReward(CombinedWearables reward)
 {
     EventBroker.Instance().SendMessage(new EventMysteryBoxOpened(reward));
     EventBroker.Instance().SendMessage(new EventShowReward(reward));
 }
コード例 #24
0
 public EventBuyNotOwnedClothes(CombinedWearables combinedWearables)
 {
     this.CombinedWearables = combinedWearables;
 }
コード例 #25
0
 public bool PassedRequirement(CombinedWearables combinedWearables)
 {
     return(combinedWearables.rarity == Rarity && combinedWearables.clothingType == ClothingType &&
            combinedWearables.wearable.Any(wearable => wearable.colorData == ColorData));
 }
コード例 #26
0
 public bool ValidateItem(CombinedWearables combinedWearables)
 {
     return(combinedWearables.stylePoints < combinedWearables.rarity.MaxValue &&
            combinedWearables.Amount > 1);
 }
コード例 #27
0
ファイル: MatchColor.cs プロジェクト: forsbergsskola-se/Cred
 public bool PassedRequirement(CombinedWearables combinedWearables)
 {
     return(combinedWearables.wearable.Any(wearable => wearable.colorData == ColorData));
 }
コード例 #28
0
ファイル: Donate.cs プロジェクト: forsbergsskola-se/Cred
 void AssignedWearable(EventAddToUpgradeSlot eventAddToUpgradeSlot)
 {
     combinedWearables = eventAddToUpgradeSlot.combinedWearable;
 }
コード例 #29
0
 public EventUpdateCombinedUI(CombinedWearables combinedWearables)
 {
     this.combinedWearables = combinedWearables;
 }
コード例 #30
0
 public void Setup(CombinedWearables combinedWearables)
 {
     purchaseItemText.text = $"{purchaseTextPrefix} {combinedWearables.rarity.name} {combinedWearables.clothingType.SingularName}?";
     buyButton.GetComponentInChildren <Text>().text = clothingManager.GetPrice(combinedWearables.rarity).ToString();
     ShowItemToBuy(combinedWearables);
 }