private static void HardRemoveFence(SideEnum sideEnum, NodeFence node) { switch (sideEnum) { case SideEnum.Left: Destroy(node.LeftGameObject); break; case SideEnum.Right: Destroy(node.RightGameObject); break; case SideEnum.Up: Destroy(node.UpGameObject); break; case SideEnum.Down: Destroy(node.DownGameObject); break; default: throw new ArgumentOutOfRangeException("sideEnum", sideEnum, null); } }
private void MoveFenceToNeighbour(NodeFence nodeFence, SideEnum side) { switch (side) { case SideEnum.Left: if (nodeFence.LeftSizeRank < 3 && RightSizeRank > 2) { nodeFence.LeftGameObject = nodeFence.BuildFence( GridManager.Instance.FenceOne, LeftLocation, 1 ); } else { nodeFence.LeftGameObject = RightGameObject; } Destroy(RightGameObject); nodeFence.LeftGameObject.transform.parent = nodeFence.transform; RightGameObject = null; Right = false; RightSizeRank = 0; break; case SideEnum.Right: if (nodeFence.RightSizeRank < 3 && LeftSizeRank > 2) { nodeFence.RightGameObject = nodeFence.BuildFence( GridManager.Instance.FenceOne, RightLocation, -1 ); } else { nodeFence.RightGameObject = LeftGameObject; } Destroy(LeftGameObject); nodeFence.RightGameObject.transform.parent = nodeFence.transform; LeftGameObject = null; Left = false; LeftSizeRank = 0; break; case SideEnum.Up: if (nodeFence.UpSizeRank < 3 && DownSizeRank > 2) { nodeFence.UpGameObject = nodeFence.BuildFence( GridManager.Instance.FenceTwo, UpLocation, -1 ); } else { nodeFence.UpGameObject = DownGameObject; } Destroy(DownGameObject); nodeFence.UpGameObject.transform.parent = nodeFence.transform; DownGameObject = null; Down = false; DownSizeRank = 0; break; case SideEnum.Down: if (nodeFence.DownSizeRank < 3 && UpSizeRank > 2) { nodeFence.DownGameObject = nodeFence.BuildFence( GridManager.Instance.FenceTwo, DownLocation, 0 ); } else { nodeFence.DownGameObject = DownGameObject; } nodeFence.DownGameObject.transform.parent = nodeFence.transform; Destroy(UpGameObject); UpGameObject = null; Up = false; UpSizeRank = 0; break; default: throw new ArgumentOutOfRangeException("side", side, null); } }