Esempio n. 1
0
 void TaskOnClick(GameObject btn)
 {
     if (Enable)
     {
         if (PlayerPrefs.GetInt(RouletteTag.RouletteSelectedCoin) > 0 && (int.Parse(PlayerPrefs.GetString(PlayerDetails.Coin)) >= PlayerPrefs.GetInt(RouletteTag.RouletteSelectedCoin)))
         {
             if (int.Parse(PlayerPrefs.GetString(PlayerDetails.Coin)) > PlayerPrefs.GetInt(RouletteTag.RouletteSelectedCoin))
             {
                 GameObject chip = Instantiate(chipSample);
                 chip.transform.SetParent(btn.transform);
                 chip.transform.position   = btn.transform.position;
                 chip.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                 chip.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(PlayerPrefs.GetString(RouletteTag.RouletteCoinImage));
                 RouletteDelegate.optionClick(btn.transform.name, chip);
                 chipSmaples.Add(chip);
             }
             else
             {
                 print("Not have sufficient coin");
             }
         }
         else
         {
             print("Please select Coin First ");
         }
     }
 }
 public void onChatReceived(ChatEvent eventObj)
 {
     // Debug.Log(eventObj.getSender() + "  :  " + eventObj.getMessage());
     if (WarpClient.GetInstance() != null)
     {
         RouletteDelegate.chatRecived(eventObj.getSender(), eventObj.getMessage());
     }
 }
Esempio n. 3
0
 public void ClearBet()
 {
     if (Enable)
     {
         clearTable();
         RouletteDelegate.removeAllBet();
     }
 }
 public void clearTable()
 {
     BetListHistory.Clear();
     foreach (Bet b in BetList)
     {
         BetListHistory.Add(b);
     }
     this.BetList.Clear();
     RouletteDelegate.removeAllBet();
 }
Esempio n. 5
0
 void clearTableAfterWin()
 {
     BetListHistory.Clear();
     foreach (Bet b in BetList)
     {
         BetListHistory.Add(b);
         //  // Debug.Log ("Add coin to hstory " + b.coin);
     }
     this.BetList.Clear();
     RouletteDelegate.removeAllBet();
 }
Esempio n. 6
0
        void addChips()
        {
            Debug.Log("Add chip");
            GameObject chip = Instantiate(chipSample);

            chip.transform.SetParent(transform);
            chip.transform.position   = this.chipPosition;
            chip.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
            chip.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(PlayerPrefs.GetString(RouletteTag.RouletteCoinImage));
            chipSmaples.Add(chip);
            RouletteDelegate.numberClick(this.SelectedNumber, chip);
        }
