| 
									
										
										
										
											2022-02-11 11:58:24 +00:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | using UnityEngine.UI; | 
					
						
							|  |  |  |  | using DG.Tweening; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public class LevelOpening : MonoBehaviour | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     [SerializeField] RectTransform mRctTopFrame; | 
					
						
							|  |  |  |  |     [SerializeField] RectTransform mRctBottomFrame; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] RectTransform mRctTitleBg; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-11 12:48:27 +00:00
										 |  |  |  |     [SerializeField] CanvasGroup mCvsBg; | 
					
						
							|  |  |  |  |     [SerializeField] CanvasGroup mCvsContent; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     [SerializeField] Image mImgBg; | 
					
						
							| 
									
										
										
										
											2022-02-11 11:58:24 +00:00
										 |  |  |  |     [SerializeField] Text mTxtTitle; | 
					
						
							|  |  |  |  |     [SerializeField] Image mImgLogo; | 
					
						
							|  |  |  |  |     [SerializeField] Image mImgIcon; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private Action mDelExit; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public void Enter(int pLevel, Action pDelExit) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         gameObject.SetActive(true); | 
					
						
							|  |  |  |  |         mDelExit = pDelExit; | 
					
						
							|  |  |  |  |         int tLevelID = GameConfig.Instance.LevelSort[pLevel - 1]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         LevelData tLvData = GameConfig.Instance.GetLevelData(tLevelID); | 
					
						
							|  |  |  |  |         if (ColorUtility.TryParseHtmlString(tLvData.LevelColorCode, out Color tLevelColor)) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mImgBg.color = tLevelColor; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         mTxtTitle.text = "关卡 " + pLevel; | 
					
						
							|  |  |  |  |         mImgLogo.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetLevelLogo(tLevelID)); | 
					
						
							|  |  |  |  |         mImgIcon.sprite = ResourceManager.Instance.LoadRes<Sprite>(Const.Path.GetLevelIconSmall(tLevelID)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //animation | 
					
						
							|  |  |  |  |         mRctTopFrame.anchoredPosition = new Vector2(0, 850); | 
					
						
							|  |  |  |  |         mRctBottomFrame.anchoredPosition = new Vector2(0, -760); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-11 12:48:27 +00:00
										 |  |  |  |         mCvsBg.alpha = 1; | 
					
						
							|  |  |  |  |         mCvsContent.alpha = 1; | 
					
						
							| 
									
										
										
										
											2022-02-11 11:58:24 +00:00
										 |  |  |  |         mRctTitleBg.localScale = new Vector3(1, 0, 1); | 
					
						
							|  |  |  |  |         mImgLogo.rectTransform.anchoredPosition = new Vector2(600, 0); | 
					
						
							| 
									
										
										
										
											2022-02-15 04:16:18 +00:00
										 |  |  |  |         mImgIcon.rectTransform.localScale = Vector3.one * 1.2f; | 
					
						
							|  |  |  |  |         mImgIcon.color = new Color(1, 1, 1, 0); | 
					
						
							| 
									
										
										
										
											2022-02-11 11:58:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         Sequence tAniSequence = DOTween.Sequence(); | 
					
						
							|  |  |  |  |         tAniSequence.Append(mRctTopFrame.DOAnchorPosY(360, 0.5f)); | 
					
						
							|  |  |  |  |         tAniSequence.Join(mRctBottomFrame.DOAnchorPosY(-360, 0.5f)); | 
					
						
							|  |  |  |  |         tAniSequence.Join(mImgLogo.rectTransform.DOAnchorPosX(-320, 0.5f).SetEase(Ease.InSine)); | 
					
						
							|  |  |  |  |         tAniSequence.Append(mImgLogo.rectTransform.DOSizeDelta(new Vector2(550, mImgLogo.rectTransform.sizeDelta.y), 0.15f).SetEase(Ease.OutSine)); | 
					
						
							|  |  |  |  |         tAniSequence.Append(mImgLogo.rectTransform.DOSizeDelta(new Vector2(640, mImgLogo.rectTransform.sizeDelta.y), 0.15f).SetEase(Ease.InSine)); | 
					
						
							|  |  |  |  |         tAniSequence.Append(mRctTitleBg.DOScale(Vector3.one, 0.3f).SetEase(Ease.OutBack)); | 
					
						
							| 
									
										
										
										
											2022-02-15 04:16:18 +00:00
										 |  |  |  |         tAniSequence.Append(mImgIcon.rectTransform.DOScale(Vector3.one, 0.3f).SetEase(Ease.OutBounce)); | 
					
						
							|  |  |  |  |         tAniSequence.Join(mImgIcon.DOFade(1, 0.1f)); | 
					
						
							| 
									
										
										
										
											2022-02-11 11:58:24 +00:00
										 |  |  |  |         tAniSequence.AppendInterval(0.8f); | 
					
						
							|  |  |  |  |         tAniSequence.AppendCallback(Exit); | 
					
						
							| 
									
										
										
										
											2022-02-11 12:48:27 +00:00
										 |  |  |  |         tAniSequence.Append(mCvsBg.DOFade(0, 0.3f)); | 
					
						
							|  |  |  |  |         tAniSequence.Join(mCvsContent.DOFade(0, 0.3f)); | 
					
						
							|  |  |  |  |         tAniSequence.Join(mRctTopFrame.DOAnchorPosY(850, 0.5f)); | 
					
						
							| 
									
										
										
										
											2022-02-11 11:58:24 +00:00
										 |  |  |  |         tAniSequence.Join(mRctBottomFrame.DOAnchorPosY(-760, 0.5f)); | 
					
						
							|  |  |  |  |         tAniSequence.AppendCallback(Over); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void Exit() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mDelExit?.Invoke(); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     private void Over() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         gameObject.SetActive(false); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |