示例#1
0
    public void InvestigateElement()
    {
        touches.Vibrate();

        if (this.bIsMine)
        {
            // Show all mines
            MineGrid.uncoverMines();

            // Game Over
            ms.bHasLost = true;
        }
        else
        {
            // Show adjacent mine number
            int x = (int)transform.position.x;
            int y = (int)transform.position.y;
            LoadTexture(MineGrid.adjacentMines(x, y));

            // Uncover area w/out mines
            MineGrid.FFuncover(x, y, new bool[MineGrid.w, MineGrid.h]);

            // Find out if the game was won
            if (MineGrid.bIsFinished())
            {
                ms.bHasWon = true;
            }
        }

        touches.bAaction = false;
    }
示例#2
0
 void OnMouseOver()
 {
     if (MineGrid.gameOver == false)
     {
         if (Input.GetMouseButtonDown(0))
         {
             if (!isFlagged)
             {
                 if (isMined)
                 {
                     MineGrid.UncoverMines();
                     mineGrid.LoseGame();
                     //losecardref.SetActive(true);
                 }
                 else
                 {
                     isClicked = true;
                     int x = (int)transform.position.x;
                     int y = (int)transform.position.y;
                     LoadTexture(MineGrid.AdjacentMines(x, y));
                     MineGrid.FFuncover(x, y, new bool[MineGrid.dimension.x, MineGrid.dimension.y]);
                     MineGrid.FloodedtoClicked();
                     if (MineGrid.IsFinished())
                     {
                         mineGrid.FinishGame();
                     }
                 }
             }
         }
         if (Input.GetMouseButtonDown(1))
         {
             if (!isClicked)
             {
                 if (!isFlagged)
                 {
                     FlagTile();
                     if (MineGrid.IsFinished())
                     {
                         mineGrid.FinishGame();
                     }
                 }
                 else
                 {
                     UnFlagTile();
                 }
             }
         }
     }
 }