// Use this for initialization void Start() { //测试用 for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { GameObject gameObject = new GameObject("test" + i.ToString() + j.ToString()); gameObject.transform.parent = GameObject.Find("Plane").transform; HexVector vector = new HexVector(); Button btn = gameObject.AddComponent <Button>(); MapUnit mapunit = gameObject.AddComponent <MapUnit>(); MeshFilter flit = gameObject.AddComponent <MeshFilter>(); MeshRenderer renderer = gameObject.AddComponent <MeshRenderer>(); gameObject.AddComponent <BoxCollider>(); flit.mesh = mesh; gameObject.transform.position = vector.ChangeToVect(new Vector3(i, 0, j)); // Debug.Log(gameObject.transform.position); } } // setaround(GameObject.Find("test00")); // Debug.Log("clicktest00"); }
public static Vector3 GetGuiPositionForHexVector(this HexVector hexVector, Vector3 gridPosition) { return(hexVector.GetGuiPositionForHexVector(HexVector.UP_RIGHT, gridPosition)); }
/// <summary> /// Returns the y-coordinate of the hexagon, based on HX,HY,HZ; in 2d space with y downwards. /// </summary> public static float GetPositionY(this HexVector hex) { return((float)(hex.HZ - hex.HY) * SCALE); }
public static Vector2 GetVector2(this HexVector hex) { return(new Vector2(hex.GetPositionX(), hex.GetPositionY())); }
public static Vector3[] CreateLinePairVerts(this HexVector vector) { var positionOffset = new Vector3(vector.GetPositionX(), vector.GetPositionY()); return(CreateLinePairVerts().Select(vector3 => vector3 + positionOffset).ToArray()); }
public static VectorLine CreateVectorLine(this HexVector vector) { Vector3[] hexLinePairs = vector.CreateLinePairVerts(); return(new VectorLine("HexagonLine", hexLinePairs, Color.white, null, 6.0f, LineType.Discrete)); }
/// <summary> /// Returns the x-coordinate of the hexagon, based on HX,HY,HZ; in 2d space with y downwards. /// </summary> public static float GetPositionX(this HexVector hex) { return((float)(hex.HX * sqrt3) * SCALE); }
public static IEnumerable <HexVector> GetNeighboursNotInRegion(this HexVector hex, IEnumerable <HexVector> regionHexes) { return(hex.GetNeighbours().Except(regionHexes)); }
public int GetDistance(HexVector vector) { return((int)Math.Floor(Math.Sqrt(Math.Pow(vector.PlanarProjection, 2) + Math.Pow(vector.VerticalComponent.Magnitude, 2)))); }