示例#1
0
    public static bool matchOnGoing = false; //Sync

    public static void SetOtherBigChip(_PlayerPokerActor exceptThis)
    {
        List <_PlayerPokerActor> sortedPlayer = new List <_PlayerPokerActor> (turnManager.currentPlayers.OrderByDescending(x => x.myMoney));

        sortedPlayer.Remove(exceptThis);

        long mine = exceptThis.myMoney + exceptThis.chipsBet;

        for (int x = sortedPlayer.Count - 1; x >= 0; x--)
        {
            if (sortedPlayer[x].isFolded)
            {
                sortedPlayer.RemoveAt(x);
            }
        }

        if (sortedPlayer.Count > 0)
        {
            biggestBet = sortedPlayer[0].myMoney + sortedPlayer[0].chipsBet;

            if (biggestBet > mine || biggestBet == 0)
            {
                biggestBet = mine;
            }
        }
        else
        {
            biggestBet = mine;
        }

        ////debug.Log("Set Biggest Bet : " + biggestBet);
    }
示例#2
0
    private void RPC_StartInitialize(bool _isBot)
    {
        PhotonPlayer botPhoton = null;

        isMine = photonView.isMine;
        isBot  = _isBot;

        if (isBot)
        {
            botPhoton = PhotonTexasPokerManager.instance.GetBotwithIndex(IDX_READONLY);// bots[PhotonTexasPokerManager.instance.bots.Count - 1];
        }
        if (botPhoton == null && isBot)
        {
            Debug.Log("GA DAPET BOT PHOTON BOS");
        }

        int ownerSlotIndex = PhotonUtility.GetPlayerProperties <int>(isBot ? botPhoton : this.photonView.owner, PhotonEnums.Player.SlotIndex);

        uiPlayerPoker = _PokerGameManager.instance.stockPlayers[ownerSlotIndex];
        uiPlayerPoker.gameObject.SetActive(true);
        uiPlayerPoker._myParasitePlayer = this;
        uiPlayerPoker.myPlayer          = isBot ? botPhoton : this.photonView.owner;
        nickname = isBot ? botPhoton.NickName : this.photonView.owner.NickName;

        transform.SetParent(uiPlayerPoker.transform);
        transform.localScale    = new Vector3(1, 1, 1);
        transform.localPosition = new Vector3(0, 0, 0);

        uiPlayerPoker.StartInitialize(ownerSlotIndex, isMine, isBot);

        if (isMine)
        {
            PhotonUtility.SetPlayerPropertiesArray(uiPlayerPoker.myPlayer, new string[] { PhotonEnums.Player.ReadyInitialized, PhotonEnums.Player.NextRoundIn }, new object[] { true, true });
        }
    }
示例#3
0
    private void PrepareEndPoker()
    {
        int[] playersIndex = PhotonTexasPokerManager.instance.GetIndexesInMatch();

        for (int i = 0; i < ApiManager.instance.pokerPlayers.Length; i++)
        {
            ApiBridge.PokerPlayer p = ApiManager.instance.pokerPlayers[i];
            for (int j = 0; j < playersIndex.Length; j++)
            {
                if (playersIndex[j] >= 0)
                {
                    _PlayerPokerActor actor = stockPlayers[playersIndex[j]];
                    if (p.player_id == int.Parse(actor.myPlayer.NickName))
                    {
                        //totalBet >= 0 => lose | coin_won = totalBet * (-1) <= 0 | coin_bet = coin_won * (-1) = totalBet >= 0
                        //totalBet < 0 => win | coin_won = totalBet * (-1) > 0 | coin_bet = totalBet / (-0.9) > 0
                        if (actor.totalBet >= 0)
                        {
                            p.End(actor.totalBet, actor.totalBet * (-1), actor.myMoney);
                        }
                        else
                        {
                            p.End(Convert.ToInt64(actor.totalBet / (-0.9f)), actor.totalBet * (-1), actor.myMoney);
                        }
                    }
                }
            }
        }

        if (PhotonNetwork.isMasterClient)
        {
            ApiManager.instance.EndPoker(PokerData.poker_round_id);
        }
    }
