public override bool Grow() { bool hasGrown = false; foreach (ActionPattern actionPattern in actionPatterns) { if (MatchesPattern(actionPattern.GetPattern())) { if (actionPattern.action == Action.Die) { this.Kill(); return(hasGrown); } } } foreach (ActionPattern actionPattern in actionPatterns) { if (MatchesPattern(actionPattern.GetPattern())) { if (actionPattern.action == Action.Expand) { CellController cell = this.Grid.GetCellInDirection(this.X, this.Y, actionPattern.expandDirection); if (CanClaim(cell)) { cell.Claim(this); hasGrown = true; } } } } return(hasGrown); }
public override bool Grow() { bool hasGrown = false; CellController cellToClaim = GetNextEmptyNeighbour(); if (cellToClaim != null) { cellToClaim.Claim(this); hasGrown = true; } return(hasGrown); }
public override bool Grow() { bool hasGrown = false; foreach (GridDirection direction in GridDirectionHelpers.Horizontal) { CellController neighbour = this.Grid.GetCellInDirection(this.X, this.Y, direction); if (CanClaim(neighbour)) { neighbour.Claim(this); hasGrown = true; } } return(hasGrown); }
public override bool Grow() { bool hasGrown = false; if (isRunning && KeepRunning) { CellController neighbour = this.Grid.GetCellInDirection(this.X, this.Y, runningDirection); if (CanClaim(neighbour)) { neighbour.Claim(this); hasGrown = true; } } foreach (GridDirection direction in DirectionsToRunFrom) { CellController neighbour = this.Grid.GetCellInDirection(this.X, this.Y, direction); if (NeighbourIsPlant(neighbour)) { CellController oppositeNeighbour = this.Grid.GetCellInDirection(this.X, this.Y, direction.Opposite()); if (CanClaim(oppositeNeighbour)) { if (!isRunning) { isRunning = true; runningDirection = direction.Opposite(); } ScaredPlant copy = DeepCopy(); copy.runningDirection = direction.Opposite(); oppositeNeighbour.Claim(copy); hasGrown = true; } } } return(hasGrown); }
public override bool Grow() { bool hasGrown = false; if (numNeighbours <= 1 || numNeighbours > 3) { this.Kill(); } else { foreach (GridDirection direction in GridDirectionHelpers.AllDirections) { CellController neighbour = this.Grid.GetCellInDirection(this.X, this.Y, direction); if (neighbour.numNeighbours == 3 && CanClaim(neighbour)) { neighbour.Claim(this); hasGrown = true; } } } return(hasGrown); }