Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Iteraction : Base_Gameplay
- {
- private Iteraction useItem;
- private Iteraction takeItem;
- protected ObjectOfType type;
- public GameObject TakeUIButton;
- public GameObject UseUIButton;
- void Start()
- {
- useItem = new UseItem();
- takeItem = new TakeItem();
- }
- void Update()
- {
- Vector3 fwd = transform.TransformDirection(Vector3.forward);
- RaycastHit hit;
- if (Physics.Raycast(transform.position, fwd, out hit, 3))
- {
- if(hit.collider.gameObject.tag == "Item")
- {
- type = hit.collider.gameObject.GetComponent<ObjectOfType>();
- if (type.type == ObjectOfType.Type.Button)
- {
- UseUIButton.SetActive(true);
- #if UNITY_EDITOR
- if(Input.GetKeyDown(KeyCode.E))
- useItem.Use();
- #endif
- }
- if (type.type == ObjectOfType.Type.Battery ||type.type == ObjectOfType.Type.Keys ||type.type == ObjectOfType.Type.Note)
- {
- TakeUIButton.SetActive(true);
- #if UNITY_EDITOR
- if(Input.GetKeyDown(KeyCode.E))
- takeItem.Take();
- #endif
- }
- }
- else
- {
- UseUIButton.SetActive(false);
- TakeUIButton.SetActive(false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement