Esempio n. 1
0
    protected virtual void FireOnce()
    {
        Vector3 start = userCommunicator.LookStartPos();
        Vector3 end;

        bool hitHealthComponent = false;

        Vector3 direction = Quaternion.Euler(InaccuracyOffset()) * userCommunicator.LookDirection();

        RaycastHit hitInfo;

        if (Physics.Raycast(start, direction, out hitInfo, range, layermask))   //Hits something
        {
            end = hitInfo.point;
            IHealth health = hitInfo.collider.GetComponent <IHealth>();
            Debug.Log(hitInfo.collider);
            if (health != null)
            {
                hitHealthComponent = true;
                health.Damage(damage);
            }
        }
        else
        {
            end = NagaUtils.GetPointAlongDirection(start, direction, range);
        }

        Debug.DrawLine(start, end, Color.white, 0.4f);

        onHitscanShoot.Invoke((new ShootInfo[] { new ShootInfo(start, end, hitInfo, hitHealthComponent) }));
    }
Esempio n. 2
0
    public override void CreateTrail(ShootInfo shootInfo)
    {
        Vector3 start = weaponFirepos.GetWeaponFirePos();
        Vector3 end   = shootInfo.end;

        start = NagaUtils.GetPointAlongDirection(start, end - start, Random.value * startposRandomness);

        TrailRenderer trail = GenericObjectPooler.RequestObject(trailRenderer).gameObject.GetComponent <TrailRenderer>();

        trail.gameObject.transform.position = start;
        trail.gameObject.SetActive(true);

        trail.Clear();

        Timing.RunCoroutine(_TweenTrail(trail, end));
    }