| 
					
				 | 
			
			
				@@ -0,0 +1,462 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using System.Collections; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using UnityEngine; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using UI.ActivityGetYuanXiao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using FairyGUI; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using System.Collections.Generic; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using System.Threading.Tasks; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+namespace GFGGame 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public class ActivityGetYuanXiaoView : BaseView 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private UI_ActivityGetYuanXiaoUI _ui; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private List<YuanXiaoItem> items = new List<YuanXiaoItem>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private PickUpGame _cfg; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private int _activityID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private int _countTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private int _score; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Dictionary<int, int> _collectDict; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Vector3 _catcherInitPos; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private bool _firstIn = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private bool _gamePause = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private float _timer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Dictionary<string, EffectUI> _effectUIDic = new Dictionary<string, EffectUI>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public override void Dispose() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Clear Effect 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            foreach (var v in _effectUIDic) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                EffectUIPool.Recycle(v.Value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_ui != null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _ui.Dispose(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            base.Dispose(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        protected override void OnInit() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            base.OnInit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            packageName = UI_ActivityGetYuanXiaoUI.PACKAGE_NAME; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui = UI_ActivityGetYuanXiaoUI.Create(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            viewCom = _ui.target; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            isReturnView = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hd_yx_bg_2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_collectList.itemRenderer = CollectListRenderer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_btnBack.onClick.Add(OnBtnBack); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _effectUIDic.Add("YXJ_Catch", EffectUIPool.CreateEffectUI(_ui.m_catcher.m_getEffect, "ui_Activity", "YXJ_Catch")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _effectUIDic.Add("YXJ_text_start", EffectUIPool.CreateEffectUI(_ui.m_startEffect, "ui_Activity", "YXJ_text_start")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _effectUIDic.Add("YXJ_gameing_bg_tx", EffectUIPool.CreateEffectUI(_ui.m_bgEffect, "ui_Activity", "YXJ_gameing_bg_tx")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        protected override void OnShown() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            base.OnShown(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            object[] arr = viewData as object[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _cfg = (PickUpGame)arr[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _activityID = (int)arr[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_firstIn) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _firstIn = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _catcherInitPos = _ui.m_catcher.target.position; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ShowGameView(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        protected override void OnHide() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            base.OnHide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HideGameView(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        protected override void AddEventListener() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            base.AddEventListener(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            EventAgent.AddEventListener(ConstMessage.ACTIVITY_GETYUANXIAO_RESET, ResetGame); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        protected override void RemoveEventListener() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            base.RemoveEventListener(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            EventAgent.RemoveEventListener(ConstMessage.ACTIVITY_GETYUANXIAO_RESET, ResetGame); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// 初始化元宵的FGUI组件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <returns></returns> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        YuanXiaoItem InitItemUICom() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            GComponent gcom = UIPackage.CreateObject("ActivityGetYuanXiao", "YuanXiaoItem").asCom; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_YuanXiaoParent.target.AddChild(gcom); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            YuanXiaoItem item = new YuanXiaoItem(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.CreateItem(gcom, _ui.m_catcher.m_catcher, this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return item; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void ClearYuanXiaoList() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < items.Count; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                items[i].Destroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            items.Clear(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// 从对象池中取出对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="type"></param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <returns></returns> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public YuanXiaoItem Get(int type) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            YuanXiaoItem item = items.Find(x => x.GetVisible() == false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (item == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                item = InitItemUICom(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.Init(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return item; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void Restore(YuanXiaoItem item) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            item.SetVisible(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// 生成元宵 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="param"></param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void CreateItems(object param) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!isShowing) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int num = _cfg.resIdArr.Length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<int> roadIndexs = GetRandomRoads(num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < num; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                PickUpCfg pickUpCfg = PickUpCfgArray.Instance.GetCfgsByid(_cfg.resArr[0])[_cfg.resIdArr[i] - 1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                float time = pickUpCfg.speed * 1f / 1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                YuanXiaoItem item = Get(_cfg.resIdArr[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                items.Add(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                int score = pickUpCfg.score; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                item.SetScore(score); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Vector3 startPos = _ui.target.GetChild("start" + roadIndexs[i]).position; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Vector3 endPos = startPos; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                endPos.y = _ui.m_end0.y; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                item.Move(startPos, endPos, time, () => Restore(item)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// 随机路径 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="count"></param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <returns></returns> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private List<int> GetRandomRoads(int count) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<int> resultList = new List<int>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<int> list = new List<int>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < 4; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                list.Add(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int j = 0; j < count; j++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                int randomIndex = Random.Range(0, list.Count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resultList.Add(list[randomIndex]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                list.RemoveAt(randomIndex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return resultList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// 接住元宵 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="item"></param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void GetYuanXiao(YuanXiaoItem item) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 回收组件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Restore(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_countTime == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 显示得分标志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _score += item.GetScore(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_score.text = _score.ToString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_ui.m_c1.selectedIndex == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                UpdateCollectProgress(item.GetYuanXiaoType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                UpdateScore(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ShowFlyScore(item.GetScore()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.m_getEffect.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.m_getEffect.visible = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void ShowFlyScore(int score) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UI_flyScore flyItem = UI_flyScore.Proxy(_ui.m_catcher.m_flyscore.target); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            flyItem.m_score.text = score.ToString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            flyItem.m_t0.Stop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.m_flyscore.target.visible = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            flyItem.m_t0.Play(() => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _ui.m_catcher.m_flyscore.target.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UI_flyScore.ProxyEnd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void SetDragRect() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.target.draggable = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.target.dragBounds = new Rect(-_ui.m_catcher.target.width / 2, _ui.m_catcher.target.y, Screen.width + _ui.m_catcher.target.width, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void StartGame() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CreateItems(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Timers.inst.Add(1, 0, UpdateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Timers.inst.AddUpdate(UpdateGame); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private async void PlayStartAnim() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            GRoot.inst.touchable = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_startEffect.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_startEffect.visible = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            await Task.Delay(820); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            GRoot.inst.touchable = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            StartGame(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void UpdateTime(object param) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!isShowing) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_time.text = TimeUtil.FormattingTimeTo_mmss(_countTime * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            --_countTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_countTime < 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Timers.inst.Remove(UpdateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                GameEnd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void GameEnd() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.target.draggable = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HideGameView(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bool win = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_ui.m_c1.selectedIndex == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                foreach (var v in _collectDict) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (v.Value > 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        win = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (_score < _cfg.targetScore) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    win = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (win) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ViewManager.Show<ActivityGetYuanXiaoSuccessView>(_cfg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ViewManager.Show<ActivityGetYuanXiaoFailView>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void InitData() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _gamePause = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _timer = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _countTime = _cfg.time; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _score = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _collectDict = new Dictionary<int, int>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            items = new List<YuanXiaoItem>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void InitView() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_startEffect.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.m_getEffect.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.m_flyscore.target.visible = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.m_c2.selectedIndex = _cfg.id > PickUpGameArray.Instance.dataArray[0].id ? 1 : 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_time.text = TimeUtil.FormattingTimeTo_mmss(_countTime * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_score.text = _score.ToString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_catcher.target.position = _catcherInitPos; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            InitTarget(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void InitTarget() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 分数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_cfg.targetIdArr.Length == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _ui.m_targetScore.text = _cfg.targetScore.ToString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _ui.m_c1.selectedIndex = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                UpdateScore(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 收集 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (int i = 0; i < _cfg.targetIdArr.Length; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    _collectDict.Add(_cfg.targetIdArr[i][0], _cfg.targetIdArr[i][1]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _ui.m_c1.selectedIndex = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _ui.m_collectList.numItems = _cfg.targetIdArr.Length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void UpdateScore() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_progress.SetVar("cur", _score.ToString()).SetVar("target", _cfg.targetScore.ToString()).FlushVars(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void UpdateCollectProgress(int collectType) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!_collectDict.ContainsKey(collectType)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_collectDict[collectType] > 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                --_collectDict[collectType]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _ui.m_collectList.numItems = _cfg.targetIdArr.Length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void CollectListRenderer(int index, GObject item) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UI_targetItem target = UI_targetItem.Proxy(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            target.m_iconType.url = string.Format("ui://ActivityGetYuanXiao/yx_mb_{0}", _cfg.targetIdArr[index][0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int num = _collectDict[_cfg.targetIdArr[index][0]]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (num == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                target.m_c1.selectedIndex = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                target.m_c1.selectedIndex = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                target.m_num.text = num.ToString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UI_targetItem.ProxyEnd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void ShowGameView() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            InitData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            InitView(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SetDragRect(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PlayStartAnim(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void HideGameView() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Timers.inst.Remove(UpdateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Timers.inst.Remove(UpdateGame); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ClearYuanXiaoList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void ResetGame() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HideGameView(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ShowGameView(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void OnBtnBack() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 暂停游戏 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PauseGame(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AlertMiniGame alertInfo = new AlertMiniGame(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            alertInfo.desc = "确认是否退出游戏?退出游戏直接按失败结算"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            alertInfo.btnConfirmClickAction = () => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            alertInfo.btnCancelClickAction = () => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ContinueGame(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ViewManager.Show<AlertMiniGameView>(alertInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void PauseGame() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _gamePause = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Timers.inst.Remove(UpdateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < items.Count; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                items[i].SetPause(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void ContinueGame() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _gamePause = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Timers.inst.Add(1, 0, UpdateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 0; i < items.Count; i++) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                items[i].SetPause(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void UpdateGame(object param) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (_gamePause) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            _timer += Time.deltaTime * 1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(_timer >= _cfg.dropTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CreateItems(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                _timer = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |