示例#1
0
    protected override void DamageTarget(Base_Health otherHealth)
    {
        if (!canDamage)
        {
            return;
        }
        //DAMAGE
        float maxDist = collider.radius * transform.localScale.x;
        float dist    = Vector3.Distance(transform.position, otherHealth.transform.position);
        float value   = (maxDist - dist) / maxDist;

        if (value <= 0f)
        {
            return;
        }
        {
            Rigidbody2D otherBody = otherHealth.GetComponent <Rigidbody2D> ();

            Vector2 diff = (maxDist - dist / maxDist) * (damage * (otherBody.position - mBody.position).normalized) * .25f;
            otherBody.AddForce(diff, ForceMode2D.Impulse);
        }

        int _id = id;

        if (otherHealth.GetPlayerTag().Id == id)
        {
            _id = -1;
        }

        otherHealth.TakeDamage(damage * (value), _id, team);
        excludeObjects.Add(otherHealth.gameObject);
    }
示例#2
0
    public override void OnTriggerEnter2D(Collider2D other)
    {
        //RETURN CONDITIONS
        if (other.tag == "Wall")
        {
            if (deathParticlePrefab != null)
            {
                Instantiate(deathParticlePrefab, transform.position, Quaternion.identity);
            }
            if (destroyOnHit)
            {
                Destroy(gameObject);
                return;
            }
            return;
        }
        Base_Health otherHealth = other.GetComponent <Base_Health> ();

        if (otherHealth == null || otherHealth.GetPlayerTag().Id == id || (otherHealth.GetPlayerTag().Team != 0 && otherHealth.GetPlayerTag().Team == team))
        {
            return;
        }

        if (canStun)
        {
            otherHealth.AddStun();
        }

        otherHealth.GetComponent <Base_Movement> ().AddSlow(slowAmount);
        DamageTarget(otherHealth);
        // ELSE CASE??
    }