Exemple #1
0
        private void TestCreateMesh()
        {
            var mesh = HexMesh.GetMesh(10);
            var go   = new GameObject("Mesh");

            go.AddComponent <MeshFilter>().sharedMesh = mesh;
            go.AddComponent <MeshRenderer>();
            go.AddComponent <MeshCollider>();
        }
Exemple #2
0
        public void ShowHex(HexCoordinates hex, Vector3 offset, float size, Material mat)
        {
            mat = GetMaterial(mat);
            mat.SetColor("_Color", color);
            mat.SetFloat("_MinSize", minSize);
            mat.SetFloat("_MaxSize", maxSize);
            mat.SetFloat("_Internal", pointInternal);

            mat.SetPass(0);
            Graphics.DrawMeshNow(HexMesh.GetMesh(size), (Vector3)hex.HexToPixel(size) + offset, Quaternion.identity);
        }
Exemple #3
0
        public void CreateMap(HexMap hexMap)
        {
            HexMap   = hexMap;
            Width    = HexMap.Map.width;
            Height   = HexMap.Map.height;
            _hexMesh = GetComponentInChildren <HexMesh>();
            _hexMesh.Init();
            Cells = new List <HexCell>();
            for (int z = 0, i = 0; z < Height; z++)
            {
                for (var x = 0; x < Width; x++)
                {
                    CreateCell(x, z, i++);
                }
            }

            TriangulateCells();
        }
Exemple #4
0
 private void Start()
 {
     _outerVerts = HexMesh.CalculateVerts(transform.position, Vector3.up, 1)
                   .Skip(1)
                   .ToArray();
 }