예제 #1
0
 public void AddSpice(Spice spice)
 {
     ownedSpices[spice]++;
     OnSpicePicked?.Invoke(this, new OnSpicePickedUp {
         spiceIcon = spice.spiceIcon, spiceName = spice.spiceName
     });
 }
예제 #2
0
 public void AddNewSpice(Spice spice)
 {
     ownedSpices.Add(spice, 1);
     OnSpicePicked?.Invoke(this, new OnSpicePickedUp {
         spiceIcon = spice.spiceIcon, spiceName = spice.spiceName
     });
 }
예제 #3
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.E) && !isSpellCrafting && pc.canJump)
        {
            spellCraftingSpices = new Spice[3];
            isSpellCrafting     = true;
            pc.DisableMovement();
            pc.SpellCraft(true);
            spellCraftingCam.gameObject.SetActive(true);
            cookingPot.gameObject.SetActive(true);
            GetSpices();
            spellCraftingUI.SetActive(true);
        }
        else if (Input.GetKeyDown(KeyCode.E) && isSpellCrafting && pc.canJump)
        {
            isSpellCrafting = false;
            pc.EnableMovement();
            cookingPot.gameObject.SetActive(false);
            pc.SpellCraft(false);
            spellCraftingCam.gameObject.SetActive(false);
            spellCraftingUI.SetActive(false);
        }

        if (isSpellCrafting)
        {
            if (Input.GetKeyDown(KeyCode.A))
            {
                if (spiceSlot - 1 < 0)
                {
                    spiceSlot = 2;
                }
                else
                {
                    spiceSlot -= 1;
                }

                OnSpiceSlotChanged?.Invoke(this, new OnSpiceSlotChangedArgs()
                {
                    spiceSlot = spiceSlot
                });
                spiceChangedAudioSource.Play();
            }

            if (Input.GetKeyDown(KeyCode.D))
            {
                if (spiceSlot + 1 > 2)
                {
                    spiceSlot = 0;
                }
                else
                {
                    spiceSlot += 1;
                }

                OnSpiceSlotChanged?.Invoke(this, new OnSpiceSlotChangedArgs()
                {
                    spiceSlot = spiceSlot
                });
                spiceChangedAudioSource.Play();
            }

            if (Input.GetKeyDown(KeyCode.W))
            {
                if (ownedSpiceList.Count != 0)
                {
                    if (spiceIndex + 1 > ownedSpiceList.Count - 1)
                    {
                        spiceIndex = 0;
                    }
                    else
                    {
                        spiceIndex += 1;
                    }
                    spellCraftingSpices[spiceSlot] = ownedSpiceList[spiceIndex];
                }

                OnSpiceChanged?.Invoke(this, new OnSpiceChangedArgs()
                {
                    spice = ownedSpiceList[spiceIndex]
                });
                spiceChangedAudioSource.Play();
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                if (ownedSpiceList.Count != 0)
                {
                    if (spiceIndex - 1 < 0)
                    {
                        spiceIndex = ownedSpiceList.Count - 1;
                    }
                    else
                    {
                        spiceIndex -= 1;
                    }
                    spellCraftingSpices[spiceSlot] = ownedSpiceList[spiceIndex];
                }

                OnSpiceChanged?.Invoke(this, new OnSpiceChangedArgs()
                {
                    spice = ownedSpiceList[spiceIndex]
                });
                spiceChangedAudioSource.Play();
            }
        }

        if (Input.GetKeyDown(KeyCode.R) && isSpellCrafting)
        {
            for (int i = 0; i < 3; i++)
            {
                if (spellCraftingSpices[i] == null)
                {
                    return;
                }
            }

            foreach (Recipe recipe in unlockedRecipes)
            {
                if (CheckForCorrectRecipe(recipe))
                {
                    if (CheckForCorrectAmountOfSpices(recipe))
                    {
                        OnSpellCrafted?.Invoke(this, new OnSpellCraftedArgs()
                        {
                            recipe = recipe
                        });
                        foreach (Ingredient ingredient in recipe.ingredients)
                        {
                            ownedSpices[ingredient.requiredSpice] -= ingredient.requiredAmount;
                        }
                        foreach (Spice s in ownedSpices.Keys)
                        {
                            OnSpicePicked?.Invoke(this, new OnSpicePickedUp {
                                spiceIcon = s.spiceIcon, spiceName = s.spiceName
                            });
                        }
                        spellCompletedAudioSource.Play();
                        break;
                    }
                    else
                    {
                        spellFailedAudioSource.Play();
                        break;
                    }
                }
            }
        }
    }