示例#4
0
        public void NextTurnTogether(int _turnNow, int _nextTurn)
        {
            SetupSyncTurn(_turnNow, _nextTurn);

            turnNow = nextTurn;
            UpdatePlayerNextTurn();

            turnNow.MyTurn();
        }
示例#5
0
    public void CleanWithHolyWater()
    {
        transform.SetParent(_PokerGameManager.instance.transform);
        transform.localScale    = new Vector3(1, 1, 1);
        transform.localPosition = new Vector3(0, 0, 0);

        uiPlayerPoker = null;
        isBot         = false;
        isMine        = false;
    }
示例#6
0
        public void UpdatePlayerNextTurn(_PlayerPokerActor _player = null)
        {
            if (_player == null)
            {
                _player = turnNow;
            }

            int val = currentPlayers.IndexOf(_player);

            //debug.LogError("Count Player " + currentPlayers.Count);
            //debug.LogError("Current Index " +val);
            val = GetIndexValueRound(val, currentPlayers.Count);

            nextTurn = currentPlayers[val];
        }
示例#7
0
        public void StartFirstTurn()
        {
            indexLastDealer = GetIndexValueRound(indexLastDealer, matchPlayers.Count);

            if (PhotonNetwork.isMasterClient)
            {
                PhotonUtility.SetRoomProperties(PhotonEnums.Room.LastIndexDealer, indexLastDealer);
            }

            phaseTurn = 0;

            instance.AddPot(0, 0, currentPlayers.ToArray());

            if (currentPlayers.Count > 2)
            {
                lastBet = startBet;

                currentPlayers[indexLastDealer].SetMyRole(_GameRoleEnums.Dealer);
                instance.chipD.SetActive(true);
                LeanTween.move(instance.chipD, currentPlayers[indexLastDealer].chipsD, 1f);

                currentPlayers[GetIndexValueRound(indexLastDealer, matchPlayers.Count)].SetMyRole(_GameRoleEnums.SmallBlind);
                currentPlayers[GetIndexValueRound(indexLastDealer + 1, matchPlayers.Count)].SetMyRole(_GameRoleEnums.BigBlind);

                turnNow = currentPlayers[GetIndexValueRound(indexLastDealer + 1, matchPlayers.Count)];
            }
            else if (currentPlayers.Count == 2)
            {
                lastBet = startBet;
                instance.chipD.SetActive(false);
                currentPlayers[indexLastDealer].SetMyRole(_GameRoleEnums.SmallBlind);
                currentPlayers[GetIndexValueRound(indexLastDealer, matchPlayers.Count)].SetMyRole(_GameRoleEnums.BigBlind);

                turnNow = currentPlayers[GetIndexValueRound(indexLastDealer, matchPlayers.Count)];
            }

            UpdatePlayerNextTurn();  //To Initialize the Next Turn Player before Start Game

            if (PhotonUtility.GetPlayerProperties <bool> (PhotonNetwork.player, PhotonEnums.Player.Active))
            {
                if (!nextTurn.isMine || nextTurn.isBot)
                {
                    instance.unsortedPlayers[0].panelPreAction.SetActive(true);
                }
            }

            StartNextTurn();
        }
示例#8
0
    public void CatchUpPot(int idx, long _money, string[] slotsOwner)
    {
        _PlayerPokerActor[] _owners = new _PlayerPokerActor[slotsOwner.Length];

        for (int a = 0; a < _owners.Length; a++)
        {
            _owners[a] = instance.stockPlayers[int.Parse(slotsOwner[a])];
        }

        GameObject o = Instantiate(objPot, positionPot[idx]);

        o.transform.localPosition = Vector3.zero;
        potOnTable.Add(o.GetComponent <_PotObject> ());

        potOnTable[potOnTable.Count - 1].SetPotOwner(_owners);
        potOnTable[potOnTable.Count - 1].SetPotValue(_money);

        ShowChips();
    }
