Пример #1
0
        IEnumerator GenerateEnergyRoutine(UnitTower unit)
        {
            if (!unit.electricityFacility)
            {
                yield return(null);
            }

            while (unit != null)
            {
                float realRegenRate = unit.GetElectricityRegenerationRate() / 100;

                if (unit.platform.gameObject.tag == "Ocean")
                {
                    realRegenRate = realRegenRate * 2.0f; // magic numbers TODO -> create parameters for them
                }
                else if (unit.platform.gameObject.tag == "Hill")
                {
                    realRegenRate = realRegenRate * 3.0f;
                }

                if (unit.electricityCurrentlyStored + realRegenRate < unit.GetMaxElectricity())
                {
                    unit.electricityCurrentlyStored += realRegenRate;
                }
                else
                {
                    unit.electricityCurrentlyStored = unit.GetMaxElectricity();
                }

                yield return(new WaitForSeconds(0.01f)); // 1/100
            }
        }
Пример #2
0
        IEnumerator GenerateEnergyRoutine(UnitTower unit)
        {
            if (!unit.electricityFacility)
            yield return null;

              while (unit != null)
              {
            float realRegenRate = unit.GetElectricityRegenerationRate() / 100;

            if (unit.platform.gameObject.tag == "Ocean")
              realRegenRate = realRegenRate * 2.0f;       // magic numbers TODO -> create parameters for them
            else if (unit.platform.gameObject.tag == "Hill")
              realRegenRate = realRegenRate * 3.0f;

            if (unit.electricityCurrentlyStored + realRegenRate < unit.GetMaxElectricity())
              unit.electricityCurrentlyStored += realRegenRate;
            else
              unit.electricityCurrentlyStored = unit.GetMaxElectricity();

            yield return new WaitForSeconds(0.01f); // 1/100
              }
        }