Ejemplo n.º 1
0
        protected override void Hitscan()
        {
            // autoaim
            Vector3 aimedDir;

            Autoaim.Aim(AimTransform.position, AimTransform.forward, AimRadius, out aimedDir, Range, AutoaimLayerMask);

            float rangey = 1 - Accuracy;

            rangey *= MaxAngleY;

            float deltax = 2 * (1 - Accuracy) / pelletCount;
            float basex  = -(1 - Accuracy);

            if (HealthInt >= 3)
            {
                deltax *= MaxAngleX;
                basex  *= MaxAngleX;
            }
            else
            {
                deltax *= MaxAngleX / 3.0f;
                basex  *= MaxAngleX / 3.0f;
            }

            for (int i = 0; i < pelletCount; i++)
            {
                // process accuracy
                float rangexl = basex + deltax * i;
                float rangexr = basex + deltax * (i + 1);

                Vector3 distortedDir =
                    Quaternion.AngleAxis(Random.Range(rangexl, rangexr), AimTransform.up)
                    * Quaternion.AngleAxis(Random.Range(-rangey, rangey), AimTransform.right)
                    * aimedDir;

                CheckRay(AimTransform.position, distortedDir);

                //Vector3 end = CheckRay(AimTransform.position, distortedDir);

                //// emit trail, if muzzle flash transform exists
                //if (MuzzleFlash != null)
                //{
                //    EmitTrail(MuzzleFlash.position, end);
                //}
            }
        }
Ejemplo n.º 2
0
        void SpawnMissile()
        {
            // reset spawn transform's rotation,
            // set max speed
            missileSpawn.rotation          = Owner.transform.rotation;
            missileSpawn.localEulerAngles += spawnStartEuler;

            float speed = launchSpeed;

            Transform target = null;

            if (!onlyForward)
            {
                // find target
                target = Autoaim.GetTarget(missileSpawn.position + Owner.transform.forward * AutoaimThreshold,
                                           Owner.transform.forward, AutoaimRadius, AutoaimRange, AutoaimLayerMask);
            }

            if (target != null)
            {
                // target found
                Vector3 targetPos = target.position;

                if (calculateTrajectory)
                {
                    // rotate spawn transform and get missile speed for aiming
                    Autoaim.AimMissile(missileSpawn, targetPos, launchSpeed, out speed);
                }
                else
                {
                    // just rotate
                    missileSpawn.forward = targetPos - missileSpawn.position;
                }
            }
            // if cant find target, so launch at max speed
            // in default direction

            GameObject missileObj = ObjectPool.Instance.GetObject(Data.MissileName, missileSpawn.position, missileSpawn.rotation);

            Missile missile = missileObj.GetComponent <Missile>();

            missile.Set(DamageValue, Owner);
            missile.Launch(speed);
        }
Ejemplo n.º 3
0
        protected override void Hitscan()
        {
            // autoaim
            Autoaim.Aim(AimTransform.position, AimTransform.forward, AimRadius, out Vector3 aimedDir, Range, AutoaimLayerMask);

            // process accuracy
            float rangex = (1 - Accuracy) * MaxAngleX;
            float rangey = (1 - Accuracy) * MaxAngleY;

            Vector3 distortedDir = HealthInt >= 3 ?
                                   Quaternion.AngleAxis(Random.Range(-rangex, rangex), AimTransform.up)
                                   * Quaternion.AngleAxis(Random.Range(-rangey, rangey), AimTransform.right)
                                   * aimedDir :
                                   aimedDir;

            Vector3 end = CheckRay(AimTransform.position, distortedDir);

            // emit trail, if muzzle flash transform exists
            if (MuzzleFlash != null)
            {
                EmitTrail(MuzzleFlash.position, distortedDir, end);
            }
        }