private void DisableAllWalls() { oneSideObject.SetActive(false); twoSidesObject.SetActive(false); threeSidesObject.SetActive(false); fourSidesObject.SetActive(false); zeroSideObject.SetActive(false); CornerObject.SetActive(false); transform.rotation = new Quaternion(0, 0, 0, 0); }
public void CheckNeighbours() { if (!canBeChecked || ignoreCurrentMeshChange) { return; } canBeChecked = false; DisableAllWalls(); bool topActive = CheckIfSideHasNeighbour(topChecker); bool downActive = CheckIfSideHasNeighbour(downChecker); bool leftActive = CheckIfSideHasNeighbour(leftChecker); bool rightActive = CheckIfSideHasNeighbour(rightChecker); int connectedSides = 0; if (topActive) { connectedSides += 1; } if (downActive) { connectedSides += 1; } if (leftActive) { connectedSides += 1; } if (rightActive) { connectedSides += 1; } StartCoroutine(StartCooldown()); switch (connectedSides) { case 4: fourSidesObject.SetActive(true); break; case 3: threeSidesObject.SetActive(true); LookAtNeighbour(GetMissingNeighbour(topActive, downActive, rightActive, leftActive).position, transform); break; case 2: if (topActive && downActive) { twoSidesObject.SetActive(true); LookAtNeighbour(topChecker.position, transform); break; } if (leftActive && rightActive) { twoSidesObject.SetActive(true); LookAtNeighbour(leftChecker.position, transform); break; } CornerObject.SetActive(true); LookAtNeighbour(GetMiddlePointForCorner(topActive, downActive, rightActive, leftActive), transform); break; case 1: oneSideObject.SetActive(true); LookAtNeighbour(GetSingularSide().position, transform); break; case 0: zeroSideObject.SetActive(true); break; } }