Example #1
0
 // Update is called once per frame
 void Update()
 {
     if (check.allowShooting)
     {
         count += Input.GetAxisRaw("Mouse ScrollWheel") * 10;
         if (count >= 0.5f)
         {
             active += 1;
             count   = 0;
             ui.Check();
         }
         if (count <= -0.5f)
         {
             active -= 1;
             count   = 0;
             ui.Check();
         }
         if (active == -1)
         {
             active = check.weaponAmount;
             ui.Check();
         }
         if (active == check.weaponAmount + 1)
         {
             active = 0;
             ui.Check();
         }
         //CrystalStorm
         if (active == check.crystalStormSlot)
         {
             if (Input.GetAxisRaw("Fire") == 1)
             {
                 if (energyScript.energy >= stormEnergy)
                 {
                     stormFireSpeed += Time.deltaTime;
                     if (stormFireSpeed >= 0.1)
                     {
                         GameObject g = Instantiate(stormCrystal, transform.position, transform.rotation);
                         Destroy(g, 0.7f);
                         stormFireSpeed       = 0;
                         energyScript.energy -= stormEnergy;
                     }
                 }
             }
         }
         //FragGrenade
         if (active == check.fragSlot)
         {
             if (Input.GetAxisRaw("Fire") == 1)
             {
                 if (energyScript.energy >= explodeEnergy)
                 {
                     explosionSpeed += Time.deltaTime;
                     if (explosionSpeed >= 0.8f)
                     {
                         GameObject g = Instantiate(explodeCrystal, transform.position, transform.rotation);
                         Destroy(g, 8);
                         explosionSpeed       = 0;
                         energyScript.energy -= explodeEnergy;
                     }
                 }
             }
         }
         //Shotgun
         if (active == check.shotgunSlot)
         {
             if (shotgunAllowShoot == false)
             {
                 shotgunFireSpeed += Time.deltaTime;
             }
             if (Input.GetAxisRaw("Fire") == 1)
             {
                 if (energyScript.energy >= shotgunEnergy)
                 {
                     if (shotgunAllowShoot == true)
                     {
                         shotgunAllowShoot = false;
                         if (shotgunFireSpeed <= 0.02f)
                         {
                             GameObject s1 = Instantiate(shotgunShard, transform.position, transform.rotation);
                             Destroy(s1, 1);
                             GameObject s2 = Instantiate(shotgunShard, transform.position, transform.rotation);
                             Destroy(s2, 1);
                             GameObject s3 = Instantiate(shotgunShard, transform.position, transform.rotation);
                             Destroy(s3, 1);
                             GameObject s4 = Instantiate(shotgunShard, transform.position, transform.rotation);
                             Destroy(s4, 1);
                             GameObject s5 = Instantiate(shotgunShard, transform.position, transform.rotation);
                             Destroy(s5, 1);
                             GameObject s6 = Instantiate(shotgunShard, transform.position, transform.rotation);
                             Destroy(s6, 1);
                             energyScript.energy -= shotgunEnergy;
                         }
                     }
                 }
                 if (shotgunFireSpeed >= 0.8f)
                 {
                     shotgunFireSpeed  = 0;
                     shotgunAllowShoot = true;
                 }
             }
         }
         //SMG
         if (active == check.smgSlot)
         {
             if (Input.GetAxisRaw("Fire") == 1)
             {
                 if (energyScript.energy >= smgEnergy)
                 {
                     smgSpeed += Time.deltaTime;
                     if (smgSpeed >= 0.05f)
                     {
                         GameObject g = Instantiate(smgBullet, transform.position, transform.rotation);
                         Destroy(g, 3);
                         smgSpeed             = 0;
                         energyScript.energy -= smgEnergy;
                     }
                 }
             }
         }
         //Pistol
         if (active == 0)
         {
             if (Input.GetAxisRaw("Fire") == 1)
             {
                 pistolSpeed += Time.deltaTime;
                 if (pistolSpeed >= 0.3f)
                 {
                     if (energyScript.energy >= pistolEnergy)
                     {
                         GameObject g = Instantiate(pistolBullet, transform.position, transform.rotation);
                         Destroy(g, 3);
                         pistolSpeed          = 0;
                         energyScript.energy -= pistolEnergy;
                     }
                 }
             }
             if (Input.GetButtonDown("Fire1"))
             {
                 if (energyScript.energy >= pistolEnergy)
                 {
                     pistolShoot = true;
                     GameObject g = Instantiate(smgBullet, transform.position, transform.rotation);
                     Destroy(g, 3);
                     energyScript.energy -= pistolEnergy;
                 }
             }
             if (Input.GetButtonUp("Fire1"))
             {
                 pistolShoot = false;
                 pistolSpeed = 0;
             }
         }
         //Missle
         if (active == check.missleSlot)
         {
             if (Input.GetAxisRaw("Fire") == 1)
             {
                 if (energyScript.energy >= missleEnergy)
                 {
                     missleSpeed += Time.deltaTime;
                     if (missleSpeed >= 0.8f)
                     {
                         missleSpeed = 0;
                         GameObject g = Instantiate(missle, transform.position, transform.rotation);
                         Destroy(g, 8);
                         energyScript.energy -= missleEnergy;
                     }
                 }
             }
         }
     }
 }