Esempio n. 1
0
    public void GetChestReward(bool ifAdd)
    {
        if (BtnInteractable)
        {
            if (DataController.GetValue <int>("WinsForChest") >= 3)
            {
                GameObject warning;

                if (Inventory.instance.items.Count >= Inventory.instance.space - 8)
                {
                    warning = WarningScript.instance.warning;

                    warning.SetActive(true);

                    warning.GetComponentsInChildren <Text>()[0].text = LocalisationSystem.GetLocalisedValue("buyWarning4");

                    warning.GetComponentsInChildren <Text>()[1].text = LocalisationSystem.GetLocalisedValue("buyWarning4");

                    return;
                }

                if (!ifAdd)
                {
                    MoreButton.SetActive(true);
                }

                ChestInfoBtn.GetComponentInChildren <Animator>().Play("ChestInfoBtnNotEnough");

                DataController.SaveValue("WinsForChest", DataController.GetValue <int>("WinsForChest") - 3);

                firstTime = false;

                Chest.GetComponentInChildren <Animator>().Play("ChestOpen");

                rewardEquipment = GetRandomEquipment();

                PicOfReward.sprite = item.icon;

                Invoke("MoveShiningBack", 1.0f);

                Invoke("SaveRewardPic", 1.8f);

                Shining.GetComponentInChildren <SpriteRenderer>().sortingOrder = 4;

                ItemPickup.PickUpToInv(rewardEquipment);
            }
            BtnInteractable = false;
        }

        // Suggest to get the second chest for an add here
        if (!ifAdd)
        {
            if (DataController.GetValue <int>("WinsForChest") >= 3)
            {
                Invoke("UpdTextOfWinQuantity", 2.0f);
            }
            else
            {
                UpdTextOfWinQuantity();
            }
        }
        else
        {
            Chest.GetComponentInChildren <Animator>().Play("ChestOpen");

            rewardEquipment = GetRandomEquipment();

            PicOfReward.sprite = item.icon;

            Invoke("MoveShiningBack", 1.0f);

            Invoke("SaveRewardPic", 1.8f);

            Invoke("UpdTextOfWinQuantity", 2.0f);

            Shining.GetComponentInChildren <SpriteRenderer>().sortingOrder = 4;

            ItemPickup.PickUpToInv(rewardEquipment);
        }


        OkButton.SetActive(true);
    }
Esempio n. 2
0
    public void RefreshTheList()
    {
        foreach (string AName in MagicNamesGS)
        {
            Item item = ScriptableObject.CreateInstance <Item>(); //new Item();
            item.Price = DataController.GetValue <int>(AName + "Price");
            if (DataController.GetValue <int>(AName + "ammount") == 0)
            {
                item.ammount = 0;
            }
            else
            {
                item.ammount = 1;
            }
        }
        foreach (string AName in NewNamesGS)
        {
            item                        = (Equipment)ScriptableObject.CreateInstance(typeof(Equipment));
            item.name                   = AName;
            item.icon                   = Resources.Load <Sprite>("Pic" + AName); // add sprites in the Resources folder with names same as NewName variables here
            item.Price                  = DataController.GetValue <int>(AName + "Price");
            item.SellPrice              = DataController.GetValue <int>(AName + "SellPrice");
            item.ModifierArmor          = DataController.GetValue <int>(AName + "ModifierArmor");
            item.ModifierDamage         = DataController.GetValue <int>(AName + "ModifierDamage");
            item.ModifierMissChance     = DataController.GetValue <int>(AName + "ModifierMissChance");
            item.ModifierCriticalChance = DataController.GetValue <int>(AName + "ModifierCriticalChance");
            item.ModifierBashChance     = DataController.GetValue <int>(AName + "ModifierBashChance");
            item.ModifierStunChance     = DataController.GetValue <int>(AName + "ModifierStunChance");
            item.ModifierBlockChance    = DataController.GetValue <int>(AName + "ModifierBlockChance");
            item.ModifierMagic          = DataController.GetValue <int>(AName + "ModifierMagic");

            if (DataController.GetValue <int>(AName + "ammount") == 0)
            {
                item.ammount = 0;
            }
            else
            {
                item.ammount = 1;
            }

            if (AName.Contains("LongSword"))
            {
                item.equipSlot = EquipmentSlot.BothHands;
                LongSwords.instance.Add(item);
            }
            else
            if (AName.Contains("Sword"))
            {
                item.equipSlot = EquipmentSlot.RightHand;
                Swords.instance.Add(item);
            }
            else
            if (AName.Contains("Axe"))
            {
                item.equipSlot = EquipmentSlot.RightHand;
                Axes.instance.Add(item);
            }
            else
            if (AName.Contains("Spear"))
            {
                item.equipSlot = EquipmentSlot.RightHand;
                Spears.instance.Add(item);
            }
            else
            if (AName.Contains("Hammer"))
            {
                item.equipSlot = EquipmentSlot.BothHands;
                Hammers.instance.Add(item);
            }
            else
            if (AName.Contains("Daggers"))
            {
                item.equipSlot = EquipmentSlot.BothHands;
                Daggers.instance.Add(item);
            }

            if (AName.Contains("Helmet"))
            {
                item.equipSlot = EquipmentSlot.Head;
                Head.instance.Add(item);
            }
            else
            if (AName.Contains("BreastPlate"))
            {
                item.equipSlot = EquipmentSlot.Chest;
                Chest.instance.Add(item);
            }
            else
            if (AName.Contains("Sleeves"))
            {
                item.equipSlot = EquipmentSlot.Arms;
                Arms.instance.Add(item);
            }
            else
            if (AName.Contains("Pants"))
            {
                item.equipSlot = EquipmentSlot.Legs;
                Legs.instance.Add(item);
            }
            else
            if (AName.Contains("Boots"))
            {
                item.equipSlot = EquipmentSlot.Feet;
                Feet.instance.Add(item);
            }
            else
            if (AName.Contains("Shield"))
            {
                item.equipSlot = EquipmentSlot.LeftHand;
                Shields.instance.Add(item);
            }
            DataController.SaveValue(item.name + "equipSlot", Equipment.PossibleSlots[(int)item.equipSlot]);
            if (item.ammount > 0)
            {
                ItemPickup.PickUpToInv(item);
            }
        }
    }