void OnTriggerExit(Collider other) { if (!_isEntered) { return; } if (requireGameObject != null) { var rtr = requireGameObject.transform; var ctr = other.transform; while (ctr != null) { if (rtr == ctr) { onExit.Invoke(other.gameObject); _isEntered = false; return; } ctr = ctr.transform.parent; } } else if (other.tag == requireTag) { onExit.Invoke(other.gameObject); _isEntered = false; } }
// Use this for initialization void OnTriggerEnter2D(Collider2D col) { if (col.tag == targetTag) { action.Invoke(col.gameObject); } }
// Invoke handlers for Custom Unity Events public void Invoke <T>(T arg0) { if (Event == null) { return; } if (Event.UnityEventType == typeof(UnityEventGameObject) && arg0 is GameObject gameObject) { responseGameObject.Invoke(gameObject); } else if (Event.UnityEventType == typeof(UnityEventTransform) && arg0 is Transform transform) { responseTransform.Invoke(transform); } else if (Event.UnityEventType == typeof(UnityEventInt) && arg0 is int intValue) { responseInt.Invoke(intValue); } else if (Event.UnityEventType == typeof(UnityEventFloat) && arg0 is float floatValue) { responseFloat.Invoke(floatValue); } else if (Event.UnityEventType == typeof(UnityEventBool) && arg0 is bool boolValue) { responseBool.Invoke(boolValue); } else if (Event.UnityEventType == typeof(UnityEventString) && arg0 is string stringValue) { responseString.Invoke(stringValue); } }
void Die() { if (isDead) { return; } isDead = true; if (onDeath != null) { onDeath.Invoke(); } if (spawnOnDeath != null) { var go = Instantiate(spawnOnDeath); go.transform.position = this.transform.position; if (onDeathPrefabInstantiated != null) { onDeathPrefabInstantiated.Invoke(go); } } if (destroyOnDeath) { Destroy(this.gameObject); } }
public static void TryInvoke(this UnityEventGameObject evt, GameObject value) { if (evt != null) { evt.Invoke(value); } }
private void OnParticleCollision(GameObject other) { if (string.IsNullOrEmpty(Tag) || other.HasTag(Tag)) { Callback.Invoke(other); } }
// Update is called once per frame void Update() { if (!col.bounds.Contains(cachedTransform.position)) { action.Invoke(gameObject); } }
private void OnTriggerEnter(Collider other) { if (!m_objectsInTrigger.Contains(other.attachedRigidbody.gameObject)) { m_objectsInTrigger.Add(other.attachedRigidbody.gameObject); onEnter.Invoke(other.attachedRigidbody.gameObject); } }
void OnPicked(PlayerCharacterController player) { onPickup.Invoke(); onPickupGameObject.Invoke(this.gameObject); // remove the calibration object -- so don't call multiple times. Destroy(gameObject); }
public void OnSelection() { // method called when this object is selected by the BCI Debug.Log("-------------- Selected: " + myobjID + "---------------------"); // invoke our selection handler Debug.Log("Invoking:" + selectedEvent.ToString()); selectedEvent.Invoke(); selectedObjectEvent.Invoke(this.gameObject); }
private void OnTriggerEnter(Collider other) { if (other.GetComponent <AIBehaviour>() == null) { return; } if (onTriggerEnter != null) { onTriggerEnter.Invoke(other.gameObject); } }
void FixedUpdate() { if (_screenSize.CheckPosition(transform.position)) { _rigidbody.velocity = transform.forward * _speed * Time.deltaTime; _rigidbody.rotation *= Quaternion.Euler(transform.forward * _speed * Time.deltaTime); } else { OutOfScreen.Invoke(gameObject); } }
void OnTriggerExit(Collider other) { if (!_isPlayerIn) { return; } if (other.tag == requireTag) { onExit.Invoke(other.gameObject); _isPlayerIn = false; } }
public void Hit(int hitCount) { if (_audioSource) { _audioSource.PlayOneShot(_hitSound); } _currentHealth -= hitCount; MinusOneHealth.Invoke(); if (_currentHealth <= 0f) { ZeroHP.Invoke(gameObject); } }
void OnTriggerEnter(Collider other) { if (_isPlayerIn) { return; } if (other.tag == requireTag) { onEnter.Invoke(other.gameObject); _isPlayerIn = true; } }
private void Update() { if (previousGroundCheck != groundCheck) { if (groundCheck) { onEnterGround.Invoke(gameObject); } else { onExitGround.Invoke(gameObject); } previousGroundCheck = groundCheck; } }
// deal damage while acknowledging the target's defense etc. public void DealDamageAt(GameObject other, int amount, Vector3 hitPoint, Vector3 hitNormal, Collider hitCollider) { if (other != null) { Health otherHealth = other.GetComponent <Health>(); Combat otherCombat = other.GetComponent <Combat>(); if (otherHealth != null && otherCombat != null) { // not dead yet? and not invincible? if (otherHealth.current > 0 && !otherCombat.invincible) { // extra damage on that collider? (e.g. on head) DamageArea damageArea = hitCollider.GetComponent <DamageArea>(); float multiplier = damageArea != null ? damageArea.multiplier : 1; int amountMultiplied = Mathf.RoundToInt(amount * multiplier); // subtract defense (but leave at least 1 damage, otherwise // it may be frustrating for weaker players) int damageDealt = Mathf.Max(amountMultiplied - otherCombat.defense, 1); // deal the damage otherHealth.current -= damageDealt; // show effect on the other end otherCombat.ShowDamageEffect(damageDealt, hitPoint, hitNormal); // call OnReceivedDamage event on the target // -> can be used for monsters to pull aggro // -> can be used by equipment to decrease durability etc. otherCombat.onReceivedDamage.Invoke(gameObject, damageDealt); // killed it? then call OnKilledEnemy(other) if (otherHealth.current == 0) { onKilledEnemy.Invoke(other); } } } } }
public override void OnEventRaised(GameObject input) { base.OnEventRaised(input); response.Invoke(input); }
public void OnPointerUp(PointerEventData eventData) { onUp.Invoke(gameObject); }
public void OnPointerExit(PointerEventData eventData) { onExit.Invoke(gameObject); }
public void OnPointerEnter(PointerEventData eventData) { onEnter.Invoke(gameObject); }
public void OnPointerDown(PointerEventData eventData) { onDown.Invoke(gameObject); }
public void OnEventRaised(GameObject parameter) { ResponseGameObject.Invoke(parameter); }
private void OnCollisionStay2D(Collision2D collision) { onCollisionStay.Invoke(collision.gameObject); }
// -- Private Functions private void OnCollisionEnter2D(Collision2D collision) { onCollisionEnter.Invoke(collision.gameObject); }
public void OnPointerClick(PointerEventData eventData) { onClick.Invoke(gameObject); }
private void OnCollisionExit2D(Collision2D collision) { onCollisionExit.Invoke(collision.gameObject); }
private void OnTriggerExit(Collider other) { m_objectsInTrigger.Remove(other.attachedRigidbody.gameObject); onExit.Invoke(other.attachedRigidbody.gameObject); }
private void OnEventRaised(GameObject value) { _response?.Invoke(value); }
private void OnDisable() { _rigidbody.velocity = Vector3.zero; bulletDisabled.Invoke(gameObject); }