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

            return(CreateLinePairVerts().Select(vector3 => vector3 + positionOffset).ToArray());
        }
Esempio n. 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));
 }
Esempio n. 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);
 }
Esempio n. 8
0
 public static IEnumerable <HexVector> GetNeighboursNotInRegion(this HexVector hex, IEnumerable <HexVector> regionHexes)
 {
     return(hex.GetNeighbours().Except(regionHexes));
 }
Esempio n. 9
0
 public int GetDistance(HexVector vector)
 {
     return((int)Math.Floor(Math.Sqrt(Math.Pow(vector.PlanarProjection, 2) + Math.Pow(vector.VerticalComponent.Magnitude, 2))));
 }