Exemple #1
0
    public void InitFromLineInfo(HitScanInfo hsi, GameObject parent, FactionHolder fh = null)
    {
        float deg = Mathf.Deg2Rad * parent.transform.rotation.eulerAngles.y;

        aimPoint = Orientation.OrientToVectorZ(hsi.AimDirection, deg);
        if (hsi.FollowCharacter)
        {
            transform.SetParent(parent.transform);
            transform.localPosition = hsi.CreatePos;
            transform.localRotation = Quaternion.identity;
        }
        else
        {
            transform.position += Orientation.OrientToVectorZ(hsi.CreatePos, deg);
        }
        setRange(hsi.MaxRange);
        Damage = hsi.Damage;
        setAimPoint(aimPoint);
        Duration            = hsi.HitboxDuration;
        Knockback           = Orientation.OrientToVectorZ(hsi.Knockback, deg);
        IsFixedKnockback    = true;
        CanPenetrateWall    = hsi.CanPenetrateWall;
        Creator             = parent;
        EnemiesCanPenetrate = hsi.PenetrativePower;
        if (fh != null)
        {
            fh.SetFaction(gameObject);
        }
        hitCallback = hsi.hitCallback;
        AddElement(hsi.Element);
        Stun = hsi.Stun;
        Init();
    }
Exemple #2
0
    public LineHitbox createLineHB(HitScanInfo hsi)
    {
        if (ListHitboxes.Instance == null)
        {
            Debug.LogWarning("LIstHitboxes not found. Please add a Gameobject with the ListHItboxes prefab");
            return(null);
        }
        var go = GameObject.Instantiate(ListHitboxes.Instance.HitboxLine, transform.position, Quaternion.identity);

        hsi.hitCallback.Add(RegisterHit);
        LineHitbox lh = go.GetComponent <LineHitbox>();

        lh.InitFromLineInfo(hsi, gameObject, GetComponent <FactionHolder>());
        return(lh);
    }
Exemple #3
0
 private void createProjectile(GameObject prefab, Vector3 origin, Vector3 targetPoint, float delay = 0.0f)
 {
     if (prefab == null)
     {
         HitScanInfo hsi = new HitScanInfo();
         hsi.CreatePos        = origin;
         hsi.AimDirection     = targetPoint;
         hsi.PenetrativePower = m_weaponStats.pierce;
         hsi.Damage           = m_weaponStats.damage;
         hsi.Stun             = m_weaponStats.stun;
         hsi.MaxRange         = m_weaponStats.hitScanRange;
         hsi.HitboxDuration   = m_weaponStats.duration;
         hsi.Knockback        = new Vector3(10f * m_weaponStats.knockbackMult, 0f);
         hsi.MyNoiseType      = m_weaponStats.noiseType;
         hsi.NoiseRange       = m_weaponStats.noiseRange;
         m_hitboxMaker.createLineHB(hsi);
     }
     else
     {
         ProjectileInfo pi = new ProjectileInfo();
         pi.Projectile             = prefab;
         pi.ProjectileCreatePos    = origin;
         pi.ProjectileAimDirection = targetPoint;
         pi.ProjectileSpeed        = m_weaponStats.speed;
         pi.PenetrativePower       = m_weaponStats.pierce;
         pi.Damage         = m_weaponStats.damage;
         pi.Stun           = m_weaponStats.stun;
         pi.HitboxDuration = m_weaponStats.duration;
         pi.Knockback      = new Vector3(10f * m_weaponStats.knockbackMult, 0f);
         pi.MyNoiseType    = m_weaponStats.noiseType;
         pi.NoiseRange     = m_weaponStats.noiseRange;
         if (delay == 0f)
         {
             m_hitboxMaker.CreateProjectile(pi);
         }
         else
         {
             m_hitboxMaker.QueueProjectile(pi, delay);
         }
     }
 }