/// <summary> /// Sets the greater triangle colours to match the center colour /// Also increments score /// </summary> /// <param name="center">The Center Triangle</param> private void SetGreaterTriangleColours(triangleNode center) { GlobalFlags.setScore(GlobalFlags.getScore() + (GlobalFlags.getBaseScoreValue() * GlobalFlags.getMultiplier())); center.delayedDestroy = true; Color c = center.triangleObject.GetComponent<TriangleColour>().GetColour(); triangleNode n; if( c != Color.black) { if(isPointingUp(center)) { //check upper node n = getNode(center.x, center.y - 1); if(n !=null && n.triangleObject.GetComponent<TriangleColour>().GetColour() != Color.black) { n.triangleObject.GetComponent<TriangleColour>().SetColour(c); } } else { //check lower node n = getNode(center.x, center.y + 1); if(n !=null && n.triangleObject.GetComponent<TriangleColour>().GetColour() != Color.black) { n.triangleObject.GetComponent<TriangleColour>().SetColour(c); } } //check left node n = getNode(center.x - 1, center.y); if(n !=null && n.triangleObject.GetComponent<TriangleColour>().GetColour() != Color.black) { n.triangleObject.GetComponent<TriangleColour>().SetColour(c); } //check right node n = getNode(center.x + 1, center.y); if(n !=null && n.triangleObject.GetComponent<TriangleColour>().GetColour() != Color.black) { n.triangleObject.GetComponent<TriangleColour>().SetColour(c); } } CascadeAndClear(center); }
void OnGUI() { //button dimensions float buttonW = Screen.width / 2; float buttonH = Screen.height / 10; GUIStyle style = new GUIStyle(GUI.skin.button); style.fontSize = (int)(buttonH / 2.5f); GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.fontSize = (int)(buttonH / 2.5f); labelStyle.alignment = TextAnchor.UpperCenter; GUI.skin = skin; style.alignment = TextAnchor.UpperCenter; GUI.Box(backWindow, "Game Over!", style); //title the menu style.alignment = TextAnchor.MiddleCenter; GUI.Label(label, "Score: " + GlobalFlags.getScore(), labelStyle); // set the resume button and functionality float halfScreenW = (Screen.width / 2) - buttonW / 2; float halfScreenH = Screen.height / 2 - 80; /*if (GUI.Button(new Rect(halfScreenW,halfScreenH,buttonW,buttonH),"Resume")){ * paused = false; * GlobalFlags.setPaused(false); * }*/ //set the restart button and functionality halfScreenW = (Screen.width / 2) - buttonW / 2; halfScreenH = backWindow.y + Screen.height / 5; if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Restart", style)) { //GlobalFlags.canFire = true; Application.LoadLevel("game"); GlobalFlags.setPaused(false); } //set the back to menu button and functionality halfScreenW = (Screen.width / 2) - buttonW / 2; halfScreenH = Screen.height / 2 + buttonH * 1.2f; if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Back To Menu", style)) { //GlobalFlags.canFire = true; Application.LoadLevel("LevelSelectPreMenu"); GlobalFlags.setPaused(false); } }
void OnGUI() { int height = Screen.height / 15; GUIStyle style = new GUIStyle(GUI.skin.label); style.fontSize = (int)(height / 2); GUI.Label(new Rect(0, 0, Screen.width, height), "Score: " + GlobalFlags.getScore(), style); GUI.Label(new Rect(0, 1 * Screen.height / 15, Screen.width, height), "Multiplier: " + GlobalFlags.getMultiplier(), style); if (!GlobalFlags.infiniteRandomMode) { GUI.Label(new Rect(0, 2 * Screen.height / 15, Screen.width, height), "Queue Bonus: " + GlobalFlags.getQueueBounusTotal(), style); } }
// Update is called once per frame void Update () { if(inEditMode && Input.GetMouseButtonUp(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if(Physics.Raycast(ray,out hitInfo)) { if(hitInfo.collider.gameObject.tag == "gridPanel") { triangleNode node = findOutlineNode(hitInfo.collider.gameObject.transform.parent.gameObject); if(node != null && GetComponent<HandleUI>().IsAdding()) { string c = GetComponent<HandleUI>().GetColourString(); Vector2 realCoords = getRealCoords(node.x, node.y); if(grid[(int)realCoords.x,(int)realCoords.y] == null) { createTriangleOnGrid(node.x, node.y, c); } } } else if(hitInfo.collider.gameObject.tag == "Triangle") { triangleNode node = getNode(hitInfo.collider.gameObject); if(node != null && !GetComponent<HandleUI>().IsAdding() && !(node.x == 0 && node.y == 0)) { Vector2 realCoords = getRealCoords(node.x, node.y); grid[(int)realCoords.x,(int)realCoords.y] = null; Destroy(hitInfo.collider.gameObject); } } } } GameObject[] triangles = GameObject.FindGameObjectsWithTag("Triangle"); GameObject gObject = GameObject.FindGameObjectWithTag("Queue"); queue queueScript = gObject.GetComponent<queue>(); if(GlobalFlags.updateControlPoints) { updateAllAttractionPoints(); GlobalFlags.updateControlPoints = false; //if all triangles are atatched to grid, let the player fire again if(allTrianglesStatic()) { GlobalFlags.trianglesStatic = true; if (queueScript.trisLeftInQueue() == 0 && triangles.Length != 1) { if(GlobalFlags.getMusicVolume() > 0.1f) { music.audio.volume = 0.1f; } music.setSeStartTime(Time.time, 2); music.playSoundEffect("gameOver"); Application.LoadLevel("EndGameMenu"); } } } if(!inEditMode) { GameObject[] queueTriangles = GameObject.FindGameObjectsWithTag("QueueTriangle"); GlobalFlags.setQueueBonusTotal(queueTriangles.Length * GlobalFlags.getQueueBounus()); //decrement delay time if(((elapsedChainDelay > 0 && elapsedChainDelay != float.MaxValue)) && (chainedClusters.Count == 0 || (chainedClusters.Count > 0 && !chainedClusters.Peek().skipDelay))) { elapsedChainDelay -= Time.deltaTime; } else if (elapsedChainDelay != float.MaxValue) { elapsedChainDelay = float.MaxValue; //if clusters left to deal with, color them and chain more if(chainedClusters.Count > 0) { GlobalFlags.incrementMultiplier(); CheckForGreaterTriangle(chainedClusters.Pop()); startChainDelay(); } else if(chainedClusters.Count == 0) { foreach (triangleNode n in grid) { if(n != null && n.delayedDestroy && n.triangleObject.GetComponent<TriangleColour>().GetColour() != Color.black) { Destroy(n.triangleObject); deleteNode(n.x, n.y); } else if(n != null) // if it is black, set to not deleted { n.delayedDestroy = false; } } //Remove any triangles stranded by this action dettatchStranded(); GlobalFlags.updateControlPoints = true; GlobalFlags.resetMultiplier(); } } else { if(triangles.Length == 1) { if(GlobalFlags.getMusicVolume() > 0.1f) { music.audio.volume = 0.1f; } music.setSeStartTime(Time.time, 6); music.playSoundEffect("machoMadness"); if (!GlobalFlags.infiniteRandomMode){ GlobalFlags.setScore(GlobalFlags.getScore() + GlobalFlags.getQueueBounusTotal()); } else { GlobalFlags.setScore(GlobalFlags.getScore()); } Application.LoadLevel("PostGameMenu"); } } } }
// Use this for initialization void Start() { score.text = "Score: " + GlobalFlags.getScore(); title.text = "Level: " + GlobalFlags.getLevel(); }