IEnumerator WaitForUnlock(int seconds) { if (seconds == 0) { CheckLock(); yield break; } int showHours = seconds / 3600; int showMinutes = (seconds % 3600) / 60; int showSeconds = seconds % 60; text_locktime.text = "Unlock after " + (showHours > 9 ? showHours.ToString() : "0" + showHours) + ":" + (showMinutes > 9 ? showMinutes.ToString() : "0" + showMinutes) + ":" + (showSeconds > 9 ? showSeconds.ToString() : "0" + showSeconds); while (seconds > 0) { yield return(MG_Manager.WaitForSeconds(1)); seconds--; if (seconds == 0) { CheckLock(); yield break; } showHours = seconds / 3600; showMinutes = (seconds % 3600) / 60; showSeconds = seconds % 60; text_locktime.text = "Unlock after " + (showHours > 9 ? showHours.ToString() : "0" + showHours) + ":" + (showMinutes > 9 ? showMinutes.ToString() : "0" + showMinutes) + ":" + (showSeconds > 9 ? showSeconds.ToString() : "0" + showSeconds); } }
IEnumerator AutoShiningLight() { bool isA = false; while (true) { yield return(MG_Manager.WaitForSeconds(0.1f)); isA = !isA; img_Light.sprite = isA ? sp_LightA : sp_LightB; } }
IEnumerator WaitShowNothanks() { if (img_giveup.color.a > 0) { yield break; } yield return(MG_Manager.WaitForSeconds(1)); while (img_giveup.color.a < 1) { yield return(null); img_giveup.color += Color.white * Time.unscaledDeltaTime; } img_giveup.color = Color.white; img_giveup.raycastTarget = true; }
IEnumerator WaitShowNothanks() { if (cg_nothanks.alpha > 0) { yield break; } yield return(MG_Manager.WaitForSeconds(1)); while (cg_nothanks.alpha < 1) { yield return(null); cg_nothanks.alpha += Time.unscaledDeltaTime * 2; } cg_nothanks.alpha = 1; cg_nothanks.blocksRaycasts = true; }
IEnumerator WaitForClearScratchCard() { Material maskMat = img_Mask.material; float alpha = 1; yield return(null); for (int i = 0; i < 9; i++) { if (cardsIndex[i] < 0) { while (alpha > 0) { yield return(null); alpha -= Time.unscaledDeltaTime * 5; if (alpha < 0) { alpha = 0; } maskMat.SetFloat(Mat_Alpha_Key, alpha); } yield return(MG_Manager.WaitForSeconds(0.5f)); switch (rewardType) { case -1: MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdDouble, MG_RewardType.Gold, rewardNum); break; case -2: MG_Manager.Instance.Show_CashRewardPanel(MG_RewardPanelType.AdClaim, rewardNum); break; case -3: MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdRandom, MG_RewardType.SSS, rewardNum); break; } MG_Manager.Instance.Add_Save_ScratchTicket(-1); break; } } isClearing = false; }
IEnumerator WaitForClickDiceGuid() { hasClickGuid = false; canClickButton = false; yield return(MG_Manager.WaitForSeconds(1)); canClickButton = true; while (true) { if (hasClickGuid) { break; } yield return(null); } trans_guidMask.SetAsLastSibling(); btn_SpecialToken.transform.SetAsLastSibling(); trans_guidBase.localScale = Vector3.one; text_guidDes.transform.localScale = Vector3.one; trans_guidDown.transform.localScale = Vector3.one; img_guidIcon.sprite = MenuAtlas.GetSprite(str_GuidStarcoin_name); img_guidBG.sprite = MenuAtlas.GetSprite(str_OrangeBgSP_name); text_guidDes.text = str_guidStarcoin; hasClickGuid = false; canClickButton = false; yield return(MG_Manager.WaitForSeconds(1)); canClickButton = true; while (true) { yield return(null); if (hasClickGuid) { break; } } trans_guidMask.SetParent(transform); trans_guidMask.gameObject.SetActive(false); MG_Manager.Instance.isGuid = false; MG_Manager.Instance.next_GuidType = MG_Guid_Type.Null; }
IEnumerator WaitShowNothanks() { if (text_nothanks.color.a > 0) { yield break; } yield return(MG_Manager.WaitForSeconds(1)); float progress = 0; while (progress < 1) { yield return(null); progress += Time.unscaledDeltaTime * 2; text_nothanks.color = new Color32(color_EndThanks.r, color_EndThanks.g, color_EndThanks.b, (byte)(255 * progress)); } text_nothanks.color = color_EndThanks; text_nothanks.raycastTarget = true; }
IEnumerator WaitForClickScratchGuid() { hasClickGuid = false; canClickButton = false; yield return(MG_Manager.WaitForSeconds(1)); canClickButton = true; while (true) { if (hasClickGuid) { break; } yield return(null); } trans_guidMask.SetParent(transform); trans_guidMask.gameObject.SetActive(false); MG_Manager.Instance.isGuid = false; MG_Manager.Instance.next_GuidType = MG_Guid_Type.Null; }
IEnumerator TimeClock(int nextEnergyTime) { while (true) { yield return(MG_Manager.WaitForSeconds(1)); if (nextEnergyTime == 1) { int currentEnergy = MG_Manager.Instance.AddEnergyNatural(); nextEnergyTime = MG_SaveManager.RevertDiceLifeTimePer; text_RollNum.text = currentEnergy + " / " + MG_SaveManager.DiceMaxLife; } else { nextEnergyTime--; } if (noGift) { text_GiftNum.text = "After " + GetStringTime(); } } }
IEnumerator WaitRoateEnd() { img_midhandle.color = Color.clear; float endAngleZ = (-90 - 30 * rewardIndex) % 360; if (endAngleZ < 0) { endAngleZ += 360; } float rotateSpeed = 800; float rotateBackSpeed = 300; float time = 0.6f; bool isStop = false; bool isBack = false; bool isRight = false; AudioSource spinAS = MG_Manager.Play_SpinSlots(); while (!isStop) { yield return(null); time -= Time.unscaledDeltaTime; if (time <= 0) { if (!isRight) { rect_wheel.localEulerAngles = new Vector3(0, 0, endAngleZ); isRight = true; } if (!isBack) { rotateBackSpeed -= 40; rect_wheel.Rotate(new Vector3(0, 0, -Time.unscaledDeltaTime * rotateBackSpeed)); if (rotateBackSpeed <= 0) { isBack = true; } } else { rotateBackSpeed += 20; rect_wheel.Rotate(new Vector3(0, 0, Time.unscaledDeltaTime * rotateBackSpeed)); float angleZ = rect_wheel.localEulerAngles.z % 360; if (angleZ < 0) { angleZ += 360; } if (Mathf.Abs(angleZ - endAngleZ) < 4) { rect_wheel.localEulerAngles = new Vector3(0, 0, endAngleZ); isStop = true; } } } else { rect_wheel.Rotate(new Vector3(0, 0, -Time.unscaledDeltaTime * rotateSpeed)); } } spinAS.Stop(); yield return(null); img_midhandle.color = Color.white; yield return(MG_Manager.WaitForSeconds(0.3f)); img_midhandle.color = Color.clear; yield return(MG_Manager.WaitForSeconds(0.3f)); img_midhandle.color = Color.white; yield return(MG_Manager.WaitForSeconds(0.3f)); if (MG_Manager.Instance.Get_Save_WheelTotalTimes() % 2 == 0) { MG_Manager.ShowIV(OnIntersititialCallback, "wheel Interstitial video"); } else { OnIntersititialCallback(); } }
IEnumerator StartSpin() { MG_Manager.Instance.SendAdjustSlotsEvent(); MG_Manager.Instance.canChangeGame = false; Material mt_L = img_L.material; Material mt_M = img_M.material; Material mt_R = img_R.materialForRendering; float endOffsetY_L = 0; float endOffsetY_M = 0; float endOffsetY_R = 0; if (rewardType == MG_Slots_RewardType.Null) { int count = dic_type_offsetY.Count; int random_L_Index = Random.Range(0, count); int random_M_Index = Random.Range(0, count); int random_R_Index; if (random_L_Index == random_M_Index) { do { random_R_Index = Random.Range(0, count); }while (random_R_Index == random_L_Index); } else { random_R_Index = Random.Range(0, count); } int indexOrder = 0; foreach (float y in dic_type_offsetY.Values) { if (indexOrder == random_L_Index) { endOffsetY_L = y; } if (indexOrder == random_M_Index) { endOffsetY_M = y; } if (indexOrder == random_R_Index) { endOffsetY_R = y; } indexOrder++; } } else if (rewardType == MG_Slots_RewardType.SS_Other) { endOffsetY_L = endOffsetY_M = dic_type_offsetY[(int)MG_Slots_RewardType.SSS]; int count = dic_type_offsetY.Count; int random_R_Index; do { random_R_Index = Random.Range(0, count); int index = 0; foreach (float y in dic_type_offsetY.Values) { if (index == random_R_Index) { endOffsetY_R = y; break; } index++; } }while (endOffsetY_R == endOffsetY_L); } else { endOffsetY_L = endOffsetY_M = endOffsetY_R = dic_type_offsetY[(int)rewardType]; } float spinTime_L = 2; float spinTime_M = 3f; float spinTime_R = 4; float timer = 0; float spinSpeed; float backSpeed_L = 0.005f; float backSpeed_M = 0.005f; float backSpeed_R = 0.005f; float backTimer_L = 0; float backTimer_M = 0; float backTimer_R = 0; float startOffsetY_L = mt_L.GetTextureOffset(mat_mainTex_Key).y; float startOffsetY_M = mt_M.GetTextureOffset(mat_mainTex_Key).y; float startOffsetY_R = mt_R.GetTextureOffset(mat_mainTex_Key).y; bool stop_L = false; bool back_L = false; bool stop_M = false; bool back_M = false; bool stop_R = false; bool back_R = false; StartCoroutine("AutoShiningLight"); AudioSource as_Spin = MG_Manager.Play_SpinSlots(); while (!stop_R || !stop_M || !stop_L) { yield return(null); timer += Time.unscaledDeltaTime * 2; spinSpeed = Time.unscaledDeltaTime * 2.6f; startOffsetY_L += spinSpeed; startOffsetY_M += spinSpeed; startOffsetY_R += spinSpeed; if (!stop_L) { if (timer < spinTime_L) { mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, startOffsetY_L)); } else { if (!back_L) { backSpeed_L -= 0.0005f; backTimer_L += backSpeed_L; mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_L + backTimer_L)); if (backSpeed_L <= 0) { back_L = true; } } else { backSpeed_L -= 0.002f; backTimer_L += backSpeed_L; mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_L + backTimer_L)); if (backTimer_L <= 0) { mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_L)); stop_L = true; } } } } if (!stop_M) { if (timer < spinTime_M) { mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, startOffsetY_M)); } else { if (!back_M) { backSpeed_M -= 0.0005f; backTimer_M += backSpeed_M; mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_M + backTimer_M)); if (backSpeed_M <= 0) { back_M = true; } } else { backSpeed_M -= 0.002f; backTimer_M += backSpeed_M; mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_M + backTimer_M)); if (backTimer_M <= 0) { mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_M)); stop_M = true; } } } } if (!stop_R) { if (timer < spinTime_R) { mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, startOffsetY_R)); } else { if (!back_R) { backSpeed_R -= 0.0005f; backTimer_R += backSpeed_R; mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_R + backTimer_R)); if (backSpeed_R <= 0) { back_R = true; } } else { backSpeed_R -= 0.002f; backTimer_R += backSpeed_R; mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_R + backTimer_R)); if (backTimer_R <= 0) { mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_R)); stop_R = true; } } } } } as_Spin.Stop(); yield return(MG_Manager.WaitForSeconds(0.5f)); StopCoroutine("AutoShiningLight"); switch (rewardType) { case MG_Slots_RewardType.Cash: MG_Manager.Instance.Show_CashRewardPanel(MG_RewardPanelType.AdClaim, rewardNum); break; case MG_Slots_RewardType.Diamond: rewardNum -= rewardNum % 10; MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdRandom, MG_RewardType.Diamond, rewardNum); break; case MG_Slots_RewardType.Gold: rewardNum -= rewardNum % 10; MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdDouble, MG_RewardType.Gold, rewardNum); break; case MG_Slots_RewardType.Cherry: MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdRandom, MG_RewardType.Cherry, rewardNum); break; case MG_Slots_RewardType.Orange: MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdRandom, MG_RewardType.Orange, rewardNum); break; case MG_Slots_RewardType.Watermalen: MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdRandom, MG_RewardType.Watermalen, rewardNum); break; case MG_Slots_RewardType.Gift: MG_Manager.Instance.Random_DiceOrExtraReward(MG_PopRewardPanel_RewardType.Extra); break; default: break; } yield return(null); CheckIsLock(); UpdateSpinButtonState(MG_SaveManager.Gold); isSpining = false; MG_Manager.Instance.canChangeGame = true; }
IEnumerator StartSpin() { Material mt_L = img_L.material; Material mt_M = img_M.material; Material mt_R = img_R.materialForRendering; float endOffsetY_L = 0; float endOffsetY_M = 0; float endOffsetY_R = 0; if (rewardNum == 0) { int count = dic_name_offsetY.Count; int random_L_Index = Random.Range(0, count); int random_M_Index = Random.Range(0, count); int random_R_Index; if (random_L_Index == random_M_Index) { do { random_R_Index = Random.Range(0, count); }while (random_R_Index == random_L_Index); } else { random_R_Index = Random.Range(0, count); } int indexOrder = 0; foreach (float y in dic_name_offsetY.Values) { if (indexOrder == random_L_Index) { endOffsetY_L = y; } if (indexOrder == random_M_Index) { endOffsetY_M = y; } if (indexOrder == random_R_Index) { endOffsetY_R = y; } indexOrder++; } } else { string key = (rewardIsGold ? "Gold" : "Cash") + rewardNum; if (dic_name_offsetY.TryGetValue(key, out float offsetY)) { endOffsetY_L = endOffsetY_M = endOffsetY_R = offsetY; } else { Debug.LogError("Get MG_DiceSlotsRewardOffsetY Error : key is not exist in dict. key : " + key); isSpining = false; yield break; } } float spinTime_L = 2; float spinTime_M = 3f; float spinTime_R = 4; float timer = 0; float spinSpeed; float backSpeed_L = 0.005f; float backSpeed_M = 0.005f; float backSpeed_R = 0.005f; float backTimer_L = 0; float backTimer_M = 0; float backTimer_R = 0; float startOffsetY_L = mt_L.GetTextureOffset(mat_mainTex_Key).y; float startOffsetY_M = mt_M.GetTextureOffset(mat_mainTex_Key).y; float startOffsetY_R = mt_R.GetTextureOffset(mat_mainTex_Key).y; bool stop_L = false; bool back_L = false; bool stop_M = false; bool back_M = false; bool stop_R = false; bool back_R = false; StartCoroutine("AutoShiningLight"); AudioSource as_Spin = MG_Manager.Play_SpinSlots(); while (!stop_R || !stop_M || !stop_L) { yield return(null); timer += Time.unscaledDeltaTime * 2; spinSpeed = Time.unscaledDeltaTime * 2.6f; startOffsetY_L += spinSpeed; startOffsetY_M += spinSpeed; startOffsetY_R += spinSpeed; if (!stop_L) { if (timer < spinTime_L) { mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, startOffsetY_L)); } else { if (!back_L) { backSpeed_L -= 0.0005f; backTimer_L += backSpeed_L; mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_L + backTimer_L)); if (backSpeed_L <= 0) { back_L = true; } } else { backSpeed_L -= 0.002f; backTimer_L += backSpeed_L; mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_L + backTimer_L)); if (backTimer_L <= 0) { mt_L.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_L)); stop_L = true; } } } } if (!stop_M) { if (timer < spinTime_M) { mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, startOffsetY_M)); } else { if (!back_M) { backSpeed_M -= 0.0005f; backTimer_M += backSpeed_M; mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_M + backTimer_M)); if (backSpeed_M <= 0) { back_M = true; } } else { backSpeed_M -= 0.002f; backTimer_M += backSpeed_M; mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_M + backTimer_M)); if (backTimer_M <= 0) { mt_M.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_M)); stop_M = true; } } } } if (!stop_R) { if (timer < spinTime_R) { mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, startOffsetY_R)); } else { if (!back_R) { backSpeed_R -= 0.0005f; backTimer_R += backSpeed_R; mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_R + backTimer_R)); if (backSpeed_R <= 0) { back_R = true; } } else { backSpeed_R -= 0.002f; backTimer_R += backSpeed_R; mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_R + backTimer_R)); if (backTimer_R <= 0) { mt_R.SetTextureOffset(mat_mainTex_Key, new Vector2(finalOffsetX, endOffsetY_R)); stop_R = true; } } } } } as_Spin.Stop(); img_buttonText.sprite = sp_adAgain; yield return(MG_Manager.WaitForSeconds(0.5f)); StopCoroutine("AutoShiningLight"); if (rewardNum == 0) { isSpining = false; StartCoroutine("WaitShowNothanks"); } else { MG_UIManager.Instance.ClosePopPanelAsync(MG_PopPanelType.DiceSlotsPanel); if (rewardIsGold) { MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdRandom, MG_RewardType.Gold, rewardNum, rewardMutiple); } else { MG_Manager.Instance.Show_CashRewardPanel(MG_RewardPanelType.AdClaim, rewardNum, rewardMutiple); } } }
IEnumerator StartMove(MG_MenuFlyTarget _flyTarget, Action <MG_MenuFlyTarget> callback) { float spreadTime = 0; float height = 50; while (spreadTime <= 0.2f) { yield return(null); spreadTime += Time.unscaledDeltaTime; float progress = spreadTime * 5; for (int i = 0; i < flyNum; i++) { list_allFly[i].position = Vector3.Lerp(StartPos, list_allEndPos[i], progress); list_allFly[i].position += new Vector3(0, -(spreadTime - 0.1f) * (spreadTime - 0.1f) * height * 100 + height, 0); } } yield return(null); for (int i = 0; i < flyNum; i++) { list_allFly[i].position = list_allEndPos[i]; } yield return(null); while (spreadTime <= 0.3f) { yield return(null); spreadTime += Time.unscaledDeltaTime; for (int i = 0; i < flyNum; i++) { list_allFly[i].position = list_allEndPos[i] + new Vector3(0, -(spreadTime - 0.25f) * (spreadTime - 0.25f) * 8000 + 20, 0); } } yield return(MG_Manager.WaitForSeconds(0.5f)); float flyTime = 0; float delay = 0.3f; int startIndex = 0; while (startIndex <= flyNum - 1) { yield return(null); flyTime += Time.unscaledDeltaTime * 5; float progress; for (int i = startIndex; i < flyNum; i++) { if (flyTime - i * delay >= 1) { callback(_flyTarget); startIndex = i + 1; list_allFlyImage[i].color = Color.clear; progress = 1; MG_Manager.Play_FlyOver(); } else { progress = flyTime; } float thisProgress = progress - i * delay; list_allFly[i].position = Vector3.Lerp(list_allEndPos[i], TargetPos, thisProgress); } } canvasGroup.alpha = 0; canvasGroup.blocksRaycasts = false; }