internal void PlaceItems(Random rand)
        {
            Coordinate center = Center();

            GameObject item = null;

            Constants.Items choice = RandomChoiceItems(rand, ItemChances);

            if (choice == Constants.Items.Fireball)
            {
                item      = new GameObject("Scroll of Fireball", Tiles.Item.ScrollTile, center.X + rand.Next(-1, 2), center.Y + rand.Next(-1, 2));
                item.Item = new Item(item, 1, Constants.UseFunctions.Fireball);
            }
            else if (choice == Constants.Items.Sword)
            {
                item                = new GameObject("Sword", Tiles.Item.SwordTile, center.X + rand.Next(-1, 2), center.Y + rand.Next(-1, 2));
                item.Item           = new Item(item, 1, Constants.UseFunctions.Equip);
                item.Item.Equipment = new Equipment(item.Item, Constants.Slots.MainHand, 2);
            }
            else if (choice == Constants.Items.HealingPotion)
            {
                item      = new GameObject("Healing Potion", Tiles.Item.HealingPotionTile, center.X + rand.Next(-1, 2), center.Y + rand.Next(-1, 2));
                item.Item = new Item(item, 1, Constants.UseFunctions.HealingPotion);
            }

            if (item != null)
            {
                Rogue.GameWorld.Objects.Add(item);
            }
        }
Exemple #2
0
    private void Upgrade(Upgrade upgrade,
                         Constants.Items itemToUpgrade)
    {
        if (IsUpgradable(upgrade))
        {
            SubstractOres();
            ChangePlayerValues();
            SetCosts(itemToUpgrade);
            updateOresInfo.SetContentInfo();
        }
        else
        {
            Debug.Log("unable to upgrade");
        }

        void ChangePlayerValues()
        {
            switch (itemToUpgrade)
            {
            case Constants.Items.PickaxeHead:
                SinglePlayerValues.damageValue =
                    pickaxeUpgrades[pickaxeHeadIndex].value;
                break;

            case Constants.Items.Stick:
                SinglePlayerValues.miningSpeedValue =
                    stickUpgrades[stickIndex].value;
                break;

            case Constants.Items.Hat:
                SinglePlayerValues.lightRadiusValue =
                    hatUpgrades[hatIndex].value;
                break;

            default:
                Debug.LogError("Incorrect item to upgrade");
                break;
            }
        }

        void SubstractOres()
        {
            for (int i = 0; i < Constants.oresAmount; i++)
            {
                if (upgrade.cost[i] != 0)
                {
                    SingleExtractedOresCounter.ores[i] -= upgrade.cost[i];
                }
            }
        }
    }
Exemple #3
0
    public void SetCosts(Constants.Items item)
    {
        Debug.Log("Set cost");
        switch (item)
        {
        case Constants.Items.PickaxeHead:
            Debug.Log(pickaxeHeadIndex);
            upgradeText =
                $"{SinglePlayerValues.damageValue} -> {pickaxeUpgrades[pickaxeHeadIndex + 1].value}";
            SetCost(pickaxeUpgrades[++pickaxeHeadIndex], pickaxeContainers);
            break;

        case Constants.Items.Stick:
            Debug.Log(stickIndex);
            upgradeText = $"{SinglePlayerValues.miningSpeedValue} -> {stickUpgrades[stickIndex + 1].value}";
            SetCost(stickUpgrades[++stickIndex], stickContainers);
            break;

        case Constants.Items.Hat:
            Debug.Log(hatIndex);
            upgradeText = $"{SinglePlayerValues.lightRadiusValue} -> {hatUpgrades[hatIndex + 1].value}";
            SetCost(hatUpgrades[++hatIndex], hatContainers);
            break;
        }

        if (pickaxeHeadIndex >= 0)
        {
            IsButtonColoredCheck(pickaxeUpgrades, pickaxeHeadIndex, pickaxeUpgradeButton);
        }
        if (stickIndex >= 0)
        {
            IsButtonColoredCheck(stickUpgrades, stickIndex, stickUpgradeButton);
        }
        if (hatIndex >= 0)
        {
            IsButtonColoredCheck(hatUpgrades, hatIndex, hatUpgradeButton);
        }

        void SetCost(Upgrade upgrade, Transform[,] container)
        {
            SetActiveFalse(container);

            var containerIndex = 0;

            for (int i = 0; i < Constants.oresAmount; i++)
            {
                if (upgrade.cost[i] != 0)
                {
                    for (int j = 0; j < container.GetLength(1); j++)
                    {
                        container[containerIndex, j].gameObject.SetActive(true);
                    }

                    container[containerIndex, 1].GetComponent <RawImage>().texture =
                        Constants.GetOre(i).shardTexture;

                    container[containerIndex, 2].GetComponent <TextMeshProUGUI>().text = upgrade.cost[i].ToString();

                    container[0, 0].parent.parent.GetChild(3).GetComponent <TextMeshProUGUI>().text = upgradeText;
                    containerIndex++;
                }
            }
        }
    }