示例#9
0
    public void SetupMenuPoker(Transform _to, int _target)
    {
        _gameRunning = GameType.TexasPoker;
        gameObject.SetActive(true);

        transform.position = _to.position;
        targetParasite     = _target;

        _PlayerPokerActor targetActor = _PokerGameManager.instance.stockParasite[_target].uiPlayerPoker;

        ExitGames.Client.Photon.Hashtable playerProperties = targetActor.myPlayer.CustomProperties;

        txtName.text      = targetActor._myName;
        txtMoney.text     = targetActor.txtMyMoney.text;
        icCurrency.sprite = targetActor.imgBetAmount[0].sprite;
        //icGender.sprite = (int)playerProperties[PhotonEnums.Player.Gender] == 1 ? HomeSceneManager.Instance.iconMale : HomeSceneManager.Instance.iconFemale;

        txtWinRate.text = (int)playerProperties[PhotonEnums.Player.WinRate] + "%";
        txtPlayed.text  = (int)playerProperties[PhotonEnums.Player.TotalPlayed] + "";
        txtLevel.text   = (int)playerProperties[PhotonEnums.Player.LevelChar] + "";
    }
示例#10
0
 public void ShowPanelThrow(Transform _to, _PlayerPokerActor _target)
 {
     //boxThrow.SetupMenuPoker(_to, _target._myParasitePlayer.IDX_READONLY);
 }
示例#11
0
 public void SetupSyncTurn(int _turnNow, int _nextTurn)
 {
     turnNow  = instance.stockPlayers[_turnNow];
     nextTurn = instance.stockPlayers[_nextTurn];
 }
示例#12
0
 public bool ThisIsNextPlayer(_PlayerPokerActor _player)
 {
     return(_player == nextTurn);
 }
示例#13
0
    IEnumerator RoutineCalculatePot()
    {
        List <_PlayerPokerActor> pSort = new List <_PlayerPokerActor> (turnManager.currentPlayers.OrderBy(x => x.chipsBet));

        //debug.Log("Jumlah player Sort : " + pSort.Count);

        while (pSort.Count > 0)
        {
            long totalBet = 0;
            long batasBet = 0;

            for (int x = pSort.Count - 1; x >= 0; x--)
            {
                if (pSort[x].isFolded)
                {
                    totalBet         += pSort[x].chipsBet;
                    pSort[x].chipsBet = 0;
                    pSort.RemoveAt(x);
                }
            }

            batasBet = pSort[0].chipsBet;

            if (pSort.Count > 0)
            {
                for (int x = pSort.Count - 1; x >= 0; x--)
                {
                    totalBet          += batasBet;
                    pSort[x].chipsBet -= batasBet;

                    if (pSort[x].chipsBet <= 0)
                    {
                        pSort.RemoveAt(x);
                    }
                }
            }

            AddMoneyToPot(totalBet);

            if (pSort.Count > 0)
            {
                AddPot(lastPotIndex + 1, 0, pSort.ToArray());
            }

            yield return(null);
        }

        _PlayerPokerActor _p;
        _PlayerPokerActor _allInPlayer = null;

        for (int x = turnManager.currentPlayers.Count - 1; x >= 0; x--)
        {
            _p = turnManager.currentPlayers[x];

            if (_p.isAllIn || _p.isFolded)
            {
                if (turnManager.ThisIsNextPlayer(_p))
                {
                    turnManager.UpdatePlayerNextTurn(_p);
                }

                if (_p.isAllIn && _allInPlayer == null)
                {
                    _allInPlayer = _p;
                }

                turnManager.currentPlayers.RemoveAt(x);
            }
        }

        if (turnManager.currentPlayers.Count > 1)
        {
            if (_allInPlayer != null)
            {
                if (potOnTable[lastPotIndex].owner.Contains(_allInPlayer))
                {
                    AddPot(lastPotIndex + 1, 0, turnManager.currentPlayers.ToArray());
                }
            }

            turnManager.OpenCard();
        }
        else
        {
            int jumlahFolded = 0;

            for (int x = 0; x < turnManager.matchPlayers.Count; x++) //untuk ngitung jumlah player Fold
            {
                if (turnManager.matchPlayers[x].isFolded)
                {
                    jumlahFolded++;
                }
            }

            if (jumlahFolded >= turnManager.matchPlayers.Count - 1)
            {
                PhotonTexasPokerManager.instance.TakeYourPotTogether(true);  // Go To Take Our Pot Together
            }
            else
            {
                turnManager.OpenAllCard();
            }
        }
    }