Exemple #1
0
 void Reload()
 {
     if ((R_gage.GetComponent <Image>().fillAmount += ReloadTime * Time.deltaTime) > 0.99f)
     {
         IsReload           = false;
         CurrentBulletCount = MaxOfBullet;
         R_gage.GetComponent <Image>().fillAmount = 0;
         B_gage.GetComponent <Image>().fillAmount = 1;
     }
     if (!Adsrc.GetComponent <AudioSource>().isPlaying)
     {
         Adsrc.clip = ReloadClip_2;
         Adsrc.Play();
     }
 }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        FPMove();
        FPRotate(tvRecoil, thRecoil);

        if (Input.GetKeyDown(KeyCode.B))
        {
            Adsrc.clip = ChangeMode;
            Adsrc.Play();
            if (IsAutoShoot)
            {
                IsAutoShoot = false;
                sMode.GetComponent <Text>().text = "Single";
            }
            else
            {
                IsAutoShoot = true;
                sMode.GetComponent <Text>().text = "Auto";
            }
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            if (IsReload)
            {
                IsReload = false;
                Adsrc.Stop();
                R_gage.GetComponent <Image>().fillAmount = 0;
            }
            else
            {
                Adsrc.clip = ReloadClip_1;
                Adsrc.Play();
                IsReload = true;
            }
        }
        if (IsReload)
        {
            Reload();
        }


        if (Input.GetMouseButtonDown(1))
        {
            if (IsZoom)
            {
                IsZoom = false; movementSpeed += 3f;
            }
            else
            {
                IsZoom = true; movementSpeed -= 3f;
            }
        }
        if (!IsAutoShoot && !IsReload && Input.GetMouseButtonDown(0))
        {
            Shooting();
        }
        if (IsAutoShoot && !IsReload && Input.GetMouseButton(0))
        {
            if ((AutoShootingSpeed_frame -= Time.deltaTime) <= 0)
            {
                Shooting();
                AutoShootingSpeed_frame = AutoShootingSpeed;
            }
        }

        if (--ShootingLight_frame == 0)
        {
            Gun_ShootingLight.GetComponent <Light>().intensity = 0;
        }
    }