public void OnSwitchTable(bool isRejoin = false) { if (GlobalVariables.gameType == GameType.TexasPoker) { if (PhotonNetwork.room != null || PhotonTexasPokerManager.instance.GetNumActivePlayers() <= 1) { if (!PhotonUtility.GetPlayerProperties <bool> (PhotonNetwork.player, PhotonEnums.Player.Active)) { GlobalVariables.bSwitchTableNextRound = false; PhotonTexasPokerManager.instance.ImLeaving(); //StartCoroutine(_LoadSwitchTable()); LoadSwitchTable(); } else if (PhotonTexasPokerManager.instance != null && PhotonTexasPokerManager.instance.GetNumActivePlayers() > 1 && !isRejoin) { MessageManager.instance.Show(gameObject, "Apakah kamu yakin ingin pindah ke meja lain?", ButtonMode.OK_CANCEL, 2); } else { GlobalVariables.bSwitchTableNextRound = false; PhotonTexasPokerManager.instance.ImLeaving(); //StartCoroutine(_LoadSwitchTable()); LoadSwitchTable(); } } } //Hide(); }
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 }); } }
public int Compare(PhotonPlayer x, PhotonPlayer y) { PhotonPlayer playerX = x; PhotonPlayer playerY = y; //Sort by descending scores order int scoreX = PhotonUtility.GetPlayerProperties <int>(playerX, PhotonEnums.Player.SlotIndex); int scoreY = PhotonUtility.GetPlayerProperties <int>(playerY, PhotonEnums.Player.SlotIndex); return((scoreX).CompareTo(scoreY)); }
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(); }
public void StartRound() { txtTimer.text = "0"; if (PhotonUtility.GetPlayerProperties <bool> (PhotonNetwork.player, PhotonEnums.Player.ReadyInitialized)) { PhotonUtility.SetPlayerPropertiesArray(PhotonNetwork.player, new string[] { PhotonEnums.Player.Active, PhotonEnums.Player.NextRoundIn }, new object[] { true, true }); } else { PhotonUtility.SetPlayerPropertiesArray(PhotonNetwork.player, new string[] { PhotonEnums.Player.Active, PhotonEnums.Player.NextRoundIn }, new object[] { false, false }); } if (crStartRound != null) { StopCoroutine(crStartRound); } crStartRound = StartCoroutine(_StartTimer(15f)); }
private void PrepareStartSicbo() { apiPlayers = null; for (int i = 0; i < unsortedPlayers.Length; i++) { if (unsortedPlayers[i].photonPlayer != null) { long lCoin = PhotonUtility.GetPlayerProperties <long> (unsortedPlayers[i].photonPlayer, PhotonEnums.Player.Money); unsortedPlayers[i].textCoinValue.text = lCoin.toShortCurrency(); string strBets = PhotonUtility.GetPlayerProperties <string> (unsortedPlayers[i].photonPlayer, PhotonEnums.Player.SICBO_BETS); if (strBets.Length != 0 && strBets != string.Empty) { AppendPlayers(FormatBets(strBets)); } } } }
public void Show() { Logger.E("a"); gameObject.SetActive(true); //Only call it for one time since show is sending two time to the round restart if (PhotonNetwork.isMasterClient) { if (GlobalVariables.gameType == GameType.TexasPoker) { SetupPoker(); } } //Don't allow any other players to be in this round PhotonPlayer[] _bots = PhotonTexasPokerManager.instance.bots.ToArray(); foreach (PhotonPlayer bot in _bots) { if (PhotonUtility.GetPlayerProperties <bool>(bot, PhotonEnums.Player.ReadyInitialized)) { PhotonUtility.SetPlayerPropertiesArray(bot, new string[] { PhotonEnums.Player.Active, PhotonEnums.Player.NextRoundIn }, new object[] { true, true }); } else { PhotonUtility.SetPlayerPropertiesArray(bot, new string[] { PhotonEnums.Player.Active, PhotonEnums.Player.NextRoundIn }, new object[] { false, false }); } } //Reset bet money to calculate giftpoints GlobalVariables.playerBetMoney = 0; if (PhotonUtility.GetPlayerProperties <bool>(PhotonNetwork.player, PhotonEnums.Player.ReadyInitialized)) { PhotonUtility.SetPlayerPropertiesArray(PhotonNetwork.player, new string[] { PhotonEnums.Player.Active, PhotonEnums.Player.NextRoundIn }, new object[] { true, true }); } else { PhotonUtility.SetPlayerPropertiesArray(PhotonNetwork.player, new string[] { PhotonEnums.Player.Active, PhotonEnums.Player.NextRoundIn }, new object[] { false, false }); } if (GlobalVariables.gameType == GameType.TexasPoker) { StartCoroutine(StartRoundTimerPoker()); } }
public void SyncCurrentMatchPlayers(string[] sCp) //, string[] sMp { currentPlayers.Clear(); matchPlayers.Clear(); foreach (_PlayerPokerActor pA in instance.stockPlayers) { bool bActive = PhotonUtility.GetPlayerProperties <bool> (pA.myPlayer, PhotonEnums.Player.Active); if (bActive) { matchPlayers.Add(pA); } } for (int a = 0; a < sCp.Length; a++) { currentPlayers.Add(instance.stockPlayers[int.Parse(sCp[a])]); } }
private void UpdateMoneyUI() { for (int i = 0; i < unsortedPlayers.Length; i++) { if (unsortedPlayers[i].photonPlayer != null) { long lCoin = PhotonUtility.GetPlayerProperties <long> (unsortedPlayers[i].photonPlayer, PhotonEnums.Player.Money); if (unsortedPlayers[i].photonPlayer.NickName == PlayerData.id.ToString()) { long lCoinDiff = lCoin - PlayerData.owned_coin; unsortedPlayers[i].SetTextCoinDiff(lCoinDiff); PlayerData.owned_coin = lCoin; _SceneManager.instance.UpdateAllCoinAndCoupon(); } unsortedPlayers[i].textCoinValue.text = lCoin.toShortCurrency(); } } }
public void UpdatePlayerForMatch() { currentPlayers.Clear(); matchPlayers.Clear(); //debug.Log("stock : " + instance.stockPlayers.Length); foreach (_PlayerPokerActor pA in instance.stockPlayers) { bool bActive = PhotonUtility.GetPlayerProperties <bool> (pA.myPlayer, PhotonEnums.Player.Active); if (bActive) { currentPlayers.Add(pA); matchPlayers.Add(pA); } } //debug.Log("CURRENT PLAYERS : " + currentPlayers.Count); }
public void SyncMoney() //In Case Not Sync { if (myPlayer == null) { return; } if (!isMine || isBot) { myMoney = PhotonUtility.GetPlayerProperties <long>(myPlayer, PhotonEnums.Player.Money); } if (isBot && PhotonNetwork.isMasterClient) { _myParasitePlayer.photonView.RPC(PhotonEnums.RPC.RPC_ForceSyncBotMoney, PhotonTargets.Others, myMoney); } txtMyMoney.text = myMoney.toFlexibleCurrency(); }
private void RPC_Initiate() { int ownerSlotIndex = PhotonUtility.GetPlayerProperties <int> (this.photonView.owner, PhotonEnums.Player.SlotIndex); uiPlayer = SicboManager.instance.stockPlayers[ownerSlotIndex]; uiPlayer.gameObject.SetActive(true); uiPlayer.parasite = this; uiPlayer.photonPlayer = this.photonView.owner; nickname = this.photonView.owner.NickName; transform.SetParent(uiPlayer.transform); transform.localScale = new Vector3(1, 1, 1); transform.localPosition = new Vector3(0, 0, 0); uiPlayer.Initiate(ownerSlotIndex, photonView.isMine); if (photonView.isMine) { Logger.W("is mine set player properties array"); PhotonUtility.SetPlayerPropertiesArray(uiPlayer.photonPlayer, new string[] { PhotonEnums.Player.ReadyInitialized, PhotonEnums.Player.NextRoundIn }, new object[] { true, true }); } }
public void AssignPlayer() { int slot_index = PhotonUtility.GetPlayerProperties <int> (PhotonNetwork.player, PhotonEnums.Player.SlotIndex); if (slot_index == -1) { PhotonUtility.SetPlayerProperties(PhotonNetwork.player, PhotonEnums.Player.SlotIndex, GetAvailableRoomSlotIndex()); return; } //Check whether the game is already started ExitGames.Client.Photon.Hashtable playerProperties = PhotonNetwork.player.CustomProperties; playerProperties[PhotonEnums.Player.ContentURL] = PlayerData.costume_id; playerProperties[PhotonEnums.Player.PlayerID] = PlayerData.id; playerProperties[PhotonEnums.Player.IsBot] = false; playerProperties[PhotonEnums.Player.Name] = PlayerData.display_name; playerProperties[PhotonEnums.Player.Gender] = 0; playerProperties[PhotonEnums.Player.PictureURL] = string.Empty; PhotonNetwork.player.SetCustomProperties(playerProperties); objPlayers[slot_index].photonView.TransferOwnership(PhotonNetwork.player); objPlayers[slot_index].Initiate(); }
private void SyncSlots() { if (PhotonNetwork.isMasterClient) { bool[] slots = PhotonUtility.GetRoomProperties <bool[]> (PhotonEnums.Room.Slots); for (int i = 0; i < slots.Length; i++) { slots[i] = false; } foreach (PhotonPlayer player in PhotonNetwork.playerList) { int slotIndex = PhotonUtility.GetPlayerProperties <int> (player, PhotonEnums.Player.SlotIndex); if (slotIndex != -1) { slots[slotIndex] = true; } } PhotonUtility.SetRoomProperties(PhotonEnums.Room.Slots, slots); } }
private void OnQuitGame() { //Debug.LogError ("Quit Game"); if (GlobalVariables.gameType == GameType.TexasPoker) { if (PhotonNetwork.room != null || PhotonTexasPokerManager.instance.GetNumActivePlayers() <= 1) { Logger.E("Quit Game 1"); if (!PhotonUtility.GetPlayerProperties <bool> (PhotonNetwork.player, PhotonEnums.Player.Active)) { GlobalVariables.bQuitOnNextRound = false; PhotonTexasPokerManager.instance.ImLeaving(); Logger.E("Quit Game 2"); LoadMenu(); } else if (PhotonTexasPokerManager.instance != null && PhotonTexasPokerManager.instance.GetNumActivePlayers() > 1) { Logger.E("Quit Game55"); MessageManager.instance.Show(gameObject, "Keluar Ruangan", ButtonMode.OK_CANCEL, 1); } else { GlobalVariables.bQuitOnNextRound = false; PhotonTexasPokerManager.instance.ImLeaving(); LoadMenu(); } } else { LoadMenu(); } } //Hide(); }
public void SetMyInfoRank() { if (!PhotonUtility.GetPlayerProperties <bool>(myPlayer, PhotonEnums.Player.Active)) { return; } if (imgHandRank == null) { panelTxtRankHand.SetActive(true); } else { imgHandRank.gameObject.SetActive(true); } System.Collections.Generic.List <_CardActor> a = new System.Collections.Generic.List <_CardActor>(); foreach (_CardActor ca in _PokerGameManager.instance.tableCard) { if (ca.gameObject.activeSelf) { a.Add(ca); } } if (a.Count >= 2) { HandRankPoker hrp = _PokerGameManager.cardManager.EvaluatPlayerHand(a.ToArray(), _myHandCard); if (imgHandRank == null) { txtHandRank.text = hrp.ToString(); } else { switch (hrp) { case HandRankPoker.highCard: imgHandRank.sprite = PokerManager.instance.sprHighCard; break; case HandRankPoker.onePair: imgHandRank.sprite = PokerManager.instance.sprOnePair; break; case HandRankPoker.twoPairs: imgHandRank.sprite = PokerManager.instance.sprTwoPair; break; case HandRankPoker.threeOfaKind: imgHandRank.sprite = PokerManager.instance.sprThrice; break; case HandRankPoker.fourOfAKind: imgHandRank.sprite = PokerManager.instance.sprQuad; break; case HandRankPoker.straight: imgHandRank.sprite = PokerManager.instance.sprStraight; break; case HandRankPoker.flush: imgHandRank.sprite = PokerManager.instance.sprFlush; break; case HandRankPoker.fullHouse: imgHandRank.sprite = PokerManager.instance.sprFullHouse; break; case HandRankPoker.straightFlush: imgHandRank.sprite = PokerManager.instance.sprStraightFlush; PokerManager.instance.bStraightFlush = true; break; case HandRankPoker.royalFlush: imgHandRank.sprite = PokerManager.instance.sprRoyalFlush; PokerManager.instance.bRoyalFlush = true; break; } } } }
public void StartInitialize(int _slot, bool _flagMine, bool _isBot = false) { forceFold = false; isBot = _isBot; slotIndex = _slot; isMine = _flagMine; totalBet = 0; //ActivateInviteButton(false); chatItem.SetActive(false); foreach (Image i in imgBetAmount) { i.sprite = PokerManager.instance.sprCoin; } ExitGames.Client.Photon.Hashtable properties = myPlayer.CustomProperties; #region change name & picture & Avatar 3D _myName = (string)properties[PhotonEnums.Player.Name]; myMoney = (long)properties[PhotonEnums.Player.Money]; txtName.text = _myName; txtMyMoney.text = myMoney.toFlexibleCurrency(); //Load Avatar 3D if (isMine && !isBot) { //avatarEquiped = DataManager.instance.hero.id; heroUsed = PlayerData.costume_id; } else { heroUsed = PhotonUtility.GetPlayerProperties <int> (myPlayer, PhotonEnums.Player.ContentURL); } //hero.LoadSpine (heroUsed, isMine && !isBot); hero.LoadFromBundle(heroUsed, isMine && !isBot); #endregion _playerHandRank = (HandRankPoker)((int)properties[PhotonEnums.Player.HandRank]); RANK = (int)properties[PhotonEnums.Player.RankPoker]; valueHand = (int)properties[PhotonEnums.Player.ValueHand]; secondValueHand = (int)properties[PhotonEnums.Player.SecondValueHand]; _kicker = (int)properties[PhotonEnums.Player.Kicker]; secondKicker = (int)properties[PhotonEnums.Player.SecondKicker]; totalBet = (long)properties[PhotonEnums.Player.TotalBet]; chipsBet = (long)properties[PhotonEnums.Player.ChipsBet]; string strCard = (string)properties[PhotonEnums.Player.Cards]; if (strCard != "") { string[] cardTypes = strCard.Split(','); this.cardTypes = cardTypes; InstallHandCard(int.Parse(cardTypes[0]), int.Parse(cardTypes[1])); } if (isBot) { if (PhotonTexasPokerManager.instance.botCount == 0) { PhotonTexasPokerManager.instance.SyncBot(); } } UpdateUIPlayer(); }
void SyncBet(long _chipsBet, long _totalBet) { myMoney = PhotonUtility.GetPlayerProperties <long>(myPlayer, PhotonEnums.Player.Money); chipsBet = _chipsBet; totalBet = _totalBet; }