Exemplo n.º 1
0
    public int Extract(Nutrients nutrient, int energy)
    {
        MediaNutrient mediaNutrient = GetNutrient(nutrient);

        if (mediaNutrient == null)
        {
            Debug.LogError(nutrient + " does not exist");
            return(0);
        }
        int extraction = GetExtractionVolume(mediaNutrient, energy);

        Debug.Log("Extractin " + extraction);
        return(mediaNutrient.Extract(extraction));
    }
Exemplo n.º 2
0
    void MakeWaste()
    {
        MediaNutrient C = GetNutrient(Nutrients.C);

        data.waste += C.Extract(C.CurrentValue / 4);

        MediaNutrient N = GetNutrient(Nutrients.N);

        data.waste += N.Extract(C.CurrentValue / 3);

        MediaNutrient AA = GetNutrient(Nutrients.AA);

        data.waste += AA.Extract(AA.CurrentValue / 2);
    }
Exemplo n.º 3
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);
            }
        }
    }
Exemplo n.º 4
0
    void CreateEnergy()
    {
        MediaNutrient C       = GetNutrient(Nutrients.C, true);
        MediaNutrient N       = GetNutrient(Nutrients.N, true);
        MediaNutrient AA      = GetNutrient(Nutrients.AA, true);
        int           cFactor = 5;
        int           nFactor = 2;
        int           aFactor = 1;

        int production = Mathf.Min(
            C.CurrentValue / cFactor,
            N.CurrentValue / nFactor,
            AA.CurrentValue / aFactor);

        C.Extract(production * cFactor);
        N.Extract(production * nFactor);
        AA.Extract(production * aFactor);

        data.energy += production * 10;
    }