示例#1
0
    /// <summary>
    /// Solve a contact between this feeder and param feeder then fire any applicable events.
    /// </summary>
    public void HandleContact(HitBoxFeeder feeder)
    {
        feeder.m_DidHit = true;
        var collision = feeder.Collider;

        //var force = Vector2.Lerp(feeder.m_ForceDirection.x, feeder.m_ForceDirection.y,
        //                            Random.Range(0f, 1f)) * Mathf.Lerp(feeder.m_Force.x, feeder.m_Force.y,
        //                            Random.Range(0f, 1f));
        //Flip force direction if the attack is also flipped.

        if (feeder.Owner.FlipX)
        {
            feeder.m_Force.x *= -1f;
        }

        //Estimate approximately where the intersection took place.
        var contactPoint = Collider.bounds.ClosestPoint(collision.bounds.center);
        var startY       = Mathf.Min(collision.bounds.center.y + collision.bounds.extents.y, Collider.bounds.center.y + (Collider.bounds.extents.y / 2f));
        var endY         = Mathf.Max(collision.bounds.center.y - collision.bounds.extents.y, Collider.bounds.center.y - (Collider.bounds.extents.y / 2f));

        contactPoint.y = Mathf.Lerp(startY, endY, Random.Range(0f, 1f));

        //Calculate force, velocity, direction, and damage.
        Owner.HitboxContact(
            new ContactData
        {
            MyHitbox    = this,
            TheirHitbox = feeder,
            Damage      = feeder.m_Damage,
            PoiseDamage = feeder.m_Strength,
            Force       = feeder.m_Force,
            Point       = contactPoint,
            RemainTime  = feeder.mRemainTime,
            State       = feeder.mState,
            //fxID = feeder.m_FXUID
        });
    }
示例#2
0
 public void AddContact(HitBoxFeeder a, HitBoxFeeder b)
 {
     mContackPairs.Add(new ContactPair {
         a = a, b = b
     });
 }