Exemplo n.º 1
0
 public void Fire(int localScaleFlipFactor)
 {
     if (!NormalShotOnCD() && gameObject.activeSelf && bullets > 0 && !Reloading())
     {
         normalShotTimer = normalShotCD;
         GameObject       shot    = Instantiate(laserShot);
         ProjectileScript pScript = shot.GetComponent <ProjectileScript>();
         pScript.hitRate = hitRate;
         if (Random.value <= critRate)
         {
             pScript.damage = NormalDistribution.CalculateNormalDistRandom(damage * 2, deviation * 2);
             pScript.isCrit = true;
         }
         else
         {
             pScript.damage = NormalDistribution.CalculateNormalDistRandom(damage, deviation);
         }
         ApplyUpgrades(pScript);
         shot.transform.position = transform.position + new Vector3(0.0001f * localScaleFlipFactor - localScaleFlipFactor * 0.3f, 0, 0);
         pScript.SetFlipFactor(localScaleFlipFactor);
         bullets--;
         if (bullets == 0)
         {
             Reload();
         }
     }
 }
Exemplo n.º 2
0
 public void ChargedFire(int localScaleFlipFactor)
 {
     if (!ChargedShotOnCD() && gameObject.activeSelf && !Reloading())
     {
         chargedShotTimer = chargedShotCD;
         GameObject       shot    = Instantiate(laserChargedShot);
         ProjectileScript pScript = shot.GetComponent <ProjectileScript>();
         // Aca se podría hacer que en vez de que el chargedShot sea siempre x4, tenga una variable que se puede tocar desde el inspector de unity.
         pScript.hitRate = hitRate;
         if (Random.value <= critRate)
         {
             pScript.damage = NormalDistribution.CalculateNormalDistRandom(damage * 4, deviation * 4);
             pScript.isCrit = true;
         }
         else
         {
             pScript.damage = NormalDistribution.CalculateNormalDistRandom(damage * 4, deviation * 4);
         }
         ApplyUpgrades(pScript);
         shot.transform.position = transform.position + new Vector3(0.0001f * localScaleFlipFactor - localScaleFlipFactor * 0.01f, 0, 0);
         pScript.SetFlipFactor(localScaleFlipFactor);
     }
 }