Example #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);
         }
     });
 }
Example #2
0
    public void ShowTile(MinesTileType type)
    {
        switch (type)
        {
        case MinesTileType.BOM:
            image.enabled = true;
            image.sprite  = Resources.Load <Sprite>("Mines/bom");
            image.rectTransform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            image.color = new Color(image.color.r, image.color.g, image.color.b, 0.35f);
            status      = MinesTileStatus.OPENED;
            break;

        case MinesTileType.GEM:
            image.enabled = true;
            image.sprite  = Resources.Load <Sprite>("Mines/gem");
            image.rectTransform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            image.color = new Color(image.color.r, image.color.g, image.color.b, 0.35f);
            status      = MinesTileStatus.OPENED;
            break;
        }
    }
Example #3
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;
         }
     }
 }