public void CreateNewGrid() { gridControl = null; foreach (Transform child in GameObject.Find("Grid").transform) { Destroy(child.gameObject); } if (difficulty != 0) { float temp_2 = 2f / 15f; switch (difficulty) { case 1: temp_2 = 0.08f; break; case 2: temp_2 = 0.13f; break; case 3: temp_2 = 0.16f; break; case 4: temp_2 = 0.2f; break; } float temp_1 = currentGridSize[0] * currentGridSize[1]; float temp_3 = temp_1 * temp_2; Debug.Log($"Temp_1 : {temp_1} Temp_2 : {temp_2} Temp_3 : {temp_3}"); bombs = Mathf.RoundToInt(temp_3); } gridControl = new GridControl(); gridControl.CreateGrid(currentGridSize[0], currentGridSize[1], bombs, GridGameObjects); CenterCamera(currentGridSize[0], currentGridSize[1]); }
// Start is called before the first frame update void Start() { DontDestroyOnLoad(this.gameObject); DontDestroyOnLoad(GameObject.Find("SoundControler")); if (SceneManager.GetActiveScene().name == "Game") { if (admin) { GameObject.Find("RegenButton").GetComponent <Button>().onClick.AddListener(delegate { CreateNewGrid(); }); } else { Destroy(GameObject.Find("RegenButton").GetComponent <Button>()); } GridGameObjects = Resources.Load <GameObject>("Prefabs/GridObject_Template_new"); if (GridGameObjects == null) { Debug.LogError("GridGameObjects Is NULL!"); } else { Debug.Log("GridGameObjects was succesfully loaded"); } if (difficulty != 0) { float temp_2 = 2f / 15f; switch (difficulty) { case 1: temp_2 = 0.10f; break; case 2: temp_2 = 0.15f; break; case 3: temp_2 = 0.20f; break; case 4: temp_2 = 0.25f; break; } float temp_1 = currentGridSize[0] * currentGridSize[1]; float temp_3 = temp_1 * temp_2; Debug.Log($"Temp_1 : {temp_1} Temp_2 : {temp_2} Temp_3 : {temp_3}"); bombs = Mathf.RoundToInt(temp_3); if ((temp_1 % 2 == 0 && bombs % 2 == 1) || (temp_1 % 2 == 1 && bombs % 2 == 0)) { bombs++; } } gridControl = new GridControl(); gridControl.CreateGrid(currentGridSize[0], currentGridSize[1], bombs, GridGameObjects); CenterCamera(currentGridSize[0], currentGridSize[1]); } }