Esempio n. 1
0
    public string GetIngredientsCode()
    {
        bool w = false;
        bool f = false;
        bool e = false;
        bool a = false;

        foreach (GameObject s in slots)
        {
            if (s != null)
            {
                if (s.activeInHierarchy)
                {
                    UISlotScript uISlot = s.GetComponent <UISlotScript>();
                    if (uISlot.GetType() == typeof(DecorationSlot))
                    {
                        switch (uISlot.Container.type)
                        {
                        case Barks.GET_DECOR_WATER:
                            w = true;
                            break;

                        case Barks.GET_DECOR_FIRE:
                            f = true;
                            break;

                        case Barks.GET_DECOR_EARTH:
                            e = true;
                            break;

                        case Barks.GET_DECOR_AIR:
                            a = true;
                            break;
                        }
                    }
                    if (uISlot.GetType() == typeof(InspirationSlot))
                    {
                        switch (crafter.proficience)
                        {
                        case Theme.WATER:
                            w = true;
                            break;

                        case Theme.FIRE:
                            f = true;
                            break;

                        case Theme.EARTH:
                            e = true;
                            break;

                        case Theme.AIR:
                            a = true;
                            break;
                        }
                    }
                }
            }
        }

        string key = "";

        if (w)
        {
            key += "w";
        }
        if (f)
        {
            key += "f";
        }
        if (e)
        {
            key += "e";
        }
        if (a)
        {
            key += "a";
        }


        return(key);
    }
Esempio n. 2
0
    private IEnumerator SlowUpdate()
    {
        while (true)
        {
            yield return(new WaitForSecondsRealtime(0.1f));

            // Crafting UI
            Slot1.Spell    = Slot1Spell;
            Slot1.Quantity = Slot1Quantity;
            Slot2.Spell    = Slot2Spell;
            Slot2.Quantity = Slot2Quantity;

            // Fill out inventory
            foreach (Spell spell in Enum.GetValues(typeof(Spell)))
            {
                // Except for nothing and everything
                if (spell != Spell.NOTHING && spell != Spell.EVERYTHING)
                {
                    // Get inventory quantity
                    int quantity = GameState.Instance.Quantities[spell];

                    // Fills in slot
                    UISlotScript slot = GetSlot(spell);
                    if (slot != null)
                    {
                        slot.Quantity = quantity;
                    }
                }
            }

            // Fills out combinations we've unlocked
            UnlockedText.text = "";
            foreach ((Spell, Spell)spellPair in GameState.Instance.Mappings.Keys)
            {
                if (GameState.Instance.LearnedMappings.Contains(spellPair))
                {
                    (Spell, Spell)resultSpellPair = GameState.Instance.Mappings[spellPair];
                    UnlockedText.text            +=
                        spellPair.Item1.ToString() +
                        " + " +
                        spellPair.Item2.ToString() +
                        " -> " +
                        resultSpellPair.Item1.ToString() +
                        (resultSpellPair.Item2 != Spell.NOTHING ?
                         " + " + resultSpellPair.Item2.ToString() :
                         "") +
                        "\n";
                }
                else
                {
                    UnlockedText.text += "???\n";
                }
            }

            // Checks if we've won the game
            bool won = true;
            foreach (var spellPair in GameState.Instance.Mappings.Keys)
            {
                if (!GameState.Instance.LearnedMappings.Contains(spellPair))
                {
                    won = false;
                    break;
                }
            }
            if (won)
            {
                SceneManager.LoadScene("PreWin");
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     uiSlot = GetComponent <UISlotScript>();
     uiSlot.ShowNothingSprite = true;
 }