Exemplo n.º 1
0
        void Update()
        {
            // Add the time since Update was last called to the timer.
            timer += Time.deltaTime;

#if !MOBILE_INPUT
            // If the Fire1 button is being press and it's time to fire...
            if (Input.GetButton("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0)
            {
                // ... shoot the gun.
                if (!BulletManager.Empty())
                {
                    timer = 0f;
                    foreach (var range_ in GunManager.current_gun.Shoot(transform.forward))
                    {
                        BulletManager.Shoot();
                        Instantiate(Bullet, transform.position, Quaternion.AngleAxis(range_, Vector3.up));
                    }

                    /*if (GunType.Ak47 == GunManager.current_gun.Shoot())
                     * {
                     *  BulletManager.Shoot();
                     *  Instantiate(Bullet, transform.position, transform.rotation);
                     * }
                     * else if (GunType.Minigun == GunManager.current_gun.Shoot())
                     * {
                     *  BulletManager.Shoot();
                     *  float angel1 = Vector3.Angle(right, transform.forward);
                     *  float angel2 = Vector3.Angle(forward, transform.forward);
                     *  if (angel1 > 90 || (angel1 == angel2 * 2))
                     *      angel2 *= -1;
                     *  Instantiate(
                     *      Bullet,
                     *      transform.position,
                     *      Quaternion.AngleAxis(Random.Range(-10f + angel2, 10f + angel2), transform.forward));
                     * }
                     * else if (GunType.Shotgun == GunManager.current_gun.Shoot()) {
                     *  BulletManager.Shoot(7);
                     *  float angel1 = Vector3.Angle(right, transform.forward);
                     *  float angel2 = Vector3.Angle(forward, transform.forward);
                     *  if (angel1 > 90 || (angel1 == angel2 * 2))
                     *      angel2 *= -1;
                     *  for (int i = 0; i < 7; i++) {
                     *      Instantiate(
                     *          Bullet,
                     *          transform.position,
                     *          Quaternion.AngleAxis(Random.Range(-30f + angel2, 30f + angel2), Vector3.up));
                     *  }
                     * }*/
                    //GunManager.current_gun.Shoot();
                }
            }

            if (Input.GetButton("Fire2"))
            {
                Invoke("Reload", 0.5f);
            }
            if (Input.GetKey(KeyCode.Alpha1))
            {
                GunManager.SetType(GunType.Ak47);
                UpdateValues();
            }
            if (Input.GetKey(KeyCode.Alpha2))
            {
                GunManager.SetType(GunType.Minigun);
                UpdateValues();
            }
            if (Input.GetKey(KeyCode.Alpha3))
            {
                GunManager.SetType(GunType.SimpleGun);
                UpdateValues();
            }
            if (Input.GetKey(KeyCode.Alpha4))
            {
                GunManager.SetType(GunType.Shotgun);
                UpdateValues();
            }
#else
            // If there is input on the shoot direction stick and it's time to fire...
            if ((CrossPlatformInputManager.GetAxisRaw("Mouse X") != 0 || CrossPlatformInputManager.GetAxisRaw("Mouse Y") != 0) && timer >= timeBetweenBullets)
            {
                // ... shoot the gun
                Shoot();
            }
#endif
            // If the timer has exceeded the proportion of timeBetweenBullets that the effects should be displayed for...
            if (timer >= timeBetweenBullets * effectsDisplayTime)
            {
                // ... disable the effects.
                DisableEffects();
            }
        }
Exemplo n.º 2
0
 void Reload()
 {
     BulletManager.Reload();
 }