public override List <BuildState> GetBuildStatus(TriCoordinates coord, TriDirection dir) { List <BuildState> ret = new List <BuildState>(); TriCell cell = TriGrid.Instance.GetCell(coord); int elev = cell.Elevation; ret.Add(new BuildState(coord, cell.IsBuildable())); cell = cell.GetNeighbor(dir); ret.Add(new BuildState(cell.coordinates, cell.IsBuildable() && Mathf.Abs(elev - cell.Elevation) < 2)); return(ret); }
public virtual List <BuildState> GetBuildStatus(TriCoordinates coord, TriDirection dir) { List <BuildState> ret = new List <BuildState>(); TriGrid grid = TriGrid.Instance; TriCell cell = grid.GetCell(coord); int elev = cell.Elevation; ret.Add(new BuildState(cell.coordinates, cell.IsBuildable())); cell = grid.GetCell(coord).GetNeighbor(dir); ret.Add(new BuildState(cell.coordinates, cell.IsBuildable() && Mathf.Abs(cell.Elevation - elev) < 2)); return(ret); }
bool IsBuildable() { if (nowCell) { if (!nowCell.GetNeighbor(dir).IsBuildable()) { return(false); } if (sizeType != null) { switch (sizeType) { case SizeType.HEX: TriCell k = nowCell; int elev = nowCell.Elevation; TriDirection tDir = dir.Previous(); for (int i = 0; i < 6; i++) { if (!k || !k.IsBuildable()) { return(false); } k = k.GetNeighbor(tDir); tDir = tDir.Next(); } return(true); case SizeType.SINGLE: return(nowCell.IsBuildable()); default: return(false); } } return(true); } else { return(false); } }
public static bool IsBuildable(TriDirection dir, TriCoordinates coord, SizeType sizeType) { switch (sizeType) { case SizeType.SINGLE: if (TriGrid.Instance.GetCell(coord).Statics) { return(false); } else { return(true); } case SizeType.HEX: TriCell cell = TriGrid.Instance.GetCell(coord); int elevation = cell.Elevation; TriCell k = cell; int elev = cell.Elevation; TriDirection tDir = dir.Previous(); for (int i = 0; i < 6; i++) { if (!k || !k.IsBuildable()) { return(false); } if (elev != k.Elevation) { return(false); } k = k.GetNeighbor(tDir); tDir = tDir.Next(); } return(true); default: return(false); } }
public override List <BuildState> GetBuildStatus(TriCoordinates coord, TriDirection dir) { List <BuildState> ret = new List <BuildState>(); TriCell k = TriGrid.Instance.GetCell(coord); int elev = k.Elevation; TriDirection tDir = dir.Previous(); for (int i = 0; i < 6; i++) { if (!k) { break; } ret.Add(new BuildState(k.coordinates, k.IsBuildable() && elev == k.Elevation)); k = k.GetNeighbor(tDir); tDir = tDir.Next(); } TriCell entrance = TriGrid.Instance.GetCell(coord).GetNeighbor(dir); ret.Add(new BuildState(entrance.coordinates, entrance.IsBuildable() && Mathf.Abs(entrance.GetNeighbor(dir).Elevation - elev) < 2)); return(ret); }
public void CalculateTerrain() { Clear(); if (selector.nowCell) { TriCell neighbor = selector.nowCell.GetNeighbor(selector.dir); if (neighbor) { RecalculateTerrain(neighbor, neighbor.IsBuildable() && neighbor.Elevation <= selector.nowCell.Elevation + 1 && neighbor.Elevation >= selector.nowCell.Elevation - 1); } switch (selector.sizeType) { case SizeType.HEX: k = selector.nowCell; int elev = selector.nowCell.Elevation; TriDirection tDir = selector.dir.Previous(); for (int i = 0; i < 6; i++) { if (!k) { break; } RecalculateTerrain(k, k.IsBuildable() && k.Elevation == elev); k = k.GetNeighbor(tDir); tDir = tDir.Next(); } break; case SizeType.SINGLE: RecalculateTerrain(selector.nowCell, selector.nowCell.IsBuildable()); break; } } Apply(); }