Exemplo n.º 1
0
 override public void Shoot(GameObject projectile, Vector3 projectileSpawnPoint, float force)
 {
     if (canShoot)
     {
         StartCoroutine(animShoot());
         projectile = ObjectPool.Instance.GetObjectForType(projectile.name, false);
         projectile.transform.position = projectileSpawnPoint;
         projectile.transform.rotation = FrontSight.rotation;
         Projectile_ForwardAndParabole p = projectile.GetComponent <Projectile_ForwardAndParabole> ();
         p.speed   = force;
         p.shooter = shooter;
     }
 }
Exemplo n.º 2
0
 override public void Shoot(GameObject projectile, Vector3 projectileSpawnPoint, float force)
 {
     if (canShoot)
     {
         StartCoroutine(animShoot());
         Aim(transform.forward + transform.position);
         projectile = ObjectPool.Instance.GetObjectForType(projectile.name, false);
         projectile.transform.position = projectileSpawnPoint;
         projectile.transform.rotation = Quaternion.LookRotation(aimDirection, FrontSight.up);
         Projectile_ForwardAndParabole flyProjectile = projectile.GetComponent <Projectile_ForwardAndParabole> ();
         flyProjectile.shooter     = shooter;
         flyProjectile.speed       = force;
         flyProjectile.maxLifeTime = Range / force;
         //to jest niezbędne, żeby automatyczne ograniczenie czasu życia działało od pierwszej iteracji
         flyProjectile.enabled = false;
         flyProjectile.enabled = true;
     }
 }
Exemplo n.º 3
0
    public void Aim()
    {
        Quaternion targetRotation = Quaternion.LookRotation(diff) * Quaternion.Euler(offset);
        float      deltaAngle     = Quaternion.Angle(targetRotation, neck[neck.Count - 1].parent.rotation) / neck.Count;

        for (int i = neck.Count - 1; i >= 0; i--)
        {
            neck [i].rotation = Quaternion.RotateTowards(neck[i].parent.rotation, targetRotation, deltaAngle);
        }
        if (canShoot)
        {
            GameObject projectile = ObjectPool.Instance.GetObjectForType(projectilePref.name, false);
            projectile.transform.position = FirePoint.position;
            projectile.transform.rotation = FirePoint.rotation;
            Projectile_ForwardAndParabole flyProjectile = projectile.GetComponent <Projectile_ForwardAndParabole> ();
            flyProjectile.maxLifeTime = (averageDist + 5) / flyProjectile.speed;
            //to jest niezbędne, żeby automatyczne ograniczenie czasu życia działało od pierwszej iteracji
            flyProjectile.enabled = false;
            flyProjectile.enabled = true;
            StartCoroutine(waitAgain());
            //neck [0].rotation = targetRotation;
        }
    }