public void setBadSpell(int s) { if (ControlFactors.PLAYER_CAN_CAST) { // Debug.Log("Bad Spell Selected"); badSpellChoice = (BadSpellType)s; spellTypeSelected = false; spellDragging = true; spellUseIdentifier.GetComponent <SpriteRenderer>().enabled = true; spellUseIdentifier.GetComponent <SpriteRenderer>().color = Color.red; uih.selectedBox.GetComponent <Image>().enabled = false; } }
// Start is called before the first frame update void Start() { badSpellChoice = BadSpellType.Squish; goodSpellChoice = GoodSpellType.Bless; spellQueue = new List <Spell>(); gt = GameObject.FindGameObjectWithTag("GridController").GetComponent <GridTester>(); uih = gt.GetComponent <UIHandler>(); mesh = new Mesh(); /* * Vector3[] verticies = * { * new Vector3(-gt.mapWidth * gt.gridNodeWidth - gt.gridNodeWidth, 0), * new Vector3(-gt.gridNodeWidth,gt.mapHeight * gt.gridNodeHeight), * new Vector3(gt.mapWidth * gt.gridNodeWidth - gt.gridNodeWidth, 0), * new Vector3(-gt.gridNodeWidth,-gt.mapHeight * gt.gridNodeHeight) * }; * mesh.vertices = verticies; * mesh.triangles = new int[] { 0, 1, 2, 0, 2, 3 };*/ float angleStep = 360.0f / (float)gt.Land.numOfPoints; List <Vector3> vertexList = new List <Vector3>(); List <int> triangleList = new List <int>(); Quaternion quaternion = Quaternion.Euler(0.0f, 0.0f, angleStep); // Make first triangle. vertexList.Add(new Vector3(0.0f, 0.0f, 0.0f)); // 1. Circle center. vertexList.Add(new Vector3(0.0f, gt.Expansion_Distance, 0.0f)); // 2. First vertex on circle outline (radius = 0.5f) vertexList.Add(quaternion * vertexList[1]); // 3. First vertex on circle outline rotated by angle) // Add triangle indices. triangleList.Add(0); triangleList.Add(1); triangleList.Add(2); for (int i = 0; i < gt.Land.numOfPoints - 1; i++) { triangleList.Add(0); // Index of circle center. triangleList.Add(vertexList.Count - 1); triangleList.Add(vertexList.Count); vertexList.Add(quaternion * vertexList[vertexList.Count - 1]); } mesh.vertices = vertexList.ToArray(); mesh.triangles = triangleList.ToArray(); GetComponent <MeshFilter>().mesh = mesh; GetComponent <MeshCollider>().sharedMesh = mesh; }