Vector3 hex_corner_int( CornerDirection i) { switch (i) { case CornerDirection.dr: return gameObject.transform.position + new Vector3( 32, -16, 0) + new Vector3( 32, -16, 0); case CornerDirection.d: return gameObject.transform.position + new Vector3( 0, -32, 0) + new Vector3( 32, -16, 0); case CornerDirection.dl: return gameObject.transform.position + new Vector3( -32, -16, 0) + new Vector3( 32, -16, 0); case CornerDirection.ul: return gameObject.transform.position + new Vector3( -32, 16, 0) + new Vector3( 32, -16, 0); case CornerDirection.u: return gameObject.transform.position + new Vector3( 0, 32, 0) + new Vector3( 32, -16, 0); case CornerDirection.ur: return gameObject.transform.position + new Vector3( 32, 16, 0) + new Vector3( 32, -16, 0); default: return gameObject.transform.position; } }
// | | // // | Hex Methods | // // | | // // PSEUDOCODE for corner method // function hex_corner(center, size, i): // var angle_deg = 60 * i + 30 // var angle_rad = PI / 180 * angle_deg // return Point(center.x + size * cos(angle_rad), // center.y + size * sin(angle_rad)) Vector3 hex_corner( CornerDirection i) { int angle_deg = 60 * (int)i + 30; float angle_rad = Mathf.PI / 180.0f * angle_deg; return new Vector3 ( gameObject.transform.position.x + (int)(32 * Mathf.Cos (angle_rad)), gameObject.transform.position.y + (int)(32 * Mathf.Sin (angle_rad)), gameObject.transform.position.z ); }
public CubeCorner(int q, int r, CornerDirection direction) { _hex = new CubeHex(q, r); _direction = direction; }
// # Constructors public CubeCorner(CubeHex hex, CornerDirection direction) { _hex = hex; _direction = direction; }
void SelectTile() { if (autoTileMode == AutoTileMode.Background) { sx = 0; sy = 7; } else { sx = 6; sy = 2; if (Gates(3)) { sx = 2; sy = 2; cornerType = CornerDirection.None; } if (Gates(0)) { sx = 3; sy = 2; cornerType = CornerDirection.None; } if (Gates(1)) { sx = 4; sy = 2; cornerType = CornerDirection.None; } if (Gates(2)) { sx = 5; sy = 2; cornerType = CornerDirection.None; } if (Gates(1, 3)) { sx = 0; sy = 2; cornerType = CornerDirection.None; } if (Gates(0, 2)) { sx = 1; sy = 2; cornerType = CornerDirection.None; } if (Gates(0, 3)) { sx = 7; sy = 1; cornerType = CornerDirection.ForwardSlash; } if (Gates(1, 0)) { sx = 0; sy = 0; cornerType = CornerDirection.BackwardSlash; } if (Gates(2, 1)) { sx = 1; sy = 0; cornerType = CornerDirection.ForwardSlash; } if (Gates(3, 2)) { sx = 2; sy = 0; cornerType = CornerDirection.BackwardSlash; } if (Gates(2, 3, 7)) { sx = 4; sy = 3; cornerType = CornerDirection.BackwardSlash; } if (Gates(3, 0, 4)) { sx = 5; sy = 3; cornerType = CornerDirection.ForwardSlash; } if (Gates(0, 1, 5)) { sx = 6; sy = 3; cornerType = CornerDirection.BackwardSlash; } if (Gates(1, 2, 6)) { sx = 7; sy = 3; cornerType = CornerDirection.ForwardSlash; } if (Gates(0, 1, 3)) { sx = 3; sy = 0; cornerType = CornerDirection.None; } if (Gates(1, 2, 0)) { sx = 4; sy = 0; cornerType = CornerDirection.None; } if (Gates(2, 3, 1)) { sx = 5; sy = 0; cornerType = CornerDirection.None; } if (Gates(3, 0, 2)) { sx = 6; sy = 0; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3)) { sx = 7; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 2, 3, 7)) { sx = 7; sy = 2; cornerType = CornerDirection.None; } if (Gates(1, 3, 0, 4)) { sx = 0; sy = 1; cornerType = CornerDirection.None; } if (Gates(2, 0, 1, 5)) { sx = 1; sy = 1; cornerType = CornerDirection.None; } if (Gates(3, 1, 2, 6)) { sx = 2; sy = 1; cornerType = CornerDirection.None; } if (Gates(0, 1, 3, 5)) { sx = 3; sy = 1; cornerType = CornerDirection.None; } if (Gates(1, 2, 0, 6)) { sx = 4; sy = 1; cornerType = CornerDirection.None; } if (Gates(2, 3, 1, 7)) { sx = 5; sy = 1; cornerType = CornerDirection.None; } if (Gates(3, 0, 2, 4)) { sx = 6; sy = 1; cornerType = CornerDirection.None; } if (Gates(1, 2, 3, 6, 7)) { sx = 0; sy = 3; cornerType = CornerDirection.None; } if (Gates(0, 2, 3, 4, 7)) { sx = 1; sy = 3; cornerType = CornerDirection.None; } if (Gates(0, 1, 3, 4, 5)) { sx = 2; sy = 3; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 5, 6)) { sx = 3; sy = 3; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 7)) { sx = 3; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4)) { sx = 4; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 5)) { sx = 5; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 6)) { sx = 6; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 5, 7)) { sx = 1; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4, 6)) { sx = 2; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 6, 7)) { sx = 5; sy = 5; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4, 7)) { sx = 6; sy = 5; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4, 5)) { sx = 7; sy = 5; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 5, 6)) { sx = 0; sy = 4; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 5, 6, 7)) { sx = 1; sy = 5; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4, 6, 7)) { sx = 2; sy = 5; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4, 5, 7)) { sx = 3; sy = 5; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4, 5, 6)) { sx = 4; sy = 5; cornerType = CornerDirection.None; } if (Gates(0, 1, 2, 3, 4, 5, 6, 7)) { sx = 0; sy = 5; cornerType = CornerDirection.None; } } UpdateColliders(); UpdateDisplay(); }
public static CornerDirection Opposite(this CornerDirection direction) { var newDir = ((int)direction + 2) % 4; return((CornerDirection)newDir); }
void SelectTile() { if (autoTileMode==AutoTileMode.Background) { sx=0; sy=7; } else { sx=6; sy=2; if (Gates(3)){sx=2;sy=2; cornerType=CornerDirection.None;} if (Gates(0)){sx=3;sy=2; cornerType=CornerDirection.None;} if (Gates(1)){sx=4;sy=2; cornerType=CornerDirection.None;} if (Gates(2)){sx=5;sy=2; cornerType=CornerDirection.None;} if (Gates(1,3)){sx=0;sy=2; cornerType=CornerDirection.None;} if (Gates(0,2)){sx=1;sy=2; cornerType=CornerDirection.None;} if (Gates(0,3)){sx=7;sy=1; cornerType=CornerDirection.ForwardSlash ;} if (Gates(1,0)){sx=0;sy=0; cornerType=CornerDirection.BackwardSlash;} if (Gates(2,1)){sx=1;sy=0; cornerType=CornerDirection.ForwardSlash ;} if (Gates(3,2)){sx=2;sy=0; cornerType=CornerDirection.BackwardSlash;} if (Gates(2,3,7)){sx=4;sy=3; cornerType=CornerDirection.BackwardSlash;} if (Gates(3,0,4)){sx=5;sy=3; cornerType=CornerDirection.ForwardSlash ;} if (Gates(0,1,5)){sx=6;sy=3; cornerType=CornerDirection.BackwardSlash;} if (Gates(1,2,6)){sx=7;sy=3; cornerType=CornerDirection.ForwardSlash ;} if (Gates(0,1,3)){sx=3;sy=0; cornerType=CornerDirection.None;} if (Gates(1,2,0)){sx=4;sy=0; cornerType=CornerDirection.None;} if (Gates(2,3,1)){sx=5;sy=0; cornerType=CornerDirection.None;} if (Gates(3,0,2)){sx=6;sy=0; cornerType=CornerDirection.None;} if (Gates(0,1,2,3)){sx=7;sy=4; cornerType=CornerDirection.None;} if (Gates(0,2,3,7)){sx=7;sy=2; cornerType=CornerDirection.None;} if (Gates(1,3,0,4)){sx=0;sy=1; cornerType=CornerDirection.None;} if (Gates(2,0,1,5)){sx=1;sy=1; cornerType=CornerDirection.None;} if (Gates(3,1,2,6)){sx=2;sy=1; cornerType=CornerDirection.None;} if (Gates(0,1,3,5)){sx=3;sy=1; cornerType=CornerDirection.None;} if (Gates(1,2,0,6)){sx=4;sy=1; cornerType=CornerDirection.None;} if (Gates(2,3,1,7)){sx=5;sy=1; cornerType=CornerDirection.None;} if (Gates(3,0,2,4)){sx=6;sy=1; cornerType=CornerDirection.None;} if (Gates(1,2,3,6,7)){sx=0;sy=3; cornerType=CornerDirection.None;} if (Gates(0,2,3,4,7)){sx=1;sy=3; cornerType=CornerDirection.None;} if (Gates(0,1,3,4,5)){sx=2;sy=3; cornerType=CornerDirection.None;} if (Gates(0,1,2,5,6)){sx=3;sy=3; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,7)){sx=3;sy=4; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4)){sx=4;sy=4; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,5)){sx=5;sy=4; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,6)){sx=6;sy=4; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,5,7)){sx=1;sy=4; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4,6)){sx=2;sy=4; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,6,7)){sx=5;sy=5; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4,7)){sx=6;sy=5; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4,5)){sx=7;sy=5; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,5,6)){sx=0;sy=4; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,5,6,7)){sx=1;sy=5; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4,6,7)){sx=2;sy=5; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4,5,7)){sx=3;sy=5; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4,5,6)){sx=4;sy=5; cornerType=CornerDirection.None;} if (Gates(0,1,2,3,4,5,6,7)){sx=0;sy=5; cornerType=CornerDirection.None;} } UpdateColliders(); UpdateDisplay(); }
// Constructor public GBTCorner(GBTHex hex, CornerDirection direction) { // Value needs to be <= CornerMask. _value = hex.value | CornerMask | (direction > 0 ? Left : 0); }
private void AddCorner(bool forceLeft) { cornerDirection = prevCornerDirection; Random.seed = (int)System.DateTime.Now.Ticks; int i = Random.Range (0, 99); if (forceLeft) { i = 0; } GameObject obj; if (i <= 50) { prevCornerDirection = CornerDirection.LEFT; obj = (GameObject)GameObject.Instantiate (Corner, TrackPos, Quaternion.Euler (0, TrackDirection, 0)); // Left corner obj.GetComponent<Transform> ().rotation.Set (0, TrackDirection, 0, 0); obj.transform.SetParent (gameObject.transform); objList.Add (obj); TrackDirection -= 90; if (TrackDirection <= -90) { TrackDirection = 270; } } else { prevCornerDirection = CornerDirection.RIGHT; obj = (GameObject)GameObject.Instantiate (Corner, TrackPos, Quaternion.Euler (0, TrackDirection - 90.0f, 0)); // Right corner obj.GetComponent<Transform> ().rotation.Set (0, TrackDirection, 0, 0); obj.transform.SetParent (gameObject.transform); objList.Add (obj); TrackDirection += 90; if (TrackDirection >= 360) { TrackDirection = 0; } } }