Esempio n. 7
0
        void calculatePosition(Vector2 point)
        {
            // Debug.Log("Working is ff "+point);
            side = Side.none;
            if (point.x > sideValue)
            {
                if (this.column != 11)
                {
                    side = Side.left;
                    if (point.y > sideValue)
                    {
                        // Debug.Log("Side.BottomLeft");
                        side = Side.bottom_Left;
                    }
                    else if (point.y < -sideValue)
                    {
                        // Debug.Log("Side.TopLeft");
                        side = Side.top_Left;
                    }
                }
            }
            else if (point.x < -sideValue)
            {
                if (this.column != 0)
                {
                    side = Side.right;
                    // Debug.Log("Side.Right");
                    if (point.y > sideValue)
                    {
                        // Debug.Log("Side.BottomRight");
                        side = Side.bottom_Right;
                    }
                    else if (point.y < -sideValue)
                    {
                        // Debug.Log("Side.TopRight");
                        side = Side.top_Right;
                    }
                }
            }
            else if (point.y > sideValue)
            {
                // Debug.Log("Side.Bottom");
                side = Side.bottom;
            }
            else if (point.y < -sideValue)
            {
                // Debug.Log("Side.Top");
                side = Side.top;
            }

            RouletteDelegate.cellClick(this.row, this.column, side);
        }
        public void onConnectDone(ConnectEvent eventObj)
        {
            Debug.Log("Connection " + eventObj.getResult());
            switch (eventObj.getResult())
            {
            case WarpResponseResultCode.SUCCESS:
            {
                RouletteDelegate.onErrorOccure(ErrorType.RecoverConnection);
                WarpClient.GetInstance().JoinRoomInRange(0, 4, true);
            }
            break;

            case WarpResponseResultCode.CONNECTION_ERROR_RECOVERABLE:
            {
                if (WarpClient.GetInstance() != null)
                {
                    WarpClient.GetInstance().RecoverConnection();
                }
                RouletteDelegate.onErrorOccure(ErrorType.ConnectionTempraryError);
            }
            break;

            case WarpResponseResultCode.SUCCESS_RECOVERED:
            {
                RouletteDelegate.onErrorOccure(ErrorType.RecoverConnection);
            }
            break;

            case WarpResponseResultCode.CONNECTION_ERR:
            {
                RouletteDelegate.onErrorOccure(ErrorType.ConnectionNotFound);
            }
            break;

            case WarpResponseResultCode.AUTH_ERROR:
            {
                RouletteDelegate.onErrorOccure(ErrorType.ConnectionNotFound);
            }
            break;

            case WarpResponseResultCode.BAD_REQUEST:
            {
                RouletteDelegate.onErrorOccure(ErrorType.ConnectionNotFound);
            }
            break;

            default:


                break;
            }
        }
