Ejemplo n.º 1
0
    void ImportNutrient(MediaNutrient nutrient, ref int energy)
    {
        if (energy == 0)
        {
            return;
        }
        int extracted = tile.nutrientState.Extract(nutrient.nutrient, Mathf.RoundToInt(energy * (1 + data.populationSize / 80f)));
        int surplus;

        nutrient.Deposit(extracted, out surplus);
        tile.nutrientState.Deposit(nutrient.nutrient, surplus);
        Debug.Log(string.Format(
                      "Import of {0} using {1} energy, extracted {2} which when deposited caused {3} surplus",
                      nutrient, energy, extracted, surplus));
    }
Ejemplo n.º 2
0
    public void CauseDiffusion(NutrientState[] others)
    {
        int nNutrients = nutrients.Count;
        int nOthers    = others.Length;

        for (int i = 0; i < nNutrients; i++)
        {
            int own         = nutrients[i].Extract(diffusionFactor);
            int ownPerOther = own / 6;
            for (int j = 0; j < nOthers; j++)
            {
                MediaNutrient otherNutrient = others[j].GetNutrient(nutrients[i].nutrient);
                int           surplus       = 0;
                nutrients[i].Deposit(otherNutrient.Extract(diffusionFactor / 6), out surplus);
                otherNutrient.Deposit(ownPerOther + surplus, out surplus);
            }
        }
    }