// Start is called before the first frame update void Start() { //Debug.Log("starting at moveUnit"); if (hexa == null) { hexa = Hexasphere.GetInstance("Hexasphere"); } if (thisUnit == null) { thisUnit = gameObject.GetComponent <Unit>(); } if (autoMove == null) { autoMove = gameObject.GetComponent <autoMovement>(); } //currentTile = thisUnit.currentTile; }
void Start() { if (touchMan == null) { touchMan = GameObject.Find("_Managers").GetComponent <touchManager>(); } if (menuParent == null) { menuParent = GetComponentInParent <adjustMenu>(); } if (hexa == null) { hexa = menuParent.hexa; } if (robotParent == null) { robotParent = GameObject.Find("Robots").GetComponent <Transform>(); } }
// Start is called before the first frame update void Start() { if (touchM == null) { touchM = GameObject.Find("_Managers").GetComponent <touchManager>(); } if (turretObj == null) { turretObj = Resources.Load <GameObject>("turret"); } if (hexa == null) { hexa = GameObject.Find("Hexasphere").GetComponent <Hexasphere>(); } if (tileExtrude == null) { tileExtrude = GameObject.Find("extrude").GetComponent <setTileExtrude>(); } }
// Use this for initialization void Start() { Hexasphere hexasphere = new Hexasphere(radius, 30); var verts = new List <Vector3>(); var tris = new List <int>(); var i = 0; foreach (Region region in hexasphere.Regions) { foreach (Tile tile in region.GetTiles()) { foreach (var point in tile.Boundary) { var height = Mathf.Max(TerrainHeight - NoiseGenerator.getDensity(point.AsVector(), 0, TerrainHeight, octaves: 3, persistence: 0.85f), 0); verts.Add(point.Project(height).AsVector()); } tris.Add(i); tris.Add(i + 1); tris.Add(i + 2); tris.Add(i + 2); tris.Add(i + 3); tris.Add(i + 4); tris.Add(i + 4); tris.Add(i); tris.Add(i + 2); if (tile.Boundary.Count > 5) { tris.Add(i + 4); tris.Add(i + 5); tris.Add(i); } i += tile.Boundary.Count; } } var mesh = new Mesh() { vertices = verts.ToArray(), triangles = tris.ToArray() }; mesh.RecalculateNormals(); GetComponent <MeshFilter>().mesh = mesh; }
public override void _Ready() { // Called every time the node is added to the scene. // Initialization here GD.Print("Hello from the Node CS Script Init"); //Define sphere properties float radius = 95; float scale = radius; int subdivisionCount = 3; //h is used for creating full size tiles Hexasphere h = new Hexasphere((decimal)radius, subdivisionCount, 1); //h2 is for creating the line mesh Hexasphere h2 = new Hexasphere((decimal)radius, subdivisionCount, 1); GD.Print("Number of Tiles: " + h.GetTiles().Count); //Load the instances to put in the scene var meshInstance = (PackedScene)ResourceLoader.Load("res://MeshInstance.tscn"); var sphereMeshScene = (PackedScene)ResourceLoader.Load("res://SphereMesh.tscn"); var greenSphereMeshScene = (PackedScene)ResourceLoader.Load("res://GreenSphereMesh.tscn"); var redSphereMeshScene = (PackedScene)ResourceLoader.Load("res://RedSphereMesh.tscn"); var hexagonTestScene = (PackedScene)ResourceLoader.Load("res://MattLevel/Main.tscn"); //Hexagon var pentagonTestScene = (PackedScene)ResourceLoader.Load("res://MattLevel/Pentagon.tscn"); //Pentagon, Main var numberOfTiles = h.GetTiles().Count; //Create all the tiles foreach (var tile in h.GetTiles()) { CreateInstance(tile, hexagonTestScene, pentagonTestScene, redSphereMeshScene, radius / numberOfTiles); } //Create the line mesh foreach (var tile in h2.GetTiles()) { CreateMesh(tile, sphereMeshScene, greenSphereMeshScene, h2.GetTiles().Count, radius * 0.99f); } }