Beispiel #1
0
 public void PlayNow()
 {
     //print ("coin is " + coin);
     if (coin > 0)
     {
         GameConstantData.entryFee = coin;
         SceneManager.LoadSceneAsync("GameScene");
     }
     else
     {
         GameConstantData.showToast(transform, "First select the coin to start game.");
     }
 }
 public void play()
 {
     if (coin > 0)
     {
         Debug.Log("USe Coin " + UserController.getInstance.Coin);
         if (coin <= float.Parse(UserController.getInstance.Coin))
         {
             GameConstantData.entryFee = coin;
             SceneManager.LoadSceneAsync("GameScene");
         }
         else
         {
             GameConstantData.showToast(transform, "You do not have sufficient coin.");
         }
     }
     else
     {
         GameConstantData.showToast(transform, "Please select bet amount.");
     }
 }
Beispiel #3
0
        void onRecivedMassage(string sender, string msg)
        {
            // try {

            JSONNode s = JSON.Parse(msg);

            switch (s[ServerTags.TAG])
            {
            case ServerTags.ROOM_INFO:
            {
                JSONNode pl     = s[ServerTags.ROOM_DATA];
                string   player = UserController.getInstance.ID;
                for (int i = 0; i < pl.Count; i++)
                {
                    JSONNode data = pl[i];
                    if (player.Equals(data[ServerTags.PLAYER_ID]))
                    {
                        TakeSeat(data);
                    }
                }
                for (int i = 0; i < pl.Count; i++)
                {
                    JSONNode data = pl[i];
                    if (!player.Equals(data[ServerTags.PLAYER_ID]))
                    {
                        if (!checkUserExist(data[ServerTags.PLAYER_ID]))
                        {
                            GameObject chair = getEmptySeat(int.Parse(data["COLOR"]));
                            if (chair)
                            {
                                chair.SetActive(true);
                                chair.GetComponent <OpponentPlayer> ().empty          = false;
                                chair.GetComponent <OpponentPlayer> ().userName.text  = "" + UppercaseFirst(data[ServerTags.DISPLAY_NAME]);
                                chair.GetComponent <OpponentPlayer> ().total_match    = int.Parse(data[DeviceTags.TOTAL_MATCH]);
                                chair.GetComponent <OpponentPlayer> ().won_match      = int.Parse(data[DeviceTags.WON_MATCH]);
                                chair.GetComponent <OpponentPlayer> ().PlayerImageUrl = "" + data[DeviceTags.PIC];
                                chair.GetComponent <OpponentPlayer> ().DisPlayname    = "" + data[DeviceTags.DISPLAY_NAME];
                                chair.GetComponent <OpponentPlayer> ().Player_ID      = "" + data[ServerTags.PLAYER_ID];
                                chair.GetComponent <OpponentPlayer> ().updateData();
                                chair.GetComponent <OpponentPlayer> ().showGoti();
                                SecurePlayerPrefs.SetString(GetPlayerDetailsTags.OPPONENT_NAME, "" + data[DeviceTags.DISPLAY_NAME]);
                                SecurePlayerPrefs.SetString(GetPlayerDetailsTags.OPPONENT_IMAGE, "" + data[DeviceTags.PIC]);
                            }
                        }
                    }
                }
            }
            break;

            case ServerTags.DRAW_GAME:
            {
                drawGame.SetActive(true);
            }
            break;

            case ServerTags.WINNER_PLAYER:
            {
                string player_name = UserController.getInstance.ID;

                JSONNode node      = s["RESULT"];
                string   Wincoin   = s["VALUE"];
                string   playerId1 = "";
                // Debug.Log ("result is " + node.Count);
                for (int i = 0; i < node.Count; i++)
                {
                    JSONNode node1    = node[i];
                    string   playerId = node1["PLAYER_ID"];
                    playerId1 = playerId;
                    string position     = node1["POSITION"];
                    string DISPLAY_NAME = node1[ServerTags.DISPLAY_NAME];
                    string pic          = node1["PIC"];
                    WinnerPanel.SetActive(true);
                    //print ("playerId " + playerId + " position " + position);
                    if (position.Equals("1"))
                    {
                        if (playerId.Equals(player_name))
                        {
                            WinnerPanel.transform.Find("panel").Find("WinText").gameObject.SetActive(true);
                            WinnerPanel.GetComponent <winnerPanelScript> ().updateName(DISPLAY_NAME, Wincoin, true, pic);
                        }
                        else
                        {
                            WinnerPanel.transform.Find("panel").Find("WinText").gameObject.SetActive(false);
                            WinnerPanel.GetComponent <winnerPanelScript> ().updateName(DISPLAY_NAME, Wincoin, false, pic);
                        }
                    }
                    else
                    {
                        GameObject newCell = Instantiate(cell);
                        newCell.transform.SetParent(Container.transform);
                        newCell.transform.localScale = new Vector3(1, 1, 1);
                        newCell.GetComponent <LooserCell> ().updateLoserCell(DISPLAY_NAME, position);
                    }
                }
                if (player_name.Equals(playerId1))
                {
                    GameDelegate.StartClappingSound();
                    WinnerAnimation.SetActive(true);
                    WinnerAnimation.GetComponent <ParticleSystem> ().Clear();
                    WinnerAnimation.GetComponent <ParticleSystem> ().Play();
                }
            }
            break;

            case ServerTags.GOTI_WIN:
            {
                string player = UserController.getInstance.ID;
                if (!player.Equals(s[ServerTags.PLAYER_ID]))
                {
                    GameDelegate.StartClappingSound();
                    GotiWinAnimation.SetActive(true);
                    GotiWinAnimation.GetComponent <ParticleSystem> ().Clear();
                    GotiWinAnimation.GetComponent <ParticleSystem> ().Play();
                    StartCoroutine(StopGotiAnimation());
                }
            }
            break;

            case ServerTags.START_DEAL:
            {
                //print ("START_DEAL working");

                CreatePrivateTatble.SetActive(false);
                JoinGamePanel.SetActive(false);
                loadingPanel.SetActive(false);
                CurrentPlayer.GetComponent <PlayerScript> ().EnableChatBtn();

                WinnerPanel.SetActive(false);
                WinnerAnimation.SetActive(false);
                WinnerAnimation.GetComponent <ParticleSystem> ().Clear();
            }
            break;

            case ServerTags.ROOM_PRICE:
            {
                try {
                    string player = UserController.getInstance.ID;
                    if (player.Equals(s[ServerTags.PLAYER_ID]))
                    {
                        int fee = int.Parse(s[ServerTags.VALUES]);
                        if (fee > int.Parse(UserController.getInstance.Coin))
                        {
                            CoinValidationPanel.SetActive(true);
                        }
                    }
                } catch (System.Exception ex) {
                    // Debug.Log (ex.Message);
                }
            }
            break;

            case ServerTags.RESET_GOTI:
            {
                for (int i = 1; i < 72; i++)
                {
                    onMoveGoti(i);
                }
            }
            break;

            case ServerTags.TURN_MISS:
            {
                if (int.Parse(s[ServerTags.VALUES]) != 0)
                {
                    string player = UserController.getInstance.ID;
                    if (player.Equals(s[ServerTags.PLAYER_ID]))
                    {
                        string message = s["ROOM_MESSAGE"];
                        GameConstantData.showToast(transform, message);
                        CurrentPlayer.GetComponent <PlayerScript> ().MissTurn(s[ServerTags.PLAYER_ID]);
                    }
                    else
                    {
                        foreach (GameObject chair in OpponentArray)
                        {
                            chair.GetComponent <OpponentPlayer> ().MissTurn(s[ServerTags.PLAYER_ID]);
                        }
                    }
                }
                else
                {
                }
            }
            break;

            default:
                break;
            }
            // } catch (System.Exception ex) {
            //   Debug.Log (ex.Message);
            // }
        }