private void GiveWater(CellularColumn from, CellularColumn to) { float waterFlown = (from.CurrentWaterLevel - to.CurrentWaterLevel) * (float)_velocityRate; to.CurrentWaterLevel += waterFlown; from.CurrentWaterLevel -= waterFlown; }
private void UpdateCellEarthState(CellularColumn cell, Graphics graphics, float earthLevel) { cell.EarthLevel = panelAutomata.Size.Height - earthLevel; cell.CurrentWaterLevel = 0; cell.EarthRect = new Rectangle(new Point(cell.CellShape.Left, (int)earthLevel), new Size(_columnWidth, (int)cell.EarthLevel)); cell.WaterRect = new Rectangle(new Point(cell.CellShape.Left, (int)earthLevel), new Size(_columnWidth, (int)cell.CurrentWaterLevel)); }
private void FillCell(CellularColumn cell, Graphics graphics) { graphics.FillRectangle(_dictionary[State.Air], cell.CellShape); graphics.FillRectangle(_dictionary[State.Water], cell.WaterRect); graphics.FillRectangle(_dictionary[State.Earth], cell.EarthRect); graphics.DrawRectangle(_pen, cell.CellShape); graphics.DrawRectangle(_pen, cell.WaterRect); graphics.DrawRectangle(_pen, cell.EarthRect); }
private void CreateCells(CellularColumn[] automata, State state) { var x = 0; automata[0] = new CellularColumn(new Rectangle(new Point(x, 0), new Size(_columnWidth, panelAutomata.Size.Height)), state); automata[0].CurrentWaterLevel = _maxLevel; automata[0].EarthLevel = 0; automata[0].EarthRect = new Rectangle(new Point(x, panelAutomata.Size.Height), new Size(_columnWidth, 0)); automata[0].WaterRect = new Rectangle(new Point(x, 0), new Size(_columnWidth, panelAutomata.Size.Height)); x += _columnWidth; for (var i = 1; i < automata.Length - 1; i++) { automata[i] = new CellularColumn(new Rectangle(new Point(x, 0), new Size(_columnWidth, panelAutomata.Size.Height)), state); automata[i].EarthRect = new Rectangle( new Point(x, panelAutomata.Size.Height - (int)automata[i].EarthLevel), new Size(_columnWidth, (int)automata[i].EarthLevel)); automata[i].WaterRect = new Rectangle( new Point(x, panelAutomata.Size.Height - (int)automata[i].EarthLevel - (int)automata[i].CurrentWaterLevel), new Size(_columnWidth, (int)automata[i].CurrentWaterLevel)); x += _columnWidth; } automata[automata.Length - 1] = new CellularColumn(new Rectangle(new Point(x, 0), new Size(_columnWidth, panelAutomata.Size.Height)), state); automata[automata.Length - 1].EarthLevel = _maxLevel; automata[automata.Length - 1].EarthRect = new Rectangle(new Point(x, 0), new Size(_columnWidth, panelAutomata.Size.Height)); automata[automata.Length - 1].WaterRect = new Rectangle(new Point(x, 0), new Size(_columnWidth, 0)); }