示例#1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        circleCollider2D = gameObject.GetComponent <CircleCollider2D>();
        if (collision.gameObject.tag == "Player" && circleCollider2D.IsTouching(collision.GetComponent <CapsuleCollider2D>()))
        {
            enemy       = collision.gameObject;
            enemyBody   = enemy.GetComponent <Rigidbody2D>();
            enemyPlayer = enemy.GetComponent <Player>();
            ContactSwarm(enemy, enemyBody, enemyPlayer);

            musicManager.AddAlien(this);
            musicManager.UpdateMusik();
        }
        if (collision.gameObject.tag == "Entity" && circleCollider2D.IsTouching(collision.GetComponent <CapsuleCollider2D>()))
        {
            UnitInRange.Add(collision.gameObject);
            aggression += UnitInRange.Count;
        }
        if (collision.gameObject.tag == "Bullet")
        {
            bulletsInRange.Add(collision.GetComponent <Bullet>());
        }
    }