public static void FullyGrow(Organism organism)
    {
        int l = organism.orderOfGrowth.Count;

        for (int i = 0; i < l; i++)
        {
            GrowCell(organism, false);
        }
        OrganismHealthCheck.KillDeatachedCells(organism.cells);
    }
Ejemplo n.º 2
0
    private void Grow()
    {
        int number = (int)Math.Sqrt(cells.Count());

        for (int i = 0; i < number; i++)
        {//grow a number of cells based on the number that are already alive
            OrganismCellsGrowth.GrowCell(this, false);
        }

        OrganismHealthCheck.KillDeatachedCells(cells);
    }
Ejemplo n.º 3
0
    public void CellDied()
    {
        //All cells that get cut out from the center of the organism, die as well

        OrganismHealthCheck.KillDeatachedCells(cells);

        SetTotalEnergyStorage();
        if (!OrganismHealthCheck.AreValidCellsAlive(cells))
        {
            Die();
        }
    }
    public static void GrowCell(Organism organism, bool killDetached)
    {
        if (!organism.orderOfGrowth.Any())
        {
            return;
        }

        KeyValuePair <CellAttributes, CellAttributes> pair = organism.orderOfGrowth.First.Value;
        CellAttributes startingCell = pair.Key;
        CellAttributes cellToGrow   = pair.Value;

        int cellEnergy = cellToGrow.type.GetComponent <Cell>().bodyEnergy;

        if (organism.organismEnergy.EggEnergy + organism.organismEnergy.Value - cellEnergy < organism.bodyEnergy * organism.chromosome.Parameters.MinimumEnergyToGrow)
        {
            return;//no energy for growth
        }
        if (startingCell == null)
        {//first cell
            if (CellsCreator.CanInstantiate(cellToGrow, organism.transform))
            {
                GrowCell(cellToGrow, organism);
            }
        }
        else
        {
            if (startingCell.alive)
            {
                Vector3 direction = cellToGrow.relativePosition;

                cellToGrow.relativePosition += startingCell.relativePosition;

                if (!CellsCreator.CanInstantiate(cellToGrow, organism.transform))
                {
                    cellToGrow.relativePosition = direction;
                    return;
                }

                ShiftCells(cellToGrow.relativePosition, direction, organism);

                GrowCell(cellToGrow, organism);
            }
        }

        if (killDetached)
        {
            OrganismHealthCheck.KillDeatachedCells(organism.cells);
        }
    }
Ejemplo n.º 5
0
 public bool Alive()
 {
     return(OrganismHealthCheck.AreValidCellsAlive(cells));
 }