//clockwise private void SetStartParameters() { //starts from left bottom switch (connectionType) { case 2: //00 //10 exitDirection = SquareEdge.Left; break; case 3: //00 //11 exitDirection = SquareEdge.Left; break; case 10: //10 //10 exitDirection = SquareEdge.Top; break; case 6: //01 //10 exitDirection = SquareEdge.Right; break; case 14: //11 //10 exitDirection = SquareEdge.Right; break; case 11: //10 //11 exitDirection = SquareEdge.Top; break; case 7: //01 //11 exitDirection = SquareEdge.Left; break; default: UnityEngine.Debug.Log(hashMap[mainX][mainZ] + " : " + targetHash); UnityEngine.Debug.Log("hit default in begin. current connection type is " + connectionType + ", main x: " + mainX + ", z: " + mainZ); break; } }
public bool Iterate() { //return sucsess bool result = true; SetConnectionType(); if (connectionType == 0 || connectionType == 15) { UnityEngine.Debug.LogError("thing happen: " + connectionType); } //SquareEdge enterDirection = exitDirection; switch (connectionType) { case 1: //00 //01 if (exitDirection == SquareEdge.Bottom) { exitDirection = SquareEdge.Left; } else if (exitDirection == SquareEdge.Right) { exitDirection = SquareEdge.Top; } else { result = false; } break; case 2: //00 //10 if (exitDirection == SquareEdge.Left) { exitDirection = SquareEdge.Top; } else if (exitDirection == SquareEdge.Bottom) { exitDirection = SquareEdge.Right; } else { result = false; } break; case 4: //01 //00 if (exitDirection == SquareEdge.Right) { exitDirection = SquareEdge.Bottom; } else if (exitDirection == SquareEdge.Top) { exitDirection = SquareEdge.Left; } else { result = false; } break; case 8: //10 //00 if (exitDirection == SquareEdge.Top) { exitDirection = SquareEdge.Right; } else if (exitDirection == SquareEdge.Left) { exitDirection = SquareEdge.Bottom; } else { result = false; } break; case 3: //00 //11 if (exitDirection == SquareEdge.Left) { exitDirection = SquareEdge.Left; } else if (exitDirection == SquareEdge.Right) { exitDirection = SquareEdge.Right; } else { result = false; } break; case 5: //01 //01 if (exitDirection == SquareEdge.Bottom) { exitDirection = SquareEdge.Bottom; } else if (exitDirection == SquareEdge.Top) { exitDirection = SquareEdge.Top; } else { result = false; } break; case 12: //11 //00 if (exitDirection == SquareEdge.Right) { exitDirection = SquareEdge.Right; } else if (exitDirection == SquareEdge.Left) { exitDirection = SquareEdge.Left; } else { result = false; } break; case 10: //10 //10 if (exitDirection == SquareEdge.Top) { exitDirection = SquareEdge.Top; } else if (exitDirection == SquareEdge.Bottom) { exitDirection = SquareEdge.Bottom; } else { result = false; } break; case 6: //01 //10 switch (exitDirection) { case SquareEdge.Bottom: //exitDirection = SquareEdge.Right; exitDirection = SquareEdge.Left; break; case SquareEdge.Top: exitDirection = SquareEdge.Right; //exitDirection = SquareEdge.Left; break; case SquareEdge.Left: exitDirection = SquareEdge.Bottom; //exitDirection = SquareEdge.Top; break; case SquareEdge.Right: exitDirection = SquareEdge.Top; //exitDirection = SquareEdge.Bottom; break; } break; case 9: //10 //01 switch (exitDirection) { case SquareEdge.Bottom: exitDirection = SquareEdge.Left; break; case SquareEdge.Top: exitDirection = SquareEdge.Right; break; case SquareEdge.Left: exitDirection = SquareEdge.Bottom; break; case SquareEdge.Right: exitDirection = SquareEdge.Top; break; } break; case 14: //11 //10 if (exitDirection == SquareEdge.Right) { exitDirection = SquareEdge.Top; } else if (exitDirection == SquareEdge.Bottom) { exitDirection = SquareEdge.Left; } else { result = false; } break; case 13: //11 //01 if (exitDirection == SquareEdge.Bottom) { exitDirection = SquareEdge.Right; } else if (exitDirection == SquareEdge.Left) { exitDirection = SquareEdge.Top; } else { result = false; } break; case 11: //10 //11 if (exitDirection == SquareEdge.Top) { exitDirection = SquareEdge.Left; } else if (exitDirection == SquareEdge.Right) { exitDirection = SquareEdge.Bottom; } else { result = false; } break; case 7: //01 //11 if (exitDirection == SquareEdge.Left) { exitDirection = SquareEdge.Bottom; } else if (exitDirection == SquareEdge.Top) { exitDirection = SquareEdge.Right; } else { result = false; } break; default: UnityEngine.Debug.Log("hit default. current connection type is " + connectionType); result = false; break; } //z /\ //x > //Debuger.Debuger3.AddLabel(fragmentMap[mainX][mainZ].GetRealMax(template) + (Vector3.up * 0.05f), connectionType + " : " + enterDirection + " : " + exitDirection); //Debuger.Debuger3.AddDot(fragmentMap[mainX][mainZ].GetRealMax(template), Color.red, 0.01f); switch (exitDirection) { case SquareEdge.Left: mainX += 1; break; case SquareEdge.Right: mainX -= 1; break; case SquareEdge.Bottom: mainZ += 1; break; case SquareEdge.Top: mainZ -= 1; break; } return(result); }