public void OnCountDownDone() { if (gChets.activeSelf) { gChets.SetActive(false); canvasItems.alpha = 1; uiItemChest.ShowReward(bonusChestItem.money, UILGameSlot20LineBonusItem.BonusItemType.OPEN_CHEST); } List <int> indexs = new List <int>(); for (int i = 0; i < uiItems.Count; i++) { var item = uiItems[i]; item.btItem.enabled = false; if (!item.isOpen) { indexs.Add(i); } } VKCommon.Shuffle(indexs); for (int i = 0; i < bonusItems.Count; i++) { var bonusItem = bonusItems[i]; var uiItem = uiItems[indexs[i]]; if (bonusItem.IsChest()) { uiItem.ShowReward(bonusItem.money, UILGameSlot20LineBonusItem.BonusItemType.OPEN_CHEST); } else if (bonusItem.IsKey()) { uiItem.ShowReward(bonusItem.money, UILGameSlot20LineBonusItem.BonusItemType.KEY); keyCount++; } else { uiItem.ShowReward(bonusItem.money, UILGameSlot20LineBonusItem.BonusItemType.NORNAL); } } totalWin = bonusGame.PrizeValue; SetHeSo(); SetLuotMo(); SetTotalWin(); StartCoroutine(WaitToShowResult()); }
private void FakeOpenItem(int index) { if (result.PrizeValue > 1) { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioWin); btTiepTuc.VKInteractable = result.RemainTurn > 0; } else { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioFail); } imgItems[index].sprite = sprItems[result.PrizeValue > 1 ? 1 : 2]; int numBomb = Random.Range(1, 3); if (result.PrizeValue < 1) { numBomb--; } List <int> otherIndexs = new List <int>(); for (int i = 0; i < imgItems.Count; i++) { if (i != index) { otherIndexs.Add(i); } } VKCommon.Shuffle(otherIndexs); foreach (int i in otherIndexs) { imgItems[i].sprite = sprItems[numBomb <= 0 ? 1 : 2]; numBomb--; btItems[i].SetupAll(false); } }
// GameOver IEnumerator WaitToAuto() { if (gChets.activeSelf) { StartCoroutine(WaitToShowMultiFinish(uiChests[UnityEngine.Random.Range(0, uiChests.Count)])); } else { List <int> indexs = new List <int>(); for (int i = 0; i < uiItems.Count; i++) { if (!uiItems[i].isOpen) { indexs.Add(i); } } VKCommon.Shuffle(indexs); for (int i = 0; i < bonusItems.Count; i++) { var bonusItem = bonusItems[i]; var uiItem = uiItems[indexs[i]]; uiItem.ShowReward(bonusItem.money, bonusItem.step == bonusGame.CurrentStep ? UILGameSlot25LineBonusItem.BonusItemType2.FINISH : UILGameSlot25LineBonusItem.BonusItemType2.NORMAL); totalWin += bonusItem.money; } SetTotalWin(); yield return(new WaitForSeconds(1f)); gChets.SetActive(true); if (canvasItems != null) { canvasItems.alpha = 0; } uiChests.ForEach(a => a.ClearUI()); StartCoroutine(WaitToShowMultiFinish(uiChests[UnityEngine.Random.Range(0, uiChests.Count)])); } }
IEnumerator RunAnimation(int cardId) { int count = 20; List <int> temp = new List <int>(); for (int i = 0; i < sprCardBlurs.Length; i++) { temp.Add(i); } VKCommon.Shuffle(temp); while (true) { imgCard.sprite = sprCardBlurs[temp[count]]; count--; yield return(new WaitForSeconds(0.05f)); if (count < 0) { break; } } imgCard.sprite = sprCards[cardId]; isRunning = false; }
// 20s for end IEnumerator WaitShowResult(int result, SRSXocXocMyWinLose myWinLose, List <SRSXocXocPlayerWinLose> playerWinLoses) { vkCountDown.StopCountDown(); vkCountDown.gameObject.SetActive(false); List <int> dices = new List <int>(); List <XocXocGate> winGate = new List <XocXocGate>(); switch (result) { case 0: dices = new List <int> { 1, 1, 1, 1 }; winGate.Add(XocXocGate.Even); winGate.Add(XocXocGate.FourDown); break; case 1: dices = new List <int> { 0, 1, 1, 1 }; winGate.Add(XocXocGate.Odd); winGate.Add(XocXocGate.ThreeDown); break; case 2: dices = new List <int> { 1, 1, 0, 0 }; winGate.Add(XocXocGate.Even); break; case 3: dices = new List <int> { 0, 0, 0, 1 }; winGate.Add(XocXocGate.Odd); winGate.Add(XocXocGate.ThreeUp); break; case 4: dices = new List <int> { 0, 0, 0, 0 }; winGate.Add(XocXocGate.Even); winGate.Add(XocXocGate.FourUp); break; } VKCommon.Shuffle(dices); _batdia.InitDice(dices[0], dices[1], dices[2], dices[3]); Database.Instance.UpdateUserMoney(_xocxoc.moneyType, myWinLose.balance); yield return(new WaitForSeconds(1f)); _xocxoc.session.History.Add(result); LoadHistory(); // refund + Banker win double dealerTakeMoney = 0; foreach (var uiGate in uiGates) { if (winGate.Contains(uiGate.gateType)) { uiGate.ShowResult(true); dealerTakeMoney += uiGate.allBet; } else { uiGate.ShowResult(false); Transform transTarget = transSystemChip; if (!string.IsNullOrEmpty(uiGate.accountIdBuyGate)) { var uiPlayerTemp = uiPlayers.FirstOrDefault(a => a._player != null && a._player.AccountId.Equals(uiGate.accountIdBuyGate)); if (uiPlayerTemp != null) { transTarget = uiPlayerTemp.transform; } } MoveWinAuto(ConvertTotalMoneyToChip(uiGate.allBet), uiGate, transTarget); } // anim or refun var winLose = myWinLose.winLose.FirstOrDefault(a => a.Gate == (int)uiGate.gateType); if (winLose != null) { if (_xocxoc.IsDealer()) { // chua lam gi } else { if (winLose.Refund > 0) { uiGate.ShowDataGate(uiGate.allBet, uiGate.meBetOld - winLose.Refund, false); uiGate.ShowNotify("Hoàn tiền\n" + VKCommon.FillColorString(VKCommon.ConvertStringMoney(winLose.Refund), colorRefund)); } } } } yield return(new WaitForSeconds(1.2f)); // show tien an neu la dealer if (_xocxoc.IsDealer() && dealerTakeMoney > 0) { uiPlayerMaster.ShowNotify("+" + VKCommon.FillColorString(VKCommon.ConvertStringMoney(dealerTakeMoney), colorWin)); } // load chip me - player double winPrize = 0; foreach (var uiGate in uiGates) { // me if (!_xocxoc.IsDealer()) { var winLose = myWinLose.winLose.FirstOrDefault(a => a.Gate == (int)uiGate.gateType); if (winLose != null) { if (winLose.Prize > 0) { winPrize += winLose.Prize; MoveWinAuto(ConvertTotalMoneyToChip(winLose.Prize), uiGate, imgMyAvatar.transform); } } } // player if (winGate.Contains(uiGate.gateType)) { foreach (var uiPlayerTemp in uiPlayers) { if (uiPlayerTemp._player != null && uiPlayerTemp.gateBets.ContainsKey(uiGate.gateType)) { MoveWinAuto(ConvertTotalMoneyToChip(uiPlayerTemp.gateBets[uiGate.gateType] * uiGate.multiReward), uiGate, uiPlayerTemp.transform); } } } // gate uiGate.ShowDataGate(0, 0, false); } yield return(new WaitForSeconds(1.2f)); // show money if (winPrize > 0) { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioThang); SetNotifyWinLose(VKCommon.FillColorString("+" + VKCommon.ConvertStringMoney(winPrize), colorWin)); } else if (winPrize < 0) { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioThua); } else { AudioAssistant.Instance.PlaySoundGame(_config.gameId, _config.audioThang); } foreach (var playerData in playerWinLoses) { var uiPlayer = uiPlayers.FirstOrDefault(a => a.IsPlayer(playerData.AccountId)); if (uiPlayer != null) { if (playerData.TotalPrize > 0) { uiPlayer.ShowNotify(VKCommon.FillColorString("+" + VKCommon.ConvertStringMoney(playerData.TotalPrize), colorWin)); uiPlayer.UpdatePlayer(playerData.Balance); } } else if (uiPlayerMaster.gameObject.activeSelf && uiPlayerMaster.IsPlayer(playerData.AccountId)) { uiPlayerMaster.UpdatePlayer(playerData.Balance); } } if (_xocxoc.session.TotalPlayer == 1 && uiPlayerMaster.gameObject.activeSelf) { yield return(new WaitForSeconds(2f)); // fake Update State if (_xocxoc.session.TotalPlayer == 1) { object[] fakeData = new object[4]; fakeData[0] = "0"; fakeData[1] = "0"; fakeData[2] = _xocxoc.session.SessionId; fakeData[3] = _xocxoc.myData.AccountId; HandleChangeState(fakeData); } } }
IEnumerator MachineRunning(Dictionary <int, List <int> > colIds) { if (type == MachineType.SLOT_25_LINE_2 && !isSpinFree) { gFreeWillCards.ForEach(a => a.SetActive(false)); } List <int> indexs = new List <int>(); for (int i = 0; i < configCol; i++) { indexs.Add(i); } if (allowRandomIndex) { VKCommon.Shuffle(indexs); } else if (stepLineRuns.Count == configCol) { indexs = stepLineRuns; } speed = speedNew; foreach (var index in indexs) { yield return(new WaitForSeconds(delayNextColumn / speed)); if (isRunning) { colums[index].StartRun(colIds[index]); } else { break; } } if (isRunning) { yield return(new WaitForSeconds(0.5f)); var col = colums[indexs.Last()]; if (col == null) { yield return(new WaitForSeconds(delayToWaitEnd)); } else { yield return(new WaitUntil(() => col.anim.GetCurrentAnimatorStateInfo(0).IsName(col.animStateIdle))); } // 20 line 2 switch (type) { case MachineType.SLOT_20_LINE: isRunning = false; break; case MachineType.SLOT_25_LINE: { bool isHaveWildCard = false; for (int i = 0; i < colums.Count; i++) { if (colums[i].items.Any(a => a.iconIndex == idItemWill)) { isHaveWildCard = true; gWillCards[i].SetActive(true); } } if (isHaveWildCard) { if (CallBackShowWildItem != null) { CallBackShowWildItem.Invoke(); } yield return(new WaitForSeconds(0.7f)); for (int i = 0; i < gWillCards.Count; i++) { if (gWillCards[i].activeSelf) { foreach (var uiItem in colums[i].items) { if (uiItem.iconIndex != idItemBonus && uiItem.iconIndex != idItemFree && uiItem.iconIndex != idItemJackpot) { uiItem.SetItem(GetIconByIndex(idItemWill), GetAnimatorByIndex(idItemWill), GetSkeletonByIndex(idItemWill), idItemWill); } } } } isRunning = false; yield return(new WaitForSeconds(0.8f)); gWillCards.ForEach(a => a.SetActive(false)); } else { isRunning = false; } } break; case MachineType.SLOT_25_LINE_2: { if (isSpinFree) { isRunning = false; for (int i = 0; i < colums.Count; i++) { for (int j = 0; j < colums[i].items.Count; j++) { if (colums[i].items[j].iconIndex == idItemWill) { gFreeWillCards[colums[i].items[j].index].SetActive(true); } } } } else { bool isHaveWildCard = false; for (int i = 0; i < colums.Count; i++) { if (colums[i].items.Any(a => a.iconIndex == idItemWill)) { isHaveWildCard = true; gWillCards[i].SetActive(true); } } if (isHaveWildCard) { if (CallBackShowWildItem != null) { CallBackShowWildItem.Invoke(); } yield return(new WaitForSeconds(0.7f)); for (int i = 0; i < gWillCards.Count; i++) { if (gWillCards[i].activeSelf) { foreach (var uiItem in colums[i].items) { if (uiItem.iconIndex != idItemBonus && uiItem.iconIndex != idItemFree && uiItem.iconIndex != idItemJackpot) { uiItem.SetItem(GetIconByIndex(idItemWill), GetAnimatorByIndex(idItemWill), GetSkeletonByIndex(idItemWill), idItemWill); } } } } isRunning = false; yield return(new WaitForSeconds(0.8f)); gWillCards.ForEach(a => a.SetActive(false)); } else { isRunning = false; } } } break; } } }