void UpdateScore() { int[] nodesInt = new int[nodesCount.Length]; int[] clustersInt = new int[clustersCount.Length]; // Count nodes per player foreach (GameObject candidateNode in btns) { int currentOwner = candidateNode.GetComponent <Node> ().owner; if (currentOwner != -1) { nodesInt[currentOwner] = nodesInt[currentOwner] + 1; } } // Update nodes count for (int i = 0; i < nodesInt.Length; i++) { string nodeText = " nodes"; if (nodesInt[i] <= 1) { nodeText = " node"; } nodesCount[i].GetComponent <Text>().text = nodesInt[i].ToString() + nodeText; } // Progress bars for (int i = 0; i < progressBars.Length; i++) { //int parentHeight = progressBars[i].GetComponentInParent<Transform>().height; float percent = (float)nodesInt[i] / (float)btns.Count; progressBars[i].GetComponent <Slider>().value = percent; } // Clusters score for (int i = 0; i < GameModel.players.Count; i++) { clustersInt[i] = TilesHelper.CountClusters(i, btns); string clusterText = " clusters"; if (clustersInt[i] <= 1) { clusterText = " cluster"; } clustersCount[i].GetComponent <Text>().text = clustersInt[i].ToString() + clusterText; } if (GameModel.IS_HUMAN) { playerScore = nodesInt [0] * clustersInt [0]; } else { // Score vs. AI depends on the difficulty playerScore = nodesInt [0] * clustersInt [0] * (GameModel.AI_DIFFICULTY + 1); } }