void Shoot(int weapon) { switch (weapon) { case 1: if (Values.GetRevolvAmmo() > 0) { Ray ray = new Ray(Camera.main.transform.position + transform.forward * 0.2f, Camera.main.transform.forward); RaycastHit hit; Revolver.gameObject.GetComponent <AudioSource>().Play(); if (Physics.Raycast(ray, out hit) && hit.distance < revolverDistance && hit.collider.gameObject.tag == "Enemy") { // Debug.Log ("Distance: " + hit.distance + " GameObject " + hit.collider.gameObject); Values.ChangeFettHealth(revolverDamage); } Values.AddAmmo(-1); StartCoroutine(Cooldown()); } break; case 2: if (Values.GetTrapAmmo() > 0) { Instantiate(TrapPrefub, Player.transform.position + Player.transform.forward, Quaternion.identity); Values.AddTrap(-1); StartCoroutine(Cooldown()); } break; } }
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; } }