public void RazeEdges(TileScript t) { // remove all loose edges foreach (var d in this.Map.Directions.Where(x => t.GetEdge(x).Opposite(t) == null)) { this.Map.KillEdge(t.GetEdge(d)); } // downgrade rest (but Indoor -> Outdoor, skipping an extra step) this.Map.DowngradeEdges(t); }
public List <Direction> GetFreeEdgeDirections(TileScript t) { var free = new List <Direction>(); foreach (var d in this.Directions) { if (t.GetEdge(d) == null) { free.Add(d); } } return(free); }
// null -> outdoor -> none -> indoor // (only after pull edges btw) public void UpgradeEdges(TileScript t) { foreach (var d in this.Directions) { var e = t.GetEdge(d); if (e == null) { e = this.CreateEdge(t.Position, d); t.SetEdge(d, e); } var wt = (WallType)((int)e.Wall + 1); this.SetWall(e, (WallType)((int)e.Wall + 1)); } }
// game object wise, not model wise public GameObject SpawnWall(TileScript t, Direction d) { var w = Instantiate(this.Wall); var wt = w.transform; var center = t.transform.Find("Center"); wt.position = center.position; wt.eulerAngles = new Vector3(wt.eulerAngles.x, ((int)d) * 90, wt.eulerAngles.z); // place into the hierarchy wt.parent = this.Walls.transform; t.GetEdge(d).EdgeObject = w; return(w); }
// indoor -2-> none -> outdoor -> null // (down indoor twice) public void DowngradeEdges(TileScript t) { foreach (var d in this.Directions) { var e = t.GetEdge(d); if (e == null) { continue; } switch (e.Wall) { case WallType.Indoor: case WallType.None: this.SetWall(e, WallType.Outdoor); break; case WallType.Outdoor: this.KillEdge(e); break; } } }