Пример #1
0
 public override void InteractWithObject(Item item)
 {
     if (item == harpoon)
     {
         audioSource.PlayOneShot(splash);
         if (Random.Range(0f, 1f) > 0.3f)
         {
             FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().AddItem(rawFish, 1);
             if (Random.Range(0f, 1f) >= 0.95f)
             {
                 FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().RemoveItem(harpoon, 1);
                 notif.CreateNotif("Your harpoon broke!");
             }
         }
         else
         {
             notif.CreateNotif("You failed to catch fish.");
         }
     }
     else if (item != null)
     {
         notif.CreateNotif("Nothing interesting happened.");
     }
     else
     {
         notif.CreateNotif("You can't catch anything barehanded.");
     }
 }
Пример #2
0
    public override void InteractWithObject(Item item)
    {
        if (isBurning && item == null)
        {
            bool canCook = false;
            canCook = FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().SearchItem(rawFish, 1);

            Debug.Log(canCook);

            if (canCook)
            {
                if (Random.Range(0f, 1f) > 0.95f)
                {
                    FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().AddItem(burnedFish, 1);
                }
                else
                {
                    FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().AddItem(cookedFish, 1);
                }
                FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().RemoveItem(rawFish, 1);
            }
        }
        else if ((barkAmount == 0 && item == null) || item == bark)
        {
            bool hasBark = false;
            hasBark = FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().SearchItem(bark, 1);

            if (hasBark)
            {
                barkAmount += 30f;
                FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().RemoveItem(bark, 1);
                notif.CreateNotif("You add bark to the fireplace.");
            }
        }
        else if (isBurning && item == shirt)
        {
            notif.CreateNotif("The shirt burns, what did you expect?");
            FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>().RemoveItem(shirt, 1);
        }
        else if (!isBurning && item == null)
        {
            if (Random.Range(0f, 1f) > 0.3f)
            {
                isBurning          = true;
                fireLight.enabled  = true;
                fireSprite.enabled = true;
                notif.CreateNotif("You light a fire.");
            }
            else
            {
                notif.CreateNotif("You failed to light a fire.");
            }
        }
        else
        {
            notif.CreateNotif("Nothing interesting happened.");
        }
    }
Пример #3
0
 void Update()
 {
     if (Random.Range(0f, 1f) > 0.5f && coconuts < 4 && coconutTimer >= coconutSpawnRate)
     {
         coconutTimer = 0f;
         notif.CreateNotif("A coconut appears in the palm tree.");
         coconuts++;
         if (coconuts >= 4)
         {
             coconuts = 4;
         }
     }
     else
     {
         coconutTimer += Time.deltaTime;
     }
 }
Пример #4
0
 public override void InteractWithObject(Item item)
 {
     if (item != null)
     {
         notif.CreateNotif("Nothing interesting happens.");
     }
     else
     {
         FindObjectOfType <PlayerInventory>().AddItem(flints, Random.Range(1, 4));
         Destroy(gameObject);
     }
 }
Пример #5
0
 public override void InteractWithObject(Item item)
 {
     if (item != null)
     {
         notif.CreateNotif("Why would you do that? This is your way to escape.");
     }
     else
     {
         DOTween.KillAll();
         SceneManager.LoadScene("Survived");
     }
 }
    private void Craft()
    {
        //Harpoon
        Debug.Log(itemsSelectedForCrafting.Count);
        if (itemsSelectedForCrafting.Count == 3)
        {
            int canCraft = 0;
            for (int i = 0; i < 3; i++)
            {
                itemsSelectedForCrafting.ForEach(iitem => {
                    if (iitem.item == itemDictionary.items[0].materials[i])
                    {
                        canCraft++;
                    }
                });
            }

            Debug.Log(canCraft);

            if (canCraft == 3)
            {
                itemsSelectedForCrafting.ForEach(iitem => {
                    RemoveItem(iitem.item, 1);
                });
                itemsSelectedForCrafting.Clear();
                AddItem(itemDictionary.items[0].result, 1);
            }
            else
            {
                notifController.CreateNotif("Crafting failed");
            }
        }
        else
        {
            notifController.CreateNotif("Crafting failed");
        }
    }
 public override void Interaction(Item item)
 {
     if (Random.Range(0f, 1f) >= successChance)
     {
         playerInventory = FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>();
         playerInventory.AddItem(receiveItem, amount);
         playerInventory.RemoveItem(item, 1);
     }
     else
     {
         if (notif == null)
         {
             notif = FindObjectOfType <NotifController>().GetComponent <NotifController>();
         }
         notif.CreateNotif(failNotifMsg);
     }
 }
Пример #8
0
 public override void Interaction(Item item)
 {
     if (Random.Range(0f, 1f) > 0.7f)
     {
         playerInventory = FindObjectOfType <PlayerInventory>().GetComponent <PlayerInventory>();
         playerInventory.AddItem(halfCoconut, 2);
         playerInventory.RemoveItem(item, 1);
     }
     else
     {
         if (notif == null)
         {
             notif = FindObjectOfType <NotifController>().GetComponent <NotifController>();
         }
         notif.CreateNotif("You failed to break the coconut.");
     }
 }
Пример #9
0
    void Update()
    {
        itemSpawnTime += Time.deltaTime;

        if (itemSpawnTime >= itemSpawnRate)
        {
            itemSpawnTime = 0;
            if (Random.Range(0f, 1f) > 0.25f)
            {
                Vector2 spawnpos = spawnSpots[Random.Range(0, spawnSpots.Length)];
                if (!Physics2D.CircleCast(spawnpos, 0.5f, Vector2.up, 0))
                {
                    GameObject item = Instantiate(items[Random.Range(0, items.Length)], spawnpos, Quaternion.identity);
                    item.SetActive(true);
                }
                notif.CreateNotif("Something washed ashore.");
            }
        }
    }