예제 #1
0
 public void OnClick()
 {
     if (status != MinesTileStatus.HIDDEN)
     {
         return;
     }
     GrdManager.Instance.CallServerScript("mines", "open", new object[] { pos }, (error, data) => {
         MinesResponse result = MiniJSON.Json.GetObject <MinesResponse>(data);
         if (result.win == -1)
         {
             image.enabled = true;
             image.sprite  = Resources.Load <Sprite>("Mines/bom");
             status        = MinesTileStatus.OPENED;
             MinesBetController.Instance.GameOver(result);
         }
         else if (result.win == 0)
         {
             image.enabled = true;
             image.sprite  = Resources.Load <Sprite>("Mines/gem");
             status        = MinesTileStatus.OPENED;
             MinesBetController.Instance.OnGemOpen(result, pos);
         }
         else
         {
             image.enabled = true;
             image.sprite  = Resources.Load <Sprite>("Mines/gem");
             status        = MinesTileStatus.OPENED;
             MinesBetController.Instance.Win(result);
         }
     });
 }
예제 #2
0
 public void StartBet()
 {
     clearBet();
     betAmount    = Int32.Parse(betAmountInput.text);
     numberOfMine = Int32.Parse(noMineInput.text);
     GrdManager.Instance.CallServerScript("mines", "newgame", new object[] { betAmount, numberOfMine }, (error, data) => {
         if (error == 0)
         {
             MinesResponse result = MiniJSON.Json.GetObject <MinesResponse>(data);
             if (result.error == 0)
             {
                 gameTable.InitTable(result, MinesTileStatus.HIDDEN);
                 numberOfMine = result.mines;
                 infoPanel.UpdateMines(numberOfMine);
                 currentGameId = result.gameid;
                 if (betAmount > 0)
                 {
                     GrdManager.Instance.User.balance = GrdManager.Instance.User.balance - (decimal)result.bet;
                     balancePanel.UpdateBalance((double)GrdManager.Instance.User.balance);
                 }
                 OnStartPlay();
             }
         }
         else
         {
             Debug.Log(data);
         }
     });
 }
예제 #3
0
 public void OnGemOpen(MinesResponse response, int pos)
 {
     openedGems++;
     gameTable.RemoveTile(pos);
     currentProfit = response.payout;
     onPlayPanel.SetPayOut(currentProfit);
     onPlayPanel.SetNextProfit(response.nextProfit);
 }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        MinesResponse init = new MinesResponse();

        init.mines      = 1;
        init.minesIndex = new List <int>();
        init.minesIndex.Add(1);
        InitTable(init, MinesTileStatus.DISABLE);
    }
예제 #5
0
 public void Win(MinesResponse result)
 {
     openedGems++;
     currentProfit = result.payout;
     onPlayPanel.SetPayOut(currentProfit);
     GrdManager.Instance.User.balance = GrdManager.Instance.User.balance + (decimal)currentProfit;
     balancePanel.UpdateBalance((double)GrdManager.Instance.User.balance);
     OnEndPlay();
     gameTable.ShowTable(result);
 }
예제 #6
0
 public void Cashout()
 {
     GrdManager.Instance.CallServerScript("mines", "payout", null, (error, data) => {
         MinesResponse result = MiniJSON.Json.GetObject <MinesResponse>(data);
         if (result.error == 0)
         {
             GrdManager.Instance.User.balance = GrdManager.Instance.User.balance + (decimal)result.payout;
             balancePanel.UpdateBalance((double)GrdManager.Instance.User.balance);
             OnEndPlay();
             gameTable.ShowTable(result);
         }
     });
 }
예제 #7
0
 public void ShowTable(MinesResponse result)
 {
     foreach (MinesTile tile in transform.GetComponentsInChildren <MinesTile>())
     {
         if (tile.status == MinesTileStatus.HIDDEN)
         {
             if (result.minesIndex.Contains(tile.pos))
             {
                 tile.ShowTile(MinesTileType.BOM);
             }
             else
             {
                 tile.ShowTile(MinesTileType.GEM);
             }
         }
     }
 }
예제 #8
0
 public void InitTable(MinesResponse response, MinesTileStatus status)
 {
     ClearTable();
     minesIndex = response.minesIndex;
     for (int i = 0; i < 25; i++)
     {
         MinesTile tile = Instantiate(tilePrefab, Vector3.zero, Quaternion.identity).GetComponent <MinesTile>();
         tile.transform.parent = transform;
         tile.status           = status;
         tile.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
         tile.pos = i;
         tiles.Add(i);
         if (minesIndex.Contains(i))
         {
             tile.type = MinesTileType.BOM;
         }
         else
         {
             tile.type = MinesTileType.GEM;
         }
     }
 }
예제 #9
0
 public void GameOver(MinesResponse result)
 {
     OnEndPlay();
     gameTable.ShowTable(result);
 }