private IEnumerator RearrangeGroups(List <Vector2> groupList) { if (groupList.Count > 0) { for (int i = 0; i < groupList.Count; i++) { Utility.guiManager.mapGUI.getHex(groupList[i]).EnableStar(true); } yield return(new WaitForSeconds(2f)); for (int i = 0; i < groupList.Count; i++) { Utility.guiManager.mapGUI.getHex(groupList[i]).EnableStar(false); } int score = Utility.gameManager.getScore(); int perHexaScore = Utility.guiManager.mapGUI.perHexaScore; int scoreIncrease = groupList.Count * perHexaScore; Utility.gameManager.IncreaseScore(scoreIncrease); int newScore = score + scoreIncrease; int everyXPointsForBomb = Utility.guiManager.mapGUI.everyXPointsForBomb; int bombCount = newScore / everyXPointsForBomb - score / everyXPointsForBomb; List <Color> availableColors = Utility.guiManager.mapGUI.getAvailableColors(); for (int i = 0; i < groupList.Count; i++) { for (int j = (int)groupList[i].y; j < Utility.guiManager.mapGUI.gridY - 1; j++) { HexGUI hexGUI1 = Utility.guiManager.mapGUI.getHex(new Vector2(groupList[i].x, j)); HexGUI hexGUI2 = Utility.guiManager.mapGUI.getHex(new Vector2(groupList[i].x, j + 1)); hexGUI1.ChangeHexa(hexGUI2.getHexData()); } Color newColor = (Color)Utility.GetRandomNumber(0, availableColors.Count); HexGUI hexGUI = Utility.guiManager.mapGUI.getHex(new Vector2(groupList[i].x, Utility.guiManager.mapGUI.gridY - 1)); hexGUI.SetColor(newColor); if (bombCount > 0) { bombCount--; hexGUI.SetBomb(true, Utility.guiManager.mapGUI.bombCounter); } else { hexGUI.SetBomb(false); } } } }
public void Initialize() { ClearContent(); hexs = new List <List <HexGUI> >(); posCoordinateMap = new Dictionary <Vector2, Vector2>(); coordinatePosMap = new Dictionary <Vector2, Vector2>(); for (int y = 0; y < gridY; y++) { List <HexGUI> rowItem = new List <HexGUI>(); hexs.Add(rowItem); for (int x = 0; x < gridX; x++) { Vector2 coordinate = new Vector2(x, y); GameObject go = Instantiate(hexPrefab, hexContent); go.name = "Hexa_" + x + "_" + y; HexGUI hexGUI = go.GetComponent <HexGUI>(); hexGUI.Initialize(getStartingColor(coordinate)); float xDiff = xDiffOffset * x; float yDiff = yDiffOffset * y; if (x % 2 == 1) { yDiff += yDiffOddOffset; } Vector2 position = new Vector2(xDiff, yDiff); go.transform.localPosition = position; rowItem.Add(hexGUI); posCoordinateMap.Add(go.transform.position, coordinate); coordinatePosMap.Add(coordinate, go.transform.position); } } }