/// <summary> /// Hiện thông tin, kết quả khi hết trận. /// </summary> private IEnumerator _FinishGame() { #region SHOW OTHER HAND foreach (PlayerControllerChan p in GameModelChan.ListPlayerInGame) { if (GameModelChan.YourController != null && p.slotServer == YourController.slotServer) { continue; } //Đặt những card ăn vào danh sách card của bản thân (Fix trường hợp có người Ù giữa trận card ăn bị kẹt chèn đè lên) p.mCardHand.ForEach(c => { c.originSide = c.currentSide; c.originSlot = c.currentSlot; }); List <int> lst = new List <int>(); while (p.summary.inHand.Count > 0) { if (p.mCardHand.Find(c => c.CardId == p.summary.inHand[0]) == null) { lst.Add(p.summary.inHand[0]); } p.summary.inHand.RemoveAt(0); } foreach (int _value in lst) { ECard card = p.mCardHand.Find(c => c.CardId == -1); if (card != null) { card.CardId = _value; } } p.mCardHand.Sort((c1, c2) => c1.CardId.CompareTo(c2.CardId)); } game.UpdateHand(); #endregion //0.5s cho Start Game mới. O.5s cho Gameplay Process Command Update Hand float time = game.TimeCountDown; float timeShowPoint = (time - 1) / 3f; float timeShowResult = timeShowPoint, timeShowMoney = timeShowPoint; MiniState = EGameStateMini.summary_point; GameModelChan.game.UpdateUI(); yield return(new WaitForSeconds(timeShowPoint)); #region PLAY SOUNDS #endregion MiniState = EGameStateMini.summary_result; GameModelChan.game.UpdateUI(); yield return(new WaitForSeconds(timeShowResult)); MiniState = EGameStateMini.summary_exchange; //GameModel.game.UpdateUserInfo(); //GameModel.game.UpdateUI(); //yield return new WaitForSeconds(timeShowMoney); MiniState = EGameStateMini.summary_end; GameModelChan.game.UpdateUI(); yield return(new WaitForSeconds(0.5f)); //DestroyObject(); game.lbDiscard.text = ""; ListResultXuongView.Close(); game.fullLayingEffect.Destroy(); GameModelChan.CreateNewGame(); ListPlayerInGame.ForEach(p => { p.warningMessage = ""; p.Reset(); p.summary.result = PlayerControllerChan.FinishGame.ResultSprite.None; }); game.IsProcesResonseDone = true; }
/// <summary> /// Hiện thông tin, kết quả khi hết trận. /// </summary> private IEnumerator _FinishGame() { #region SET RESULT if (game.gameFinishType == GamePlayPhom.EFinishType.NORMAL) { GamePlayPhom.Summary sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.TOP_2); if (sum != null) { GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_NHAT; GameModelPhom.GetPlayer(sum.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_NHI; } else { if (game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.MOM) != null) { GameModelPhom.GetPlayer(game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.MOM).targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_NHAT; } else if (game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.XAO_KHAN) != null) { GamePlayPhom.Summary xaoKhan = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.XAO_KHAN); GameModelPhom.GetPlayer(xaoKhan.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.XAO_KHAN; ListPlayerInGame.ForEach(p => { if (p.username != xaoKhan.targetPlayer) { p.summary.result = PlayerControllerPhom.FinishGame.ResultSprite.MOM; } }); } } sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.TOP_3); if (sum != null) { GameModelPhom.GetPlayer(sum.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_BA; } sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.TOP_4); if (sum != null) { GameModelPhom.GetPlayer(sum.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.VE_TU; } List <GamePlayPhom.Summary> lstSum = game.summaryGame.FindAll(o => o.action == GamePlayPhom.Summary.EAction.MOM); if (lstSum.Count > 0) { foreach (GamePlayPhom.Summary s in lstSum) { GameModelPhom.GetPlayer(s.sourcePlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.MOM; } } } else { GamePlayPhom.Summary sum; if (game.gameFinishType == GamePlayPhom.EFinishType.U_THUONG || game.gameFinishType == GamePlayPhom.EFinishType.U_DEN_THUONG) { sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.U_THUONG || o.action == GamePlayPhom.Summary.EAction.U_TRON || o.action == GamePlayPhom.Summary.EAction.DEN_LANG); if (sum != null) { GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.U; } } else if (game.gameFinishType == GamePlayPhom.EFinishType.U_TRON || game.gameFinishType == GamePlayPhom.EFinishType.U_DEN_TRON) { sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.U_TRON || o.action == GamePlayPhom.Summary.EAction.DEN_LANG); if (sum != null) { GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.U_TRON; } } else if (game.gameFinishType == GamePlayPhom.EFinishType.U_XUONG) { sum = game.summaryGame.Find(o => o.action == GamePlayPhom.Summary.EAction.U_XUONG); if (sum != null) { GameModelPhom.GetPlayer(sum.targetPlayer).summary.result = PlayerControllerPhom.FinishGame.ResultSprite.U_XUONG; } } } #endregion #region SHOW OTHER HAND foreach (PlayerControllerPhom p in GameModelPhom.ListPlayerInGame) { if (p.slotServer == YourController.slotServer) { continue; } //Đặt những card ăn vào danh sách card của bản thân (Fix trường hợp có người Ù giữa trận card ăn bị kẹt chèn đè lên) p.mCardHand.ForEach(c => { c.originSide = c.currentSide; c.originSlot = c.currentSlot; }); List <int> lst = new List <int>(); while (p.summary.inHand.Count > 0) { if (p.mCardHand.Find(c => c.CardId == p.summary.inHand[0]) == null) { lst.Add(p.summary.inHand[0]); } p.summary.inHand.RemoveAt(0); } foreach (int _value in lst) { ECard card = p.mCardHand.Find(c => c.CardId == -1); if (card != null) { card.CardId = _value; } } p.mCardHand.Sort((c1, c2) => c1.CardId.CompareTo(c2.CardId)); } game.UpdateHand(); #endregion #region CHUYỂN CÁC QUÂN BÀI THẮNG TRẮNG RA GIỮA MÀN HÌNH if (game.gameFinishType != GamePlayPhom.EFinishType.NORMAL && YourController.mCardHand.Count == 0) { int i = 0; YourController.mCardMelds.ForEach(meld => { for (int j = 0; j < meld.meld.Count; j++) { ECard card = meld.meld[j]; card.SetHightlight(); Hashtable hash = new Hashtable(); hash.Add("islocal", true); hash.Add("time", 0.75f); hash.Add("position", game.mPlaymat.GetLocationFulllaying(YourController, i, j)); iTween.MoveTo(card.gameObject, hash); iTween.ScaleTo(card.gameObject, Vector3.one * 1.5f, 0.75f); } i++; }); } #endregion //0.5s cho Start Game mới. O.5s cho GamePlayPhom Process Command Update Hand float time = game.TimeCountDown; float timeShowPoint = (time - 1) / 3f; float timeShowResult = timeShowPoint, timeShowMoney = timeShowPoint; MiniState = EGameStateMini.summary_point; GameModelPhom.game.UpdateUI(); yield return(new WaitForSeconds(timeShowPoint)); #region PLAY SOUNDS SoundGamePhom.Instances.PlaySound(game); #endregion MiniState = EGameStateMini.summary_result; GameModelPhom.game.UpdateUI(); yield return(new WaitForSeconds(timeShowResult)); MiniState = EGameStateMini.summary_exchange; GameModelPhom.game.UpdateUserInfo(); GameModelPhom.game.UpdateUI(); yield return(new WaitForSeconds(timeShowMoney)); MiniState = EGameStateMini.summary_end; GameModelPhom.game.UpdateUI(); yield return(new WaitForSeconds(0.5f)); //DestroyObject(); game.IsProcesResonseDone = true; }