IEnumerator CreateEffectDealCard(PokerPlayerController[] players, int[] hands, int time) { PokerObserver.Game.IsClientListening = false; PokerPlayerController dealer = Array.Find <PokerPlayerController>(players, p => p.userName == PokerObserver.Game.Dealer); int indexDealer = Array.IndexOf(players, dealer); List <PokerPlayerController> playerDeal = new List <PokerPlayerController>(); for (int i = indexDealer; i < players.Length; i++) { playerDeal.Add(players[i]); } for (int i = 0; i < indexDealer; i++) { playerDeal.Add(players[i]); } float timeEffect = (time / 1000); float timeMove = 1.0f; float timeWaitForStart = (timeEffect - timeMove) / (playerDeal.Count * 2 - 1); for (int i = 0; i < 2; i++) { foreach (PokerPlayerController p in playerDeal) { PokerPlayerUI playerUI = GetPlayerUI(p.userName); GameObject cardObjects = (GameObject)GameObject.Instantiate(prefabCard); cardObjects.transform.parent = positionEffectDealCard.transform; cardObjects.transform.localRotation = Quaternion.identity; cardObjects.transform.localPosition = Vector3.zero; cardObjects.transform.localScale = Vector3.one / 3; Vector3 cardMoveTo = Vector3.zero; if (PokerObserver.Game.IsMainPlayer(p.userName)) { cardMoveTo = playerUI.side.positionCardMainPlayer[i].transform.localPosition; cardObjects.transform.parent = playerUI.side.positionCardMainPlayer[i].transform.parent; } else { cardMoveTo = playerUI.side.positionCardFaceCards[i].transform.localPosition; cardObjects.transform.parent = playerUI.side.positionCardFaceCards[i].transform.parent; } Hashtable tweenValue = new Hashtable(); tweenValue.Add("cardObject", cardObjects); tweenValue.Add("index", i); tweenValue.Add("cardId", hands[i]); tweenValue.Add("userName", p.userName); iTween.MoveTo(cardObjects, iTween.Hash("islocal", true, "time", timeMove, "position", cardMoveTo, "oncomplete", "onMoveCardComplete", "oncompletetarget", gameObject, "oncompleteparams", tweenValue)); PuSound.Instance.Play(SoundType.DealCard); yield return(new WaitForSeconds(timeWaitForStart)); } } PokerObserver.Game.IsClientListening = true; }
public static PokerGameplayPlayerChat Create(string chatContent, PokerPlayerUI player) { if (chatContent.Length > 57) chatContent = chatContent.Substring(0, 50) + "..."; GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/PlayerChat")); obj.name = "Chat Content"; obj.transform.parent = player.transform; obj.transform.localPosition = new Vector3(-70f,50f); obj.transform.localScale = Vector3.one; obj.GetComponent<PokerGameplayPlayerChat>().txtContent.text = chatContent; obj.GetComponent<PokerGameplayPlayerChat>().ReDraw(); return obj.GetComponent<PokerGameplayPlayerChat>(); }
void onMoveCardComplete(object vals) { Hashtable table = (Hashtable)vals; string userName = (string)table["userName"]; GameObject cardObjects = (GameObject)table["cardObject"]; int index = (int)table["index"]; int cardId = (int)table["cardId"]; PokerPlayerUI playerUI = GetPlayerUI(userName); cardObjects.GetComponent <PokerCardObject>().SetDataCard(PokerObserver.Game.IsMainPlayer(userName) ? new PokerCard(cardId) : new PokerCard(), index); playerUI.UpdateSetCardObject(cardObjects, index); cardsDeal.Add(cardObjects); }
public static PokerGameplayPlayerChat Create(string chatContent, PokerPlayerUI player) { if (chatContent.Length > 57) { chatContent = chatContent.Substring(0, 50) + "..."; } GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/PlayerChat")); obj.name = "Chat Content"; obj.transform.parent = player.transform; obj.transform.localPosition = new Vector3(-70f, 50f); obj.transform.localScale = Vector3.one; obj.GetComponent <PokerGameplayPlayerChat>().txtContent.text = chatContent; obj.GetComponent <PokerGameplayPlayerChat>().ReDraw(); return(obj.GetComponent <PokerGameplayPlayerChat>()); }
void Instance_onPlayerListChanged(ResponsePlayerListChanged dataPlayer) { PokerPlayerChangeAction state = dataPlayer.GetActionState(); if (state == PokerPlayerChangeAction.playerAdded) { if (PokerObserver.Game.IsMainPlayer(dataPlayer.player.userName)) { PuSound.Instance.Play(SoundType.Sit_Down); } SetPositionAvatarPlayer(dataPlayer.player.userName); } else if ((state == PokerPlayerChangeAction.playerRemoved || state == PokerPlayerChangeAction.playerQuitGame) && dictPlayerObject.ContainsKey(dataPlayer.player.userName)) { PokerPlayerUI playerUI = GetPlayerUI(dataPlayer.player.userName); if (PokerObserver.Game.IsMainPlayer(dataPlayer.player.userName)) { PuSound.Instance.Play(SoundType.StandUp); } if (PokerObserver.Game.Dealer == dataPlayer.player.userName) { objectDealer.SetActive(false); } DestroyCardObject(playerUI.cardOnHands); if (dictReJoinGame.ContainsKey(dataPlayer.player.userName)) { GameObject.Destroy(dictReJoinGame[dataPlayer.player.userName]); dictReJoinGame.Remove(dataPlayer.player.userName); } else { //GameObject.Destroy(playerUI); NGUITools.SetActive(playerUI.gameObject, false); listPlayerQuit.Add(playerUI); playerUI.PlayerOutGame(); //dictPlayerObject.Remove(dataPlayer.player.userName); } } UpdatePositionPlayers(dataPlayer.player.userName); }
void CreateHand(PokerPlayerController[] players, int [] hands) { foreach (PokerPlayerController p in players) { PokerPlayerUI playerUI = GetPlayerUI(p.userName); int handSize = p.handSize; GameObject[] cardObjects = playerUI.cardOnHands.Length > 0 ? playerUI.cardOnHands : new GameObject[handSize]; for (int i = 0; i < handSize; i++) { if (cardObjects[i] == null) { cardObjects[i] = (GameObject)GameObject.Instantiate(prefabCard); } } if (PokerObserver.Game.IsMainPlayer(p.userName)) { if (hands != null && hands.Length == handSize) { for (int i = 0; i < handSize; i++) { cardObjects[i].GetComponent <PokerCardObject>().SetDataCard(new PokerCard(hands[i]), i); } } else { Logger.LogError("Hand Size & Card On Hand: is not fit"); } } else { for (int i = 0; i < handSize; i++) { cardObjects[i].GetComponent <PokerCardObject>().SetDataCard(new PokerCard(), i); } } playerUI.UpdateSetCardObject(cardObjects); cardsDeal.AddRange(cardObjects); } }
private void onShowMessage(DataChat message) { if (message.GetChatType() == DataChat.ChatType.Private) { string itemInteraction = message.Content; if (itemInteraction.IndexOf(ITEM_INTERACTION_PREFIX) == 0) { PokerPlayerUI sender = playmat.GetPlayerUI(message.Sender.userName); PokerPlayerUI receiver = playmat.GetPlayerUI(message.ReceiverName); GameObject pointTo = new GameObject(); pointTo.name = "Point To"; pointTo.transform.parent = receiver.transform; pointTo.transform.localScale = Vector3.one; pointTo.transform.localPosition = Vector3.zero; pointTo.transform.parent = gameObject.transform; Vector3 pointMoveTo = pointTo.transform.localPosition; GameObject.Destroy(pointTo); string nameSprite2D = message.Content.Split('_')[1]; Sprite[] sprites = Resources.LoadAll <Sprite>("Sprites/ItemInteractions/" + nameSprite2D); GameObject pointFrom = new GameObject(); pointTo.name = "Point From"; pointFrom.transform.parent = sender.transform; pointFrom.transform.localScale = Vector3.one; pointFrom.transform.localPosition = Vector3.zero; pointFrom.transform.parent = gameObject.transform; pointFrom.AddComponent <UI2DSprite>().sprite2D = sprites[0]; pointFrom.GetComponent <UI2DSprite>().depth = 20; pointFrom.GetComponent <UI2DSprite>().MakePixelPerfect(); pointFrom.AddComponent <UI2DSpriteAnimation>().frames = Array.FindAll <Sprite>(sprites, sp => sp.name.Contains(nameSprite2D)); pointFrom.GetComponent <UI2DSpriteAnimation>().ignoreTimeScale = false; pointFrom.GetComponent <UI2DSpriteAnimation>().framesPerSecond = 5; pointFrom.GetComponent <UI2DSpriteAnimation>().loop = true; pointFrom.GetComponent <UI2DSpriteAnimation>().Play(); pointFrom.name = nameSprite2D; Hashtable tweenValue = new Hashtable(); tweenValue.Add("item", pointFrom); tweenValue.Add("spriteArray", Array.FindAll <Sprite>(sprites, sp => sp.name.Contains("finish"))); iTween.MoveTo(pointFrom, iTween.Hash("islocal", true, "position", pointMoveTo, "time", 1.5f, "oncomplete", "onMoveItemInteractionComplete", "oncompletetarget", gameObject, "oncompleteparams", tweenValue)); } } }
IEnumerator _SummaryPot(ResponseResultSummary data, float timeEffect) { PokerPotItem thisPot = currentPots.Find(p => data.potId == p.Pot.id); if (thisPot != null && thisPot.gameObject != null) { List <PokerPotItem> listPotItems = new List <PokerPotItem>(); List <ResponseMoneyExchange> winnerPlayers = new List <ResponseMoneyExchange>(System.Array.FindAll <ResponseMoneyExchange>(data.players, p => p.winner)); foreach (ResponseMoneyExchange exchange in winnerPlayers) { PokerPlayerUI uiPlayer = playmat.GetPlayerUI(exchange.userName); if (exchange.moneyExchange > 0 && uiPlayer != null) { PokerPotItem pot = NGUITools.AddChild(thisPot.gameObject, thisPot.gameObject).GetComponent <PokerPotItem>(); pot.gameObject.transform.parent = uiPlayer.transform.parent; pot.OnMove(); listPotItems.Add(pot); } } currentPots.Remove(thisPot); GameObject.Destroy(thisPot.gameObject); foreach (PokerPotItem pot in listPotItems) { iTween.MoveTo(pot.gameObject, iTween.Hash("islocal", true, "time", timeEffect, "position", Vector3.zero)); } StartCoroutine(PlaySound()); yield return(new WaitForSeconds(timeEffect)); for (int i = listPotItems.Count - 1; i >= 0; i--) { GameObject.Destroy(listPotItems[i].gameObject); } listPotItems.Clear(); yield return(new WaitForEndOfFrame()); } yield return(new WaitForEndOfFrame()); tablePot.Reposition(); }
void SetPositionAvatarPlayer(string userName) { PokerPlayerController player = PokerObserver.Game.GetPlayer(userName); GameObject obj; if (dictPlayerObject.ContainsKey(userName) && listPlayerQuit.Find(p => p.UserName == userName) == null) { obj = dictPlayerObject[userName]; } else if (dictReJoinGame.ContainsKey(userName)) { obj = dictReJoinGame[userName]; } else { obj = (GameObject)GameObject.Instantiate(prefabPlayer); if (listPlayerQuit.Find(p => p.UserName == userName) == null) { dictPlayerObject.Add(player.userName, obj); } else if (dictReJoinGame.ContainsKey(player.userName) == false) { dictReJoinGame.Add(player.userName, obj); } } PokerGPSide playerSide = Array.Find <PokerGPSide>(arrayPokerSide, s => s.CurrentSide == player.GetSide()); PokerPlayerUI playerUI = obj.GetComponent <PokerPlayerUI>(); playerUI.side = playerSide; playerUI.SetData(player); obj.transform.parent = playerSide.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; playerUI.ChangeCardPosition(); }
IEnumerator _UpdatePot(List <ResponseUpdatePot.DataPot> dataPots) { foreach (ResponseUpdatePot.DataPot data in dataPots) { bool isCreate = false; PokerPotItem thisPot = currentPots.Find(p => data.id == p.Pot.id); if (thisPot != null) { thisPot.SetValue(data); } else { thisPot = PokerPotItem.Create(data); isCreate = true; switch (currentPots.Count) { case 6: thisPot.transform.parent = topLeftPosition.transform; break; case 7: thisPot.transform.parent = topRightPosition.transform; break; default: thisPot.transform.parent = tablePot.transform; break; } thisPot.transform.localScale = Vector3.one; thisPot.transform.localPosition = Vector3.zero; currentPots.Add(thisPot); } #region EFFECT MOVE CHIP if (data.isNew) { if (isCreate) { thisPot.SetAlpha(0); } tablePot.Reposition(); yield return(new WaitForEndOfFrame()); List <PokerPotItem> listPotItems = new List <PokerPotItem>(); for (int i = 0; i < data.contributors.Length; i++) { PokerPlayerUI uiPlayer = playmat.GetPlayerUI(data.contributors[i]); if (uiPlayer != null) { PokerPotItem pot = NGUITools.AddChild(uiPlayer.side.positionMoney, playmat.prefabBetObject).GetComponent <PokerPotItem>(); pot.gameObject.transform.parent = thisPot.transform; pot.OnMove(); listPotItems.Add(pot); } } yield return(new WaitForEndOfFrame()); foreach (PokerPotItem pot in listPotItems) { iTween.MoveTo(pot.gameObject, iTween.Hash("islocal", true, "time", .5f, "position", Vector3.zero)); } StartCoroutine(PlaySound()); yield return(new WaitForSeconds(.6f)); while (listPotItems.Count > 0) { if (listPotItems[0] != null && listPotItems[0].gameObject != null) { GameObject.Destroy(listPotItems[0].gameObject); } listPotItems.RemoveAt(0); yield return(new WaitForEndOfFrame()); } thisPot.SetAlpha(1); yield return(new WaitForEndOfFrame()); } #endregion } yield return(new WaitForEndOfFrame()); tablePot.Reposition(); }