Example #1
0
    public HitboxDoT CreateHitboxDoT(Vector2 hitboxScale, Vector2 offset, float damage, float stun, float hitboxDuration, Vector2 knockback, bool fixedKnockback = true,
                                     bool followObj = true, ElementType element = ElementType.PHYSICAL)
    {
        Vector2 cOff   = (m_physics == null) ? offset : m_physics.OrientVectorToDirection(offset);
        Vector3 newPos = transform.position + (Vector3)cOff;
        var     go     = GameObject.Instantiate(HitboxList.Instance.HitboxDoT, newPos, Quaternion.identity);

        HitboxDoT newBox = go.GetComponent <HitboxDoT>();

        if (followObj)
        {
            go.transform.SetParent(gameObject.transform);
            Vector2 ls = new Vector2(hitboxScale.x / transform.localScale.x, hitboxScale.y / transform.localScale.y);
            newBox.transform.localScale = (m_physics == null) ?  ls : m_physics.OrientVectorToDirection(ls, false);
        }
        else
        {
            newBox.SetScale((m_physics == null) ? hitboxScale : m_physics.OrientVectorToDirection(hitboxScale, false));
        }
        newBox.Damage           = damage;
        newBox.Duration         = hitboxDuration;
        newBox.Knockback        = (m_physics == null) ? knockback : m_physics.OrientVectorToDirection(knockback);
        newBox.IsFixedKnockback = fixedKnockback;
        newBox.Stun             = stun;
        newBox.AddElement(element);
        newBox.Creator = gameObject;
        newBox.Faction = Faction;

        ExecuteEvents.Execute <ICustomMessageTarget> (gameObject, null, (x, y) => x.OnHitboxCreate(newBox));
        newBox.Init();
        return(newBox);
    }
Example #2
0
    void TakeDoT(HitboxDoT hbdot)
    {
        Resistence r = GetAverageResistences(hbdot.Element);
        float      d = hbdot.Damage - (hbdot.Damage * (r.Percentage / 100f));

        DamageObj(d * ScaledTime.deltaTime);
        if (Health <= 0f)
        {
            Killer = hbdot.Creator;
        }
        if (hbdot.IsFixedKnockback)
        {
            Vector2 kb = hbdot.Knockback - (hbdot.Knockback * Mathf.Min(1f, (r.KnockbackResist / 100f)));
            if (GetComponent <BasicPhysics>() != null)
            {
                GetComponent <BasicPhysics>().AddToVelocity(kb * ScaledTime.deltaTime);
            }
        }
        else
        {
            Vector3 otherPos  = gameObject.transform.position;
            float   angle     = Mathf.Atan2(transform.position.y - otherPos.y, transform.position.x - otherPos.x); //*180.0f / Mathf.PI;
            float   magnitude = hbdot.Knockback.magnitude;
            float   forceX    = Mathf.Cos(angle) * magnitude;
            float   forceY    = Mathf.Sin(angle) * magnitude;
            Vector2 force     = new Vector2(-forceX, -forceY);
            if (GetComponent <BasicPhysics>() != null)
            {
                GetComponent <BasicPhysics>().AddToVelocity(force * ScaledTime.deltaTime);
            }
        }
    }
Example #3
0
 public override void OnHit(Hitbox hb, GameObject attacker)
 {
     if (!GetComponent <PropertyHolder> ().HasProperty("Flaming"))
     {
         //Debug.Log ("Does not have flaming");
         if (hb.HasElement(ElementType.FIRE))
         {
             //Debug.Log ("has flaming");
             HitboxDoT hd = hb as HitboxDoT;
             if (hd != null)
             {
                 m_flameDamage += (Time.deltaTime * hb.Damage);
             }
             else
             {
                 m_flameDamage += hb.Damage;
             }
             if (m_flameDamage >= FLAME_THREASHOLD)
             {
                 GetComponent <PropertyHolder> ().AddProperty("PR_Flaming");
                 m_flameDamage = 0f;
             }
         }
     }
 }
Example #4
0
 protected override void OnActive()
 {
     dotBox    = GetComponent <HitboxMaker>().CreateHitboxDoT(scl, off, dmg, stun, hd, kb, true, true, ElementType.PHYSICAL);
     launchBox = GetComponent <HitboxMaker>().CreateHitboxMulti(scl2, off2, dmg, stun, hd, kb2, true, true, ElementType.PHYSICAL);
     fx        = GetComponent <PropertyHolder> ().AddBodyEffect(FXBody.Instance.FXFan);
     GetComponent <PropertyHolder> ().AddAmbient(FXBody.Instance.SFXFan);
 }
Example #5
0
    protected override void OnActive()
    {
        fireOnly = new List <ElementType> ();
        fireOnly.Add(ElementType.FIRE);

        dotBox = GetComponent <HitboxMaker>().CreateHitboxDoT(scl, off, dmg, stun, hd, kb, true, true, ElementType.FIRE);

        fx = GetComponent <PropertyHolder> ().AddBodyEffect(FXBody.Instance.FXBurner);
        GetComponent <PropertyHolder> ().AddAmbient(FXBody.Instance.SFXFlaming);
    }
Example #6
0
    public HitResult TakeHit(HitInfo hi)
    {
        ExecuteEvents.Execute <ICustomMessageTarget> (gameObject, null, (x, y) => x.OnHit(hi, hi.Creator));
        HitboxDoT hd = hi.mHitbox as HitboxDoT;

        if (hd != null)
        {
            TakeDoT(hd);
            return(HitResult.NONE);
        }
        if (GetComponent <AIBase>())
        {
            GetComponent <AIBase> ().OnHit(hi);
        }
        Resistence r = GetAverageResistences(hi.Element);
        float      d;

        //Debug.Log ("Damage; " + hi.Damage + " r: " + r.Percentage);
        d = hi.Damage - (hi.Damage * (r.Percentage / 100f));
        float fD = hi.FocusDamage;

        d = DamageObj(d);

        ApplyHitToPhysicsSS(hi);
        float s = hi.Stun - (hi.Stun * Mathf.Min(1f, (r.StunResist / 100f)));

        if (hi.Stun > 0f && m_fighter)
        {
            if (s <= 0f)
            {
                return(HitResult.BLOCKED);
            }
            m_fighter.RegisterStun(s, true, hi, (d >= 0f && fD >= 0f));
        }
        if (Health <= 0f)
        {
            Killer = hi.Creator;
        }
        if (d == 0f && fD == 0f)
        {
            return(HitResult.NONE);
        }
        else if (d < 0f)
        {
            return(HitResult.HIT);
        }
        else if (fD >= 0f)
        {
            return(HitResult.FOCUSHIT);
        }
        else
        {
            return(HitResult.HEAL);
        }
    }
Example #7
0
    public override void OnAddProperty()
    {
        Vector3 sc = GetComponent <PropertyHolder> ().BodyScale();

        sc          *= 1.2f;
        fireSurround = GetComponent <HitboxMaker>().CreateHitboxDoT(sc, off, dmg, stun, hd, kb, false, true, ElementType.FIRE);
        fireSurround.GetComponent <Hitbox> ().Faction = FactionType.HOSTILE;
        fx       = GetComponent <PropertyHolder> ().AddBodyEffect(FXBody.Instance.FXFlame);
        fireOnly = new List <ElementType> ();
        fireOnly.Add(ElementType.FIRE);
        GetComponent <PropertyHolder> ().AddAmbient(FXBody.Instance.SFXFlaming);
    }
Example #8
0
    public HitResult TakeHit(Hitbox hb)
    {
        ExecuteEvents.Execute <ICustomMessageTarget> (gameObject, null, (x, y) => x.OnHit(hb, hb.Creator));
        HitboxDoT hd = hb as HitboxDoT;

        if (hd != null)
        {
            TakeDoT(hd);
            return(HitResult.NONE);
        }
        if (GetComponent <AIFighter>())
        {
            GetComponent <AIFighter> ().OnHit(hb);
        }
        Resistence r = GetAverageResistences(hb.Element);
        float      d;

        d = hb.Damage - (hb.Damage * (r.Percentage / 100f));
        d = DamageObj(d);

        ApplyHitToPhysicsSS(hb);
        float s = hb.Stun - (hb.Stun * Mathf.Min(1f, (r.StunResist / 100f)));

        if (hb.Stun > 0f && m_fighter)
        {
            if (s <= 0f)
            {
                return(HitResult.BLOCKED);
            }
            m_fighter.RegisterStun(s, true, hb);
        }
        if (Health <= 0f)
        {
            Killer = hb.Creator;
        }
        if (d == 0f)
        {
            return(HitResult.NONE);
        }
        else if (d < 0f)
        {
            return(HitResult.HIT);
        }
        else
        {
            return(HitResult.HEAL);
        }
    }
Example #9
0
 public override void OnHit(Hitbox hb, GameObject attacker)
 {
     if (!GetComponent <PropertyHolder> ().HasProperty("Parasite"))
     {
         if (hb.HasElement(ElementType.BIOLOGICAL))
         {
             HitboxDoT hd = hb as HitboxDoT;
             if (hd != null)
             {
                 m_bioDamage += (Time.deltaTime * hb.Damage);
             }
             else
             {
                 m_bioDamage += hb.Damage;
             }
             if (m_bioDamage >= BIO_THREASHOLD)
             {
                 GetComponent <PropertyHolder> ().AddProperty("PR_Poison");
                 m_bioDamage = 0f;
             }
         }
     }
 }