Esempio n. 9
0
        void onWarpChatRecived(string sender, string message)
        {
            JSONNode s = JSON.Parse(message);

            switch (s[RouletteTag.TAG])
            {
            case RouletteTag.MOVE_TO_TABLE:
            {
                onMoveToTable();
                Numbers = JSON.Parse(s["PREVIOUS_NUMBER"]);
                GameID  = s["GAME_ID"];
                ManageHistoryPanels(Numbers);
            }
            break;

            case RouletteTag.START_WHEEL:
            {
                this.winingNumber = int.Parse(s[RouletteTag.VALUE]);
                GameID            = s["GAME_ID"];
            }
            break;

            case RouletteTag.NOT_ENOUGH_COIN:
            {
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    GameController.showToast("Alert! you don't have sufficient coins");
                }
            }
            break;

            case RouletteTag.START_DEAL:
            {
                this.winingNumber = -1;
            }
            break;

            case RouletteTag.BET_ADDED:
            {
                string betID = s["BET_ID"];
                addBetOnTable(betID);
            }
            break;

            case RouletteTag.REMOVE_DONE:
            {
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    // Debug.Log ("Clear Table ");
                    BetListHistory.Clear();
                    foreach (Bet b in BetList)
                    {
                        // Debug.Log ("user coins" + b.coin);

                        GameUser.CurrentUser.Coin = "" + (float.Parse(GameUser.CurrentUser.Coin) + b.coin);
                        PlayerPrefs.SetFloat(RouletteTag.TOTAL_BET, PlayerPrefs.GetInt(RouletteTag.TOTAL_BET) - b.coin);
                        Player_coin.text = "Coin:" + GameUser.CurrentUser.Coin;
                        BetListHistory.Add(b);
                    }
                    this.BetList.Clear();
                    RouletteDelegate.removeAllBet();
                    refreshTable();
                }
            }
            break;

            case RouletteTag.UNDO_DONE:
            {
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    string betID = s["BET_ID"];
                    Bet    b     = getBetbyID(betID);
                    if (b != null)
                    {
                        Destroy(b.coinSample);
                        GameUser.CurrentUser.Coin = "" + (float.Parse(GameUser.CurrentUser.Coin) + b.coin);
                        PlayerPrefs.SetFloat(RouletteTag.TOTAL_BET, PlayerPrefs.GetFloat(RouletteTag.TOTAL_BET) - b.coin);
                        Player_coin.text = "Coin:" + GameUser.CurrentUser.Coin;
                        foreach (int n in b.number)
                        {
                            if (n > 0)
                            {
                                GameObject btn = GameObject.Find("" + n);
                                Color      c   = btn.transform.GetChild(0).GetComponent <Image> ().color;
                                c.a = 0.0f;
                                btn.transform.GetChild(0).GetComponent <Image> ().color = c;
                            }
                        }
                        BetList.Remove(b);
                    }
                    refreshTable();
                }
            }
            break;

            case RouletteTag.MOVE_TO_WHEEL:
            {
                moveToWheel();
                try {
                    HistoryPanel.transform.SetSiblingIndex(0);
                    GameID = s["GAME_ID"];
                } catch (System.Exception ex) {
                }
                isTable = false;
            }
            break;

            case RouletteTag.BETTING_STOP:
            {
                // sendBetttingToServer ();
                GameID = s["GAME_ID"];
            }
            break;

            case RouletteTag.WIN_COIN:
            {
                // Debug.Log (message);
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    if (PlayerPrefs.GetInt("Sound") == 1)
                    {
                        Player.PlayOneShot(WinSound);
                    }
                    winAmount.text = "Win: " + s[RouletteTag.VALUE];
                    RouletteDelegate.winnerFound();
                }
                ServerRequest();
                // Debug.Log ("win found");
            }
            break;

            case RouletteTag.LOSS_COIN:
            {
                ServerRequest();
                // Debug.Log ("loss found");
            }
            break;

            case RouletteTag.BETTING_START:
            {
                GameID         = s["GAME_ID"];
                winAmount.text = "Win: 0";
                clearTableAfterWin();
            }
            break;

            case RouletteTag.TIME:
            {
                try {
                    Timer.text = int.Parse(s[RouletteTag.VALUE]) + ":00";
                    if (PlayerPrefs.GetInt("Sound") == 1)
                    {
                        Player.PlayOneShot(ClockSound);
                    }
                } catch (System.Exception ex) {
                    // Debug.Log (ex.Message);
                }
            }
            break;
            }
        }
        void winningAnimation()
        {
            bool flag = false;
            bool win  = false;

            totalWin  = 0;
            totalLoss = 0;
            ActualWin = 0;
            Debug.Log("Total Bet :" + BetList.Count);
            foreach (Bet b in BetList)
            {
                flag = false;
                foreach (int n in b.number)
                {
                    if (n == this.winingNumber)
                    {
                        flag = true;
                        win  = true;
                    }
                }
                if (flag)
                {
                    totalWin      += (b.coin + b.coin * ((36 / b.number.Count) - 1));
                    ActualWin     += b.coin * ((36 / b.number.Count) - 1);
                    winAmount.text = "Win: " + totalWin;
                    iTween.MoveTo(b.coinSample, winAmount.transform.position, 2.0f);
                }
                else
                {
                    totalLoss += b.coin;
                    foreach (int n in b.number)
                    {
                        if (n > 0)
                        {
                            GameObject btn = GameObject.Find("" + n);
                            Color      c   = btn.GetComponent <Image>().color;
                            c.a = 0.0f;
                            btn.GetComponent <Image>().color = c;
                        }
                    }
                    iTween.MoveTo(b.coinSample, new Vector3(0.0f, -400.0f, 0.0f), 2.0f);
                }
            }
            Debug.Log("sdsds " + PlayerPrefs.GetString(PlayerDetails.Coin));
            PlayerPrefs.SetString(PlayerDetails.Coin, "" + (int.Parse(PlayerPrefs.GetString(PlayerDetails.Coin)) + totalWin));
            Player_coin.text = "Coin:" + PlayerPrefs.GetString(PlayerDetails.Coin);


            if (win)
            {
                win = false;
                if (PlayerPrefs.GetInt("Sound") == 1)
                {
                    Player.PlayOneShot(WinSound);
                }
                RouletteDelegate.winnerFound();
            }
            else
            {
                winAmount.text = "Win: 0";
            }
            Invoke("clearTable", 2.0f);

            this.winingNumber = -1;
        }