Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (!isCollectable)
        {
            cd -= Time.deltaTime;
            anim.SetBool("isCollectable", false);
        }
        else
        {
            anim.SetBool("isCollectable", true);
        }

        if (cd < 0)
        {
            isCollectable = true;
            cd            = regenTime;
        }


        if (inRange && isCollectable)
        {
            if (Input.GetKeyDown(KeyCode.W))
            {
                bm.AddItem(fruitId);
                isCollectable = false;
            }
        }
    }
Beispiel #2
0
 public void OnButtonPressed(VirtualButtonBehaviour vb)
 {
     //animator.SetBool("pressed",true);
     text.SetActive(false);
     bm.AddItem(itemName);
     Debug.Log("ON");
 }
Beispiel #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "food")
     {
         string itemId = collision.gameObject.GetComponent <Item>().id;
         // add to bag
         im.AddItem(itemId); // add 1 item to bag
         im.DisplayBag();
         // destory it for current phase
         Destroy(collision.gameObject);
     }
 }
    public void OnRequestFinishedButtonClicked()
    {
        // give items to NPC
        foreach (string id in questGoal.Keys)
        {
            bm.LoseItem(id, questGoal[id]);
            Debug.Log("Finish quest, you lost " + id + questGoal[id]);
        }
        requestFinishButton.gameObject.SetActive(false);

        // give reward to player
        foreach (string id in rewards)
        {
            bm.AddItem(id);
            Debug.Log("You get the reward" + id);
        }
    }