public override void Init() { cells = new Dictionary <ulong, Cell>(); uint rings = parameters.rings; for (int q = (int)(-rings); q <= rings; q++) { int r1 = (int)Math.Max(-rings, -q - rings); int r2 = (int)Math.Min(rings, -q + rings); for (int r = r1; r <= r2; r++) { cells.Add(Cantor.Pairing(q, r), CreateCellAtPosition(new HexagonalPosition(q, r))); } } base.Init(); }
public override void Init() { cells = new Dictionary <ulong, Cell>(); for (int i = 0; i < parameters.shape.Width; i++) { for (int j = 0; j < parameters.shape.Height; j++) { RectangularPosition pos = new RectangularPosition(i, j); if (parameters.shape.ContainsAtPosition(pos)) { cells.Add(Cantor.Pairing(i, j), CreateCellAtPosition(pos)); } } } base.Init(); }
protected override Cell CellAtPosition(RectangularPosition position) { return(cells[Cantor.Pairing(position.x, position.y)]); }
public override int GetHashCode() { return((int)Cantor.Pairing(q, r)); }
protected override Cell CellAtPosition(HexagonalPosition position) { return(cells[Cantor.Pairing(position.q, position.r)]); }
protected override bool ContainsAtPosition(HexagonalPosition position) { return(cells.ContainsKey(Cantor.Pairing(position.q, position.r))); }