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(new WaitForSeconds(0.5f * Time.timeScale)); 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.AdDouble, 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.AdClaim, MG_RewardType.Cherry, rewardNum); break; case MG_Slots_RewardType.Orange: MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdClaim, MG_RewardType.Orange, rewardNum); break; case MG_Slots_RewardType.Watermalen: MG_Manager.Instance.Show_MostRewardPanel(MG_RewardPanelType.AdClaim, 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_Manager.Instance.Get_Save_Gold()); isSpining = false; MG_Manager.Instance.canChangeGame = true; }
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() { 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(new WaitForSeconds(0.5f * Time.timeScale)); 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.AdRandom, rewardNum, rewardMutiple); } } }