コード例 #1
0
    // 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");
    }
コード例 #2
0
 public static Vector3 GetGuiPositionForHexVector(this HexVector hexVector, Vector3 gridPosition)
 {
     return(hexVector.GetGuiPositionForHexVector(HexVector.UP_RIGHT, gridPosition));
 }
コード例 #3
0
 /// <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);
 }
コード例 #4
0
 public static Vector2 GetVector2(this HexVector hex)
 {
     return(new Vector2(hex.GetPositionX(), hex.GetPositionY()));
 }
コード例 #5
0
        public static Vector3[] CreateLinePairVerts(this HexVector vector)
        {
            var positionOffset = new Vector3(vector.GetPositionX(), vector.GetPositionY());

            return(CreateLinePairVerts().Select(vector3 => vector3 + positionOffset).ToArray());
        }
コード例 #6
0
 public static VectorLine CreateVectorLine(this HexVector vector)
 {
     Vector3[] hexLinePairs = vector.CreateLinePairVerts();
     return(new VectorLine("HexagonLine", hexLinePairs, Color.white, null, 6.0f, LineType.Discrete));
 }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
 public static IEnumerable <HexVector> GetNeighboursNotInRegion(this HexVector hex, IEnumerable <HexVector> regionHexes)
 {
     return(hex.GetNeighbours().Except(regionHexes));
 }
コード例 #9
0
 public int GetDistance(HexVector vector)
 {
     return((int)Math.Floor(Math.Sqrt(Math.Pow(vector.PlanarProjection, 2) + Math.Pow(vector.VerticalComponent.Magnitude, 2))));
 }