public void SetData(int cardId, PanelBetting grandParent) { this.cardId = cardId; this.grandParentView = grandParent; ChanCard card = new ChanCard(); card.CardId = cardId; card.parent = gameObject.transform; card.Instantiate(); card.cardTexture.texture.width = CARD_WIDTH; card.cardTexture.texture.height = CARD_HIGHT; GameObject.Destroy(card.gameObject.GetComponent <BoxCollider>()); }
internal void ShowIndividualCard(Electrotank.Electroserver5.Api.EsObject eso) { esObj = eso; DestroyCard(); if (eso.variableExists("cards")) { int[] cardIds = eso.getIntegerArray("cards"); for (int i = 0; i < cardIds.Length; i++) { if (parent.model != null) { if (parent.model.CardId == cardIds[i]) { FACardBettingView.Create(cardIds[i], tableCardFA.transform, gameObject.GetComponent <PanelBetting>()).gameObject.SetActive(false); continue; } } FACardBettingView cars = FACardBettingView.Create(cardIds[i], tableCardFA.transform, gameObject.GetComponent <PanelBetting>()); } tableCardFA.Reposition(); GameManager.Instance.FunctionDelay(delegate() { tableCardFA.transform.parent.localPosition = Vector3.zero; }, 0.01f); } GameManager.Instance.FunctionDelay(delegate() { if (parent.model != null) { if (parent.model.CardId != -1) { ChanCard card = new ChanCard(); card.CardId = parent.model.CardId; card.parent = cardParent; card.Instantiate(); card.cardTexture.texture.width = CARD_WIDTH; card.cardTexture.texture.height = CARD_HIGHT; GameObject.Destroy(card.gameObject.GetComponent <BoxCollider>()); lbCardBet.text = card.ToString(); cardId = parent.model.CardId; } if (parent.model.ChipBetting == 0) { lbChipBet.text = ((LobbyChan)GameManager.Instance.selectedLobby).betting.ToString(); } else { lbChipBet.text = parent.model.ChipBetting.ToString(); } HideAllButton(); } }, 0.15f); }
public void SetData(PlayerBettingModel model) { this.model = model; userName.text = model.Player.username; model.Player.AvatarTexture(delegate(Texture texture) { avatar.mainTexture = texture; }); ShowTypeAndMoney(model.ETypeLaying != ETypeLayingBetting.None); string textTypeGa = ""; if (model.ETypeLaying != ETypeLayingBetting.None) { switch (model.ETypeLaying) { case ETypeLayingBetting.Rong: textTypeGa = "Rộng"; break; case ETypeLayingBetting.Hep: textTypeGa = "Hẹp"; break; case ETypeLayingBetting.RongHep: textTypeGa = "Rộng | Hẹp"; break; } lbTypeLaying.text = textTypeGa; lbMoney.text = Utility.Convert.Chip(model.ChipBetting); ECardTexture texture = gameObject.GetComponentInChildren <ECardTexture>(); if (texture != null) { texture.card.CardId = model.CardId; } else { Transform cardManager = gameObject.transform.FindChild("CardManager"); ChanCard card = new ChanCard(); card.CardId = model.CardId; card.parent = cardManager; card.Instantiate(); card.cardTexture.texture.width = CARD_WIDTH; card.cardTexture.texture.height = CARD_HIGHT; GameObject.Destroy(card.gameObject.GetComponent <BoxCollider>()); } } }
internal void ChoosenCard(int cardID) { if (parent.model != null && parent.model.CardId != cardID && btnSubmit.gameObject.transform.collider.enabled == false) { btnSubmit.gameObject.GetComponentInChildren <UISprite>().color = Color.white; btnSubmit.gameObject.transform.collider.enabled = true; } else if (parent.model != null && parent.model.CardId == cardID && btnSubmit.gameObject.transform.collider.enabled == true) { btnSubmit.gameObject.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 90f / 255f); btnSubmit.gameObject.transform.collider.enabled = false; } for (int i = 0; i < tableCardFA.transform.childCount; i++) { if (tableCardFA.transform.GetChild(i).GetComponent <FACardBettingView>().cardId == cardID) { tableCardFA.transform.GetChild(i).GetComponent <FACardBettingView>().gameObject.SetActive(false); } else { if (!tableCardFA.transform.GetChild(i).GetComponent <FACardBettingView>().gameObject.activeSelf) { tableCardFA.transform.GetChild(i).GetComponent <FACardBettingView>().gameObject.SetActive(true); } } } tableCardFA.Reposition(); cardId = cardID; for (int i = 0; i < cardParent.childCount; i++) { GameObject.Destroy(cardParent.transform.GetChild(i).gameObject); } ChanCard card = new ChanCard(); card.CardId = cardID; card.parent = cardParent; card.Instantiate(); card.cardTexture.texture.width = CARD_WIDTH; card.cardTexture.texture.height = CARD_HIGHT; GameObject.Destroy(card.gameObject.GetComponent <BoxCollider>()); lbCardBet.text = card.ToString(); }
/// <summary> /// Khi có người chơi bốc bài /// </summary> /// <param name="index">Người bốc bài</param> /// <param name="cardValue">Bài bốc được</param> public static void DrawCard(int index, int cardValue, int timeExpire) { ChanCard card = new ChanCard(index, cardValue); card.Instantiate(GameModelChan.game.deck.transform); card.isDrawFromDeck = true; GetPlayer(index).mCardTrash.Add(card); card.setTimeExpire(timeExpire); DeckCount--; game.stolen = false; MiniState = EGameStateMini.stealCard_or_skip; if (Common.CanViewHand && (YourController == null || YourController.slotServer != index)) { GetPlayer(index).mCardHand.Sort((c1, c2) => c1.CompareTo(c2)); } card.UpdateParent(index); game.UpdateHand(index, 0.5f); //game.UpdateHand(GameModel.IndexLastInTurn, 0.5f); }
IEnumerator DealCard() { float time = 0.3f; #region CHIA BAI Hashtable hash = iTween.Hash("islocal", true, "time", time, "position", Vector3.zero); int index = 0; GameObject[] oldObj = new GameObject[2]; while (index < 2) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 2; j++) { ChanCard c = new ChanCard(0, -1); c.Instantiate(GameModelChan.game.mPlaymat.locationDealCard[i + (j * 5)]); GameObject obj = c.gameObject; obj.name = "Card " + index + " " + i + " " + j + " - " + (index * (i + 1) + (j)); Vector3 pos; if (oldObj[j] != null) { pos = oldObj[j].transform.parent.localPosition - GameModelChan.game.mPlaymat.locationDealCard[i + (j * 5)].localPosition; } else { pos = GameModelChan.game.mPlaymat.locationDealCard[i + (j * 5)].localPosition; } obj.transform.localPosition = pos; obj.transform.localScale /= 1.75f; obj.transform.localRotation = new Quaternion(0f, 0f, 0.9f, 0.4f); iTween.MoveTo(obj, hash); oldObj[j] = obj; } yield return(new WaitForSeconds(time)); } index++; } #endregion yield return(new WaitForSeconds(0.5f)); #region GỘP BÀI for (int i = 0; i < 5; i++) { if (i < 2) { while (GameModelChan.game.mPlaymat.locationDealCard[i + (1 * 5)].childCount > 0) { Transform tran = GameModelChan.game.mPlaymat.locationDealCard[i + (1 * 5)].GetChild(0); tran.parent = GameModelChan.game.mPlaymat.locationDealCard[i + (0 * 5)]; iTween.MoveTo(tran.gameObject, hash); } } else { while (GameModelChan.game.mPlaymat.locationDealCard[i + (0 * 5)].childCount > 0) { Transform tran = GameModelChan.game.mPlaymat.locationDealCard[i + (0 * 5)].GetChild(0); tran.parent = GameModelChan.game.mPlaymat.locationDealCard[i + (1 * 5)]; iTween.MoveTo(tran.gameObject, hash); } } } #endregion yield return(new WaitForSeconds(time + 0.05f)); #region DI CHUYỂN BÀI CHO ĐỀU for (int i = 0; i < 2; i++) { while (GameModelChan.game.mPlaymat.locationDealCard[i].childCount > 0) { Transform tran = GameModelChan.game.mPlaymat.locationDealCard[i].GetChild(0); tran.parent = GameModelChan.game.mPlaymat.locationDealCard[4 - i]; iTween.MoveTo(tran.gameObject, hash); } } //Destroy hết child giữ lại 1 card List <GameObject> listObj = new List <GameObject>(); foreach (Transform trans in GameModelChan.game.mPlaymat.locationDealCard) //for(int i=0;i<GameModel.game.mPlaymat.locationDealCard.Length;i++) { //Transform trans = GameModel.game.mPlaymat.locationDealCard[i]; while (trans.childCount >= 2) { GameObject obj = trans.GetChild(0).gameObject; obj.transform.parent = null; GameObject.Destroy(obj); } if (trans.childCount > 0) { listObj.Add(trans.GetChild(0).gameObject); } } listPickObject[0] = listObj[0]; listPickObject[1] = listObj[1]; listPickObject[2] = listObj[2]; listPickObject[3] = listObj[3]; listPickObject[4] = listObj[4]; #endregion currentStep = StepDealCard.WAIT_PICK; if (EventResponseMessage != null) { EventResponseMessage(); } }
/// <summary> /// Khi có người chơi đánh bài /// </summary> /// <param name="index">Người đánh bài</param> /// <param name="cardValue">Card đã đánh</param> public static void Discard(int soundId, int index, int cardValue, params string[] discardToPlayer) { ECard card = GetCard_FromHandPlayer(index, cardValue); if (GameModelChan.YourController == null || GameModelChan.YourController.slotServer != index) { card = new ChanCard(index, cardValue); card.Instantiate(game.mPlaymat.locationPlayer[(int)GetPlayer(index).mSide]); GetPlayer(index).mCardHand.Add(card); card.UpdateParent(index); } GetPlayer(index).mCardDiscardedAndDraw.Add(card); GetPlayer(index).mCardDiscarded.Add(card); GetPlayer(index).mCardHand.Remove(card); if (discardToPlayer != null && discardToPlayer.Length > 0 && discardToPlayer[0] != null) { PlayerControllerChan p = GetPlayer(discardToPlayer[0]); GetPlayer(discardToPlayer[0]).mCardTrash.Add(card); card.ChangeSide(p.slotServer); card.UpdateParent(p.slotServer); } else { GetPlayer(index).mCardTrash.Add(card); } game.fullLaying = false; card.UpdateParent(index); if (YourController != null && YourController.slotServer == index) { game.OnClickSort(game.btSorted.gameObject); } else { game.UpdateHand(index, 0.5f); } if (discardToPlayer != null && discardToPlayer.Length > 0 && discardToPlayer[0] != null) { game.UpdateHand(GetPlayer(discardToPlayer[0]).slotServer, 0.5f); } if (discardToPlayer != null && discardToPlayer.Length > 0 && discardToPlayer[0] != null)// co' chiu' tra? cua { Debug.Log(GameModelChan.GetPlayer(discardToPlayer[0]).username + " PlayerState " + GameModelChan.GetPlayer(index).PlayerState.ToString()); if (GameModelChan.GetPlayer(discardToPlayer[0]).PlayerState == EPlayerController.EPlayerState.inTurnStealOrIgnore) { // Chíu cây bốc MiniState = EGameStateMini.stealCard_or_skip; //SoundGameplay.Instances.playAudioDisCard(cardValue, GetPlayer(index), GetPlayer(discardToPlayer[0]), null); } else { // Chíu cây bốc đánh MiniState = EGameStateMini.stealCard_or_draw; //SoundGameplay.Instances.playAudioDisCard(cardValue, GetPlayer(index), GetNextPlayer(discardToPlayer[0]), null); } } else { MiniState = EGameStateMini.stealCard_or_draw; //SoundGameplay.Instances.playAudioDisCard(cardValue, GetPlayer(index), GetNextPlayer(index), GetLastPlayer(index)); } SoundGameplay.Instances.PlaySoundInGame(soundId, GetPlayer(index)); }
/// <summary> /// Khi có người chơi ăn bài /// </summary> /// <param name="index">Index Người chơi ăn</param> /// <param name="indexLast">Index người chơi đánh bài</param> public static void StealCard(int soundId, int index, int indexLast, int[] cardId) { StealCard stealCard = new StealCard(); stealCard.player = GetPlayer(index); stealCard.steals.Clear(); #region FIND CARD STEAL ECard cardSteal = GetPlayer(indexLast).mCardTrash[GetPlayer(indexLast).mCardTrash.Count - 1]; GetPlayer(indexLast).mCardTrash.Remove(cardSteal); cardSteal.ChangeSide(index); stealCard.steals.Add(cardSteal); #endregion #region FIND CARD STEAL ON HAND for (int i = 1; i < cardId.Length; i++) { ECard cardOnHand = GetPlayer(index).mCardHand.Find(c => c.CardId == cardId[1]); if (cardOnHand != null) { GetPlayer(index).mCardHand.Remove(cardOnHand); if (GameModelChan.YourController != null && GameModelChan.YourController.slotServer != index) { Debug.LogError("Tìm thấy card trên tay người chơi: " + GetPlayer(index).username); } } else if (cardOnHand == null && (GameModelChan.YourController == null || GameModelChan.YourController.slotServer != index)) { cardOnHand = new ChanCard(index, cardId[1]); cardOnHand.Instantiate(); } else { Debug.LogError("Không tìm thấy card phù hợp!!!"); } stealCard.steals.Add(cardOnHand); } #endregion GetPlayer(index).mCardSteal.Add(stealCard); for (int i = 0; i < stealCard.steals.Count; i++) { stealCard.steals[i].cardTexture.texture.depth = i; } stealCard.steals.ForEach(c => c.UpdateParent(index)); MiniState = EGameStateMini.discard; if (GameModelChan.YourController != null && YourController.slotServer == index) { game.OnClickSort(game.btSorted.gameObject); } else { game.UpdateHand(index, 0.5f); } game.UpdateHand(GameModelChan.IndexLastInTurn, 0.5f); if (soundId == -1) { SoundGameplay.Instances.PlaySoundStealCard(cardId, GetPlayer(index), GetLastPlayer(index)); } else { SoundGameplay.Instances.PlaySoundInGame(soundId, GetPlayer(index)); } }
public void LocationFullLayingChiu(Electrotank.Electroserver5.Api.EsObject[] list, bool isResult) { int x = 0; int carid = 0; if (list == null || list.Length == 0) { return; } string textValue = ""; int index = 0; if (GameModelChan.game.listFullLaying[2] == list) { index = (GameModelChan.game.listFullLaying[0].Length + GameModelChan.game.listFullLaying[1].Length) / 2; textValue = "Ù"; } List <GameObject> listGameObject = new List <GameObject>(); for (int i = 0; i < list.Length; i++) { Electrotank.Electroserver5.Api.EsObject obj = list[i]; carid = obj.getInteger("id"); if (carid == obj.getInteger("id")) { x++; } ChanCard c = new ChanCard(0, obj.getInteger("id")); c.Instantiate(GameModelChan.game.mPlaymat.locationFullLaying); if (obj.variableExists("cardDraw") && obj.getBoolean("cardDraw")) { c.isDrawFromDeck = true; } Vector3 moveToPosition = GameModelChan.game.mPlaymat.GetLocationFullLayingChiu(index, i); if (isResult) { moveToPosition.x -= 230f; } c.gameObject.transform.localPosition = moveToPosition; if (i % 2 == 1) { index++; } listGameObject.Add(c.gameObject); } int indexCenter = Mathf.FloorToInt(listGameObject.Count / 2) - 1; Vector3 centerObject = new Vector3(listGameObject[indexCenter].transform.localPosition.x, 110f, listGameObject[indexCenter].transform.localPosition.z); if (listGameObject.Count / 2 % 2 == 0) { centerObject.x += 20f; } GameObject objText = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/LablePrefab")); UILabel text = objText.GetComponent <UILabel>(); objText.transform.parent = GameModelChan.game.mPlaymat.locationFullLaying; objText.transform.localScale = Vector3.one; objText.transform.localPosition = centerObject; text.color = Color.black; text.text = textValue; ListGameObjectFulllaying.Add(objText); ListGameObjectFulllaying.AddRange(listGameObject); }