Exemplo n.º 1
0
    public Hitbox CreateHitbox(Vector2 hitboxScale, Vector2 offset, float damage, float stun, float hitboxDuration, Vector2 knockback, bool fixedKnockback, bool followObj)
    {
        Vector2 cOff   = m_physics.OrientVectorToDirection(offset);
        Vector3 newPos = transform.position + (Vector3)cOff;
        var     go     = GameObject.Instantiate(hitboxClass, newPos, Quaternion.identity);

        go.transform.SetParent(gameObject.transform);

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

        newBox.SetScale(m_physics.OrientScaleToDirection(hitboxScale));
        newBox.Damage           = damage;
        newBox.Duration         = hitboxDuration;
        newBox.Knockback        = m_physics.OrientVectorToDirection(knockback);
        newBox.IsFixedKnockback = fixedKnockback;
        newBox.Stun             = stun;
        newBox.HitTypes         = hitTypes;
        newBox.Creator          = gameObject;
        if (followObj)
        {
            newBox.SetFollow(gameObject, offset);
        }

        newBox.Init();
        return(newBox);
    }
Exemplo n.º 2
0
    public Hitbox createHitbox(Vector2 hitboxScale, Vector2 offset, float damage, float stun, float hitboxDuration, Vector2 knockback, bool fixedKnockback, string faction, bool followObj)
    {
        Vector2    cOff   = m_physics.OrientVectorToDirection(offset);
        Vector3    newPos = transform.position + new Vector3(cOff.x, cOff.y, 0f);
        GameObject go     = Instantiate(hitboxClass, newPos, Quaternion.identity) as GameObject;
        Hitbox     newBox = go.GetComponent <Hitbox> ();

        newBox.setScale(m_physics.OrientScaleToDirection(hitboxScale));
        newBox.setDamage(damage);
        newBox.setHitboxDuration(hitboxDuration);
        newBox.setKnockback(m_physics.OrientVectorToDirection(knockback));
        newBox.setFixedKnockback(fixedKnockback);
        newBox.setFaction(faction);
        newBox.stun    = stun;
        newBox.creator = gameObject;
        newBox.mAttr   = mAttrs;
        if (followObj)
        {
            newBox.setFollow(gameObject, offset);
        }
        return(newBox);
    }