Exemple #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Targetable collidedObject = collision.gameObject.GetComponent <Targetable>();

        if (collidedObject == null)
        {
            return;
        }

        if (!((collidedObject.IsPlayersTeam && isTargetingEnemyTeam) || (!collidedObject.IsPlayersTeam && !isTargetingEnemyTeam)))
        {
            return;
        }

        lock (collidedObject)
        {
            collidedObject.Hit();
        }

        Destroy(this.gameObject);
    }
Exemple #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Targetable target = collision.gameObject.GetComponent <Targetable>();

        if (target == null)
        {
            return;
        }

        if (target.IsPlayersTeam != isTargetingPlayer)
        {
            return;
        }

        lock (target)
        {
            target.Hit();
        }

        Destroy(this.gameObject);
    }