示例#1
0
 /*
  * =====================================
  *      Calculate the propability that a
  *      turbine can get damaged
  * =====================================
  */
 void CalculateDamagePropability()
 {
     if (simulator.minutesCount >= damageStartTime && turbine.IsRotating() == true && turbine.IsDamaged() == false &&
         TurbineController.damagedTurbines <= 4)
     {
         propabilityMultiplier = Random.Range(0.0f, 1.0f);
         turbineUsage          = 0.0f;
         if (string.Compare(simulator.powerUsage, "-Over power") == 0)
         {
             turbineUsage = 1.3f;
         }
         else if (string.Compare(simulator.powerUsage, "-Correct power") == 0)
         {
             turbineUsage = 1.0f;
         }
         else
         {
             turbineUsage = 0.0f;
         }
         float damagePropability = turbineUsage * propabilityMultiplier;
         if (damagePropability > 0.85)
         {
             damageTurbine();
         }
     }
 }
 //when user clicks the turbine.
 void OnMouseDown()
 {
     //clicks while turbine is rotating.
     if (turbine.IsRotating() == true && turbine.IsDamaged() == false)
     {
         turbine.DisableTurbine();
         GoedleAnalytics.track("disable.turbine");
     }
     //clicks while is not rotating.
     else if (turbine.IsRotating() == false && turbine.IsDamaged() == false)
     {
         turbine.EnableTurbine();
         GoedleAnalytics.track("enable.turbine");
     }
     //clicks while turbine is damaged.
     else if (turbine.IsDamaged() == true)
     {
         turbine.repairTurbine();
         GoedleAnalytics.track("repair.turbine");
     }
 }
 //when user clicks the turbine.
 void OnMouseDown()
 {
     //clicks while turbine is rotating.
     if (turbine.IsRotating() == true && turbine.IsDamaged() == false)
     {
         turbine.DisableTurbine();
         GoedleAnalytics.instance.track("disable.turbine");
         SoundManager.instance.PlaySound(turnOff);
     }
     //clicks while is not rotating.
     else if (turbine.IsRotating() == false && turbine.IsDamaged() == false)
     {
         turbine.EnableTurbine();
         GoedleAnalytics.instance.track("enable.turbine");
         SoundManager.instance.PlaySound(turnOn);
     }
     //clicks while turbine is damaged.
     else if (turbine.IsDamaged() == true)
     {
         turbine.RepairTurbine();
         GoedleAnalytics.instance.track("repair.turbine");
         SoundManager.instance.PlaySound(repair);
     }
 }