private void SetStats() { if (gripStat) { var gripModel = transform.GetChild(0); GripHelper.SetColour(gripModel, gripStat); } }
// Start is called before the first frame update void Start() { GripHelper helper = GameObject.Find("Big Panel").GetComponent <GripHelper>(); hasMine = (Random.value < helper.mineWeight); // 15% de probabilidad //LoadTexture(1); int x = (int)this.transform.position.x; // Casting int y = (int)this.transform.parent.transform.position.y; // Casting GripHelper.cells[x, y] = this; }
private void OnMouseUpAsButton() { if (hasMine) { // Game Over GripHelper.UncoverAllTheMines(); Debug.Log("You lose!!"); Invoke("ReturnToMainMenu", 3f); } else { // Cambiar la textura e la celda int x = (int)this.transform.position.x; int y = (int)this.transform.parent.transform.position.y; LoadTexture(GripHelper.CountAdjacentMines(x, y)); // Descubrir toda el área sin minas alrededor de la celda abierta GripHelper.FloodFillUncover(x, y, new bool[GripHelper.w, GripHelper.h]); // Comprobar si el juego ha terminado if (GripHelper.HasTheGameEnded()) { Debug.Log("Fin de la partida: You Win!!"); Invoke("ReturnToMainMenu", 3f); } } }