Beispiel #1
0
        /// <summary>
        /// Shoots ammo in the directions specified using this objects shooting pattern.
        /// </summary>
        /// <param name="direction">The direction to shoot in.</param>
        /// <returns>True if this object was able to fire, false otherwise.</returns>
        public void PrimaryShoot(Vector3 direction)
        {
            if (Time.time > nextFire)
            {
                nextFire    = Time.time + fireRate;
                currentAmmo = primaryAmmo;
                switch (pattern)
                {
                case 0:
                    ShootInPattern(0, direction);
                    break;

                case 1:
                    ShootInPattern(1, direction);
                    break;

                case 2:
                    ShootInPattern(2, direction);
                    break;

                case 3:
                    ShootInPattern(3, direction);
                    break;
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// For every direction in the array, fires a shootable object in that direction.
 /// </summary>
 /// <param name="directions"> The desired directions to shoot in</param>
 private void FireInDirections(Vector3[] directions)
 {
     for (int i = 0; i < directions.Length; i++)
     {
         Shootable temp = Instantiate(currentAmmo, gameObject.transform.position, new Quaternion(0, 0, 0, 0)) as Shootable;
         temp.transform.position = transform.position;
         temp.SetRange(range);
         temp.SetDirection(directions[i].normalized, true);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Shoots secondary ammo in the spcified direction using this object's shooting pattern.
 /// </summary>
 /// <param name="direction">The direction to shoot in.</param>
 /// <returns>True if the shot was successful, false otherwise.</returns>
 public bool SecondaryShoot(Vector3 direction)
 {
     if (Time.time > nextFire + secondaryDelay)
     {
         nextFire    = Time.time + fireRate;
         currentAmmo = secondaryAmmo;
         ShootInPattern(0, direction);
         return(true);
     }
     else
     {
         return(false);
     }
 }