internal override void Action(Organism organism, ThisWorld thisWorld, StorageForElements storageForElements) { var options = new Specification(); var element = thisWorld.CheckField(organism.State.Cell, _x, _y); if (element == null) { var cell = thisWorld.GetCell(organism.State.Cell.Point.X / options.SizeCell + _x, organism.State.Cell.Point.Y / options.SizeCell + _y); cell.Element = organism; organism.State.Cell.Element = null; organism.State.Cell = thisWorld.GetCell(organism.State.Cell.Point.X / options.SizeCell + _x, organism.State.Cell.Point.Y / options.SizeCell + _y); } organism.Defense = false; organism.Scout = false; }
internal override void Action(Organism organism, ThisWorld thisWorld, StorageForElements storageForElements) { organism.Defense = false; if (organism.Scout) { organism.Scout = false; HelpAction(organism, thisWorld, -1, 0, storageForElements); HelpAction(organism, thisWorld, 1, 0, storageForElements); HelpAction(organism, thisWorld, 0, -1, storageForElements); HelpAction(organism, thisWorld, 0, 1, storageForElements); } else { HelpAction(organism, thisWorld, _x, _y, storageForElements); } }
internal abstract void Action(Organism organism, ThisWorld thisWorld, StorageForElements storageForElements);
internal override void Action(Organism organism, ThisWorld thisWorld, StorageForElements storageForElements) { organism.Scout = true; organism.Defense = false; }
private void HelpAction(Organism organism, ThisWorld thisWorld, int x, int y, StorageForElements storageForElements) { var options = new Specification(); var element = thisWorld.CheckField(organism.State.Cell, x, y); if (element != null) { if (element.GetType() == typeof(Eat)) { organism.State.UpLifeFromEat(); } if (element.GetType() == typeof(Organism)) { var bufOrganism = (Organism)element; if (bufOrganism.Defense) { thisWorld.DeleteElement(organism); return; } organism.State.UpLifeFromOrganism(); } thisWorld.DeleteElement(element); } }