Exemplo n.º 1
0
    public void Activating()
    {
        if (Activated == false)
        {
            Activated = true;
            if (Creator.Bomb_Cells.Length == 0)
            {
                Creator.Bomb_Creation(Neighbors, PlayerPrefs.GetInt("Bomb Quantity"));
            }

            Self_Bomb_Check();

            Bombs_Nearby = Neighbor_Bomb_Check();

            if (Creator.Game_Active == true)
            {
                if (Is_Bomb == true)
                {
                    this.GetComponent <UnityEngine.UI.RawImage>().color = Color.red;
                    GameObject.Find("Canvas").GetComponent <GameMaster>().Game_Over("Death");
                    Bomb.SetActive(true);
                }
                else
                {
                    this.GetComponent <UnityEngine.UI.RawImage>().color = Color.white;
                    if (Bombs_Nearby == 0)                       //Expose 0 value Neighbors
                    {
                        Bomb_Quantity.text = "";
                        for (int i = 1; i <= 8; i++)
                        {
                            if (GameObject.Find(Neighbors[i]) == true && GameObject.Find(Neighbors[i]).GetComponent <Cell>().Activated == false)
                            {
                                GameObject.Find(Neighbors[i]).GetComponent <Cell>().Activating();
                            }
                        }
                    }
                    else
                    {
                        Bomb_Quantity.text = Bombs_Nearby.ToString();
                    }
                }
            }
            else
            {
                if (Flagged && Is_Bomb == false)
                {
                    this.GetComponent <UnityEngine.UI.RawImage>().color = Color.white;
                    Flag.SetActive(false);
                    Bomb.SetActive(true);
                    Red_X.SetActive(true);
                }
                else if (Is_Bomb == true && Flagged == false)
                {
                    this.GetComponent <UnityEngine.UI.RawImage>().color = Color.white;
                    Bomb.SetActive(true);
                }
            }
            Creator.Cells_Activated++;
            Destroy(this.GetComponent <UnityEngine.UI.Button>());
        }
    }