public void UpdateSeed(int value, CellInfo.Content content = CellInfo.Content.dead) { if (content == CellInfo.Content.dead) { content = CurrentContentMode; } switch (content) { case CellInfo.Content.plant: m_PlantSeedText.text = $"seed : {value}"; break; case CellInfo.Content.herbivorus: m_HerbivorusSeedText.text = $"seed : {value}"; break; case CellInfo.Content.carnivorus: m_CarnivorusSeedText.text = $"seed : {value}"; break; default: break; } }
private Tuple <int, float> GetNeighboursAmount(CellInfo cell, CellInfo.Content type) { Tuple <int, float> result = new Tuple <int, float>(0, 0f); for (var i = -1; i <= 1; i += 1) { for (var j = -1; j <= 1; j += 1) { var neighborX = (cell.X + i + m_GridWidth) % m_GridWidth; var neighborY = (cell.Y + j + m_GridHeight) % m_GridHeight; if (cell.X != neighborX - 1 && cell.X != neighborX && cell.X != neighborX + 1) { continue; } if (cell.Y != neighborY - 1 && cell.Y != neighborY && cell.Y != neighborY + 1) { continue; } if (neighborX != cell.X || neighborY != cell.Y) { switch (type) { case CellInfo.Content.plant: if (CellsArray[neighborX, neighborY].PlantPopulation > 0f) { result = new Tuple <int, float>(result.Item1 + 1, result.Item2 + CellsArray[neighborX, neighborY].GrowthDeltas.x); } break; case CellInfo.Content.herbivorus: if (CellsArray[neighborX, neighborY].HerbivorusPopulation > 0f) { result = new Tuple <int, float>(result.Item1 + 1, result.Item2 + CellsArray[neighborX, neighborY].GrowthDeltas.y); } break; case CellInfo.Content.carnivorus: if (CellsArray[neighborX, neighborY].CarnivorusPopulation > 0f) { result = new Tuple <int, float>(result.Item1 + 1, result.Item2 + CellsArray[neighborX, neighborY].GrowthDeltas.z); } break; default: break; } } } } return(result); }
public void SetMode(int mode) { CurrentContentMode = (CellInfo.Content)mode; CellInfo.Content currentMode = (CellInfo.Content)mode; switch (currentMode) { case CellInfo.Content.dead: PickerBackground.color = DeleteColor; PickerIcon.sprite = DeleteIcon; break; case CellInfo.Content.plant: PickerBackground.color = PlantColor; PickerIcon.sprite = PlantIcon; break; case CellInfo.Content.herbivorus: PickerBackground.color = HerbivorusColor; PickerIcon.sprite = HerbivorusIcon; break; case CellInfo.Content.carnivorus: PickerBackground.color = CarnivorusColor; PickerIcon.sprite = CarnivorusIcon; break; default: break; } }