// Update is called once per frame void Update() { if (GameObject.Find("DialogueCanvasDecorated").GetComponent <DialogueBox>().IsShowing()) { Hide(); } else if (Input.GetKeyDown(KeyCode.Mouse0)) { if (_canClick) { if (MyButtonCommand.MouseIsOverOtherButton() == false && GameObject.Find("DialogueCanvasDecorated").GetComponent <DialogueBox>().IsShowing() == false) { Vector3 mousePos = Input.mousePosition; mousePos.z = 2.0f; // we want 2m away from the camera position Vector3 objectPos = Camera.main.ScreenToWorldPoint(mousePos); this.transform.position = objectPos; PlayEntryAnimation(); } } else { Hide(); } } if (_playEntryAnimation) { if (this.transform.localScale.x < _normalScale.x) { this.transform.localScale += new Vector3(growthRate, growthRate, growthRate) * Time.deltaTime; } else if (this.transform.localScale.x > _normalScale.x) { this.transform.localScale = _normalScale; _playEntryAnimation = false; Vector3 pos = Camera.main.WorldToViewportPoint(transform.position); pos.x = Mathf.Clamp(pos.x, 0.1f, 0.88f); pos.y = Mathf.Clamp(pos.y, 0.3f, 0.82f); transform.position = Camera.main.ViewportToWorldPoint(pos); } else { _playEntryAnimation = false; } } }
private void ChangeCommandWheelEvents() { GameObject commandWheel = GameObject.Find("CommandWheel"); MyButtonCommand equip = Utilities.SearchChild("Equip", commandWheel).GetComponent <MyButtonCommand>(); MyButtonCommand hit = Utilities.SearchChild("Hit", commandWheel).GetComponent <MyButtonCommand>(); MyButtonCommand examine = Utilities.SearchChild("Examine", commandWheel).GetComponent <MyButtonCommand>(); MyButtonCommand go = Utilities.SearchChild("Go", commandWheel).GetComponent <MyButtonCommand>(); MyButtonCommand take = Utilities.SearchChild("Take", commandWheel).GetComponent <MyButtonCommand>(); MyButtonCommand talk = Utilities.SearchChild("Talk", commandWheel).GetComponent <MyButtonCommand>(); MyButtonCommand use = Utilities.SearchChild("Use", commandWheel).GetComponent <MyButtonCommand>(); MyButtonCommand open = Utilities.SearchChild("Open", commandWheel).GetComponent <MyButtonCommand>(); if (canEquip) { equip.SetClickedEvent(m_OnEquip); } else { equip.SetClickedEvent(new UnityEvent()); } if (canHit) { hit.SetClickedEvent(m_OnHit); } else { hit.SetClickedEvent(new UnityEvent()); } if (canExamine) { examine.SetClickedEvent(m_OnExamine); } else { examine.SetClickedEvent(new UnityEvent()); } if (canGo) { go.SetClickedEvent(m_OnGo); } else { go.SetClickedEvent(new UnityEvent()); } if (canTake) { take.SetClickedEvent(m_OnTake); } else { take.SetClickedEvent(new UnityEvent()); } if (canTalk) { talk.SetClickedEvent(m_OnTalk); } else { talk.SetClickedEvent(new UnityEvent()); } if (canUse) { use.SetClickedEvent(m_OnUse); } else { use.SetClickedEvent(new UnityEvent()); } if (canOpen) { open.SetClickedEvent(m_OnOpen); } else { open.SetClickedEvent(new UnityEvent()); } }