Ejemplo n.º 1
0
    private void OnCollisionEnter(Collision collision)
    {
        Collider myCollider  = collision.contacts[0].thisCollider;
        Collider hisCollider = collision.contacts[0].otherCollider;

        if (hisCollider.CompareTag("Wall"))
        {
            InteractionManager wallInteraction = collision.gameObject.GetComponent <InteractionManager>();
            if (wallInteraction != null)
            {
                wallInteraction.getInteraction()?.RunInteraction(gameObject);
            }
        }
        else if (myCollider.CompareTag("Balloon") && (hisCollider.CompareTag("Knife") || hisCollider.CompareTag("Damaging")))
        {
            if (!_isInvincible)
            {
                if (PlayerConfigManager.Instance._teamsEnabled)
                {
                    InputManager myInput  = GetComponent <InputManager>();
                    InputManager hisInput = hisCollider.GetComponentInParent <InputManager>();
                    if (hisInput != null && myInput._teamBlue != hisInput._teamBlue)
                    {
                        TakeDamage(myCollider);
                    }
                }
                else
                {
                    TakeDamage(myCollider);
                }
            }
        }
        else if (collision.gameObject.CompareTag("Player"))
        {
            Rigidbody rb = collision.gameObject.GetComponent <Rigidbody>();
            if (rb.velocity.magnitude >= 12)
            {
                Vector3 direction = transform.position - collision.transform.position;
                _controller.GetStunned(0.5f, new Vector2(direction.x, direction.z), 200);
            }
        }
        else if (myCollider.transform.parent.CompareTag("Player") && hisCollider.CompareTag("Damaging"))
        {
            Vector3 direction = Vector3.Normalize(hisCollider.transform.position - myCollider.transform.position);
            _controller.GetStunned(1.5f, new Vector2(-direction.x, -direction.z), 300);
        }
    }
Ejemplo n.º 2
0
    public void Explosion(GameObject obj)
    {
        foreach (GameObject _target in _players)
        {
            if (ReferenceEquals(obj, _target))
            {
                continue;
            }

            if (Vector3.Distance(_target.transform.position, obj.transform.position) < distance)
            {
                Vector3             direction   = Vector3.Normalize(_target.transform.position - obj.transform.position);
                NewRoombaController _controller = _target.GetComponent <NewRoombaController>();
                _target.GetComponent <PlayerVariables>().MaxSpeed = 100;
                _controller.GetStunned(1f, new Vector2(direction.x, direction.z), 2000);
                StartCoroutine(_controller.changeKnife());
            }
        }
    }