Exemple #1
0
    public void OnTriggerStay(Collider collider)
    {
        switch (collider.gameObject.tag)
        {
        case "Note":
            Message.SetActive(true);
            if (Input.GetKey("e"))
            {
                FoundNotes[numberOfNotes] = collider.name;
                NoteButtons[numberOfNotes].SetActive(true);
                numberOfNotes++;
                Destroy(collider.gameObject);
            }
            break;

        case "Ammo":
            Message.SetActive(true);
            if (Input.GetKey("e"))
            {
                Destroy(collider.gameObject);
                Values.AddAmmo();
            }
            break;

        case "Medpack":
            Message.SetActive(true);
            if (Input.GetKey("e"))
            {
                Destroy(collider.gameObject);
                Values.ChangePlayerHealth(100);
            }
            break;

        case "Trap":
            Message.SetActive(true);
            if (Input.GetKey("e"))
            {
                Destroy(collider.gameObject);
                Values.AddTrap();
            }
            break;

        case "Can":
            Message.SetActive(true);
            if (Input.GetKey("e"))
            {
                Destroy(collider.gameObject);
                Values.AddCan();
            }
            break;

        case "Rope":
            Message.SetActive(true);
            if (Input.GetKey("e"))
            {
                Destroy(collider.gameObject);
                Values.AddRope();
            }
            break;

        case "Stick":
            Message.SetActive(true);
            if (Input.GetKey("e"))
            {
                Destroy(collider.gameObject);
                Values.AddStick();
            }
            break;

        case "SpotTrap":
            BuildingMessage.SetActive(true);
            if (Values.CanPlaceTrap())
            {
                BuildingMessage.GetComponent <Text>().text = "Press 'E' to place";
                if (Input.GetKey("e"))
                {
                    Values.tripwire.Place(collider.gameObject.transform.parent.gameObject);
                }
            }
            else
            {
                BuildingMessage.GetComponent <Text>().text = "Not enough items to place";
            }
            break;
        }
    }