public Vector3 Hex2Board(CubeCoordinate hex) { Vector3 position; position.y = spacing.y * (hex.z + 0.5f * hex.x); position.x = spacing.x * hex.x; position.z = 0; return(position); }
public static IEnumerable <CubeCoordinate> Fan(CubeCoordinate center, int radius) { for ( ; radius >= 0; --radius) { foreach (var position in Arc(center, radius)) { yield return(position); } } }
ICell IBoard.this[CubeCoordinate coord] { get { if (cells.TryGetValue(coord, out var cell)) { return(cell); } else { return(null); } } }
public void Destroy(CubeCoordinate coord) { if (cells.TryGetValue(coord, out var cell) == false) { return; } if (cell.block == null) { return; } Destroy(cell.block.gameObject); cell.block = null; }
void IBoard.Spawn(CubeCoordinate coord, int count) { Debug.Assert(count > 0); var spawner = cells[coord].GetComponent <Spawner>(); Debug.Assert(spawner != null, $"Tried to spawn a block from non-spawner cell, {coord}"); var offset = FlatTopDirection.N * count; var p = coord; for (var i = 0; i < count; ++i) { var cell = cells[p]; cell.block = SpawnBlock(spawner.Draw(), p + offset); anim.Drop(cell); p -= FlatTopDirection.N; } }
public static IEnumerable <CubeCoordinate> Ring(CubeCoordinate center, int radius) { if (radius <= 0f) { yield return(center); yield break; } var position = center + (around[4] * radius); foreach (var dir in around) { for (var i = 0; i < radius; ++i) { yield return(position); position += dir; } } }
void IBoard.Drop(CubeCoordinate from, CubeCoordinate to) { Swap(cells[from], cells[to]); Debug.Assert(cells[to].block != null, $"{from} -> {to}"); anim.Drop(cells[to]); }
void IBoard.Swap(CubeCoordinate from, CubeCoordinate to) { Swap(cells[from], cells[to]); }
bool IBoard.HasCell(CubeCoordinate coord) { return(cells.ContainsKey(coord)); }
public int Distance(CubeCoordinate subject) { return(Distance(this, subject)); }
public Line(CubeCoordinate selected, CubeCoordinate direction) { this.selected = selected; this.direction = direction; }
public Vector3 Hex2World(CubeCoordinate hex) { var local = Hex2Board(hex); return(transform.TransformPoint(local)); }
private static bool Less(CubeCoordinate a, CubeCoordinate b) { return(a.r < b.r); }
public Burst(CubeCoordinate selected) { target = selected; }