// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit obj; if (Physics.Raycast(transform.position + transform.forward * 0.5f, transform.forward, out obj, 1.0f)) { Trigger t = obj.collider.GetComponent <Trigger>(); Debug.Log("Trying to click " + obj.collider.name + "..."); if (t != null && t.triggerType == TriggerType.Clickable) { if (t.state == State.Activated) { t.Deactivate(); } else { t.Activate(); } } } } }
public void Setup() { someTrigger = new Trigger(() => testBoolean = true); someTrigger.Activate(); failingTrigger = new Trigger(() => throw new Exception()); failingTrigger.Activate(); }
private void Update() { foreach (LightTrigger light in GameManager.Instance.Lights) { if (light.IsLit && Vector3.SqrMagnitude(light.transform.position - transform.position) < 16) { Trigger.Activate(); break; } } }
private void Update() { bool inLight = false; foreach (LightTrigger light in GameManager.Instance.Lights) { if (light.IsLit && Vector3.SqrMagnitude(light.transform.position - transform.position) < 25) { inLight = true; break; } } if (!inLight) { Trigger.Activate(); } }
//check for step triggers private void CheckForTrigger() { List <Collider2D> results = new List <Collider2D>(); ContactFilter2D filter = new ContactFilter2D(); filter.useTriggers = true; if (boxCollider.OverlapCollider(filter, results) > 0) { foreach (Collider2D item in results) { Trigger target = item.gameObject.GetComponent <Trigger>(); if (target != null) { target.Activate(); } } } }
private void Update() { bool allActive = true; bool allActiveOnce = true; foreach (Trigger trigger in Triggers) { if (!trigger.Activated) { allActive = false; } if (!trigger.ActivatedOnce) { allActiveOnce = false; } } if (AllActiveTrigger != null) { if (allActive) { if (!AllActiveTriggered) { AllActiveTrigger.Activate(null); AllActiveTriggered = true; } } else { AllActiveTriggered = false; } } if (AllActiveOnceTrigger != null && allActiveOnce && !AllActiveOnceTriggered) { AllActiveOnceTrigger.Activate(null); AllActiveOnceTriggered = true; } }
/* Update Method * Send out a raycast forward to return what it hits * If the hit object has the tag Button and is in the LayerMask * If the user left clicks, the button will be activated * Don't worry about double activation, button script will handle with states */ void Update() { if (Physics.Raycast(transform.position, transform.forward, out hitInfo, buttonPressDist, pickupMask)) { Trigger t = hitInfo.collider.GetComponent <Trigger>(); if (t != null && t.triggerType == TriggerType.Clickable) { //TODO Display some GUI thing that'll tell the user he can interact. pointedAt = true; Debug.DrawRay(transform.position, buttonPressDist * transform.forward, Color.green); if (Input.GetMouseButtonDown(0)) { if (t.state == State.Activated) { t.Deactivate(); } else { t.Activate(); } audio.PlayOneShot(buttonSound, 1); } } else { pointedAt = false; Debug.DrawRay(transform.position, buttonPressDist * transform.forward, Color.yellow); } } else { pointedAt = false; Debug.DrawRay(transform.position, buttonPressDist * transform.forward, Color.red); } }
public void OnTurnEnd(TurnManager turnManager, Character unit) { onTurnEndTriggers.Activate(unit.Stats, turnManager, _ui); }
public void OnKill(TurnManager turnManager, Character unit) { onKillTriggers.Activate(unit.Stats, turnManager, _ui); }