Пример #1
0
    void Evaporate()
    {
        float amount = 0.001f;

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                WorldPoint point     = map[x, y];
                float      addAmount = -Mathf.Min(point.water, amount);
                if (point.water > point.surfaceWaterHeight)
                {
                    point.AddWater(addAmount);
                }
                else
                {
                    point.AddWater(addAmount / 5);
                }
            }
        }
    }
Пример #2
0
    void Grow()
    {
        //absorb water
        if (point.water > waterAbsorption)
        {
            point.AddWater(-waterAbsorption);
            energy += waterAbsorption;
        }

        //photosynthesize
        if (point.light > lightNeeds)
        {
            energy += lightAbsorption;
        }

        //grow
        if (energy > energyUse)
        {
            energy -= energyUse;
            size   += growthRate;
            if (size > maxSize)
            {
                size = maxSize;
            }
            targetScale = Vector3.one * size;

            //recalculate needs and energy use
            energyUse  = initialEnergyUse + (size / growthNeedsAjust);
            lightNeeds = initialLightNeeds + (size / growthNeedsAjust);

            //change light blocking
            numTilesBlocked = Mathf.RoundToInt(size);
        }
        else
        {
            Die();
        }
    }