Scene.hexNum[] neighbour = new Scene.hexNum[6]; // start from left up hexagon, clockwise void Initialize() { //for (int i=0; i<6; i++) //neighbourHex[i] = null; hexA = NumToAxis(hexNum.num_x, hexNum.num_z); neighbour = GetNeighbourHex(hexNum); }
public static Scene.hexAxis[] NumToAxisArray(Scene.hexNum[] array) { Scene.hexAxis[] axisArray = new Scene.hexAxis[array.Length]; for (int i = 0; i < array.Length; i++) { axisArray[i] = NumToAxis(array[i].num_x, array[i].num_z); } return(axisArray); }
public static int NearestAngleForCamera(Scene.hexAxis start, Scene.hexAxis end) { Vector3 v = new Vector3(end.axis_x - start.axis_x, 0, end.axis_z - start.axis_z); float angle = Vector3.Angle(Vector3.forward, v); int angleInt = Mathf.RoundToInt((angle - 30) / 60) * 60 + 30; if (Vector3.Cross(v, Vector3.forward).y > 0) { angleInt = -angleInt; } return(angleInt); }
public static void DebugDrawPoint(Scene.hexNum hexN, int angle, Color color, float y = 0.5f) { Scene.hexAxis hexA = Hexagon.NumToAxis(hexN.num_x, hexN.num_z); Vector3 pos; pos.x = hexA.axis_x; pos.z = hexA.axis_z; pos.y = y; Vector3 dir = Matrix4x4.Rotate(Quaternion.Euler(0, angle, 0)).MultiplyVector(Vector3.forward); Debug.DrawLine(pos, pos + dir * 0.5f, color, 10f); }
private void OnTriggerEnter(Collider other) { var player = other.GetComponent <PlayerCharacter>(); if (inDoor) { //player.Move(0); // stop player, cancel original speed Vector3 pos; Scene.hexAxis hexA = Hexagon.NumToAxis(pairedDoor.nearestHex.num_x, pairedDoor.nearestHex.num_z); pos.x = hexA.axis_x; pos.z = hexA.axis_z; pos.y = 0.5f; controller.waitToTurn = false; controller.waitToTransmit = true; activeCamera.transmit = true; //controller.waitToTransmit = true; player.transform.forward = pairedDoor.forwardVector; player.transform.position = pos; AudioSource.PlayClipAtPoint(transmitSound, player.transform.position); //Debug.Log("Set rot: "+player.transform.eulerAngles.y); } }
public static Vector3 CenterVectorBetweenTwoHex(Scene.hexNum start, Scene.hexNum end) { Scene.hexAxis startAxis = NumToAxis(start.num_x, start.num_z); Scene.hexAxis endAxis = NumToAxis(end.num_x, end.num_z); return(new Vector3(endAxis.axis_x - startAxis.axis_x, 0, endAxis.axis_z - startAxis.axis_z)); }