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);
     }
 }
Esempio n. 3
0
 // 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);
     }
 }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 8
0
 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);
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <AIBehaviour>() == null)
     {
         return;
     }
     if (onTriggerEnter != null)
     {
         onTriggerEnter.Invoke(other.gameObject);
     }
 }
Esempio n. 12
0
 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);
     }
 }
Esempio n. 13
0
        void OnTriggerExit(Collider other)
        {
            if (!_isPlayerIn)
            {
                return;
            }

            if (other.tag == requireTag)
            {
                onExit.Invoke(other.gameObject);
                _isPlayerIn = false;
            }
        }
Esempio n. 14
0
 public void Hit(int hitCount)
 {
     if (_audioSource)
     {
         _audioSource.PlayOneShot(_hitSound);
     }
     _currentHealth -= hitCount;
     MinusOneHealth.Invoke();
     if (_currentHealth <= 0f)
     {
         ZeroHP.Invoke(gameObject);
     }
 }
Esempio n. 15
0
        void OnTriggerEnter(Collider other)
        {
            if (_isPlayerIn)
            {
                return;
            }

            if (other.tag == requireTag)
            {
                onEnter.Invoke(other.gameObject);
                _isPlayerIn = true;
            }
        }
Esempio n. 16
0
    private void Update()
    {
        if (previousGroundCheck != groundCheck)
        {
            if (groundCheck)
            {
                onEnterGround.Invoke(gameObject);
            }
            else
            {
                onExitGround.Invoke(gameObject);
            }

            previousGroundCheck = groundCheck;
        }
    }
Esempio n. 17
0
    // 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);
        }
Esempio n. 19
0
 public void OnPointerUp(PointerEventData eventData)
 {
     onUp.Invoke(gameObject);
 }
Esempio n. 20
0
 public void OnPointerExit(PointerEventData eventData)
 {
     onExit.Invoke(gameObject);
 }
Esempio n. 21
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     onEnter.Invoke(gameObject);
 }
Esempio n. 22
0
 public void OnPointerDown(PointerEventData eventData)
 {
     onDown.Invoke(gameObject);
 }
Esempio n. 23
0
 public void OnEventRaised(GameObject parameter)
 {
     ResponseGameObject.Invoke(parameter);
 }
Esempio n. 24
0
 private void OnCollisionStay2D(Collision2D collision)
 {
     onCollisionStay.Invoke(collision.gameObject);
 }
Esempio n. 25
0
 // -- Private Functions
 private void OnCollisionEnter2D(Collision2D collision)
 {
     onCollisionEnter.Invoke(collision.gameObject);
 }
Esempio n. 26
0
 public void OnPointerClick(PointerEventData eventData)
 {
     onClick.Invoke(gameObject);
 }
Esempio n. 27
0
 private void OnCollisionExit2D(Collision2D collision)
 {
     onCollisionExit.Invoke(collision.gameObject);
 }
Esempio n. 28
0
 private void OnTriggerExit(Collider other)
 {
     m_objectsInTrigger.Remove(other.attachedRigidbody.gameObject);
     onExit.Invoke(other.attachedRigidbody.gameObject);
 }
 private void OnEventRaised(GameObject value)
 {
     _response?.Invoke(value);
 }
Esempio n. 30
0
    private void OnDisable()
    {
        _rigidbody.velocity = Vector3.zero;

        bulletDisabled.Invoke(gameObject);
    }