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); } }); }
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); } }); }
public void OnGemOpen(MinesResponse response, int pos) { openedGems++; gameTable.RemoveTile(pos); currentProfit = response.payout; onPlayPanel.SetPayOut(currentProfit); onPlayPanel.SetNextProfit(response.nextProfit); }
// 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); }
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); }
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); } }); }
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); } } } }
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; } } }
public void GameOver(MinesResponse result) { OnEndPlay(); gameTable.ShowTable(result); }