Jelajahi Sumber

摘星砍掉一波特效 跟加入一波特效的容错.

hexiaojie 6 bulan lalu
induk
melakukan
76465c23d6

+ 278 - 259
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxBonusShowView.cs

@@ -1,10 +1,10 @@
-using UnityEngine;
 using FairyGUI;
 using UI.LuckyBox;
 using System.Collections.Generic;
 using System.Collections;
 using cfg.GfgCfg;
 using ET;
+using System;
 
 namespace GFGGame
 {
@@ -13,25 +13,31 @@ namespace GFGGame
         private UI_LuckBoxBonusShowUI _ui;
         private List<ItemData> _rewardList = new List<ItemData>();
         private List<ItemData> _rewardItemList = new List<ItemData>();
-        private Dictionary<int, Dictionary<int, EffectUI>> _effListTen = new Dictionary<int, Dictionary<int, EffectUI>>();
+
+        private Dictionary<int, Dictionary<int, EffectUI>> _effListTen =
+            new Dictionary<int, Dictionary<int, EffectUI>>();
+
         private Dictionary<int, EffectUI> _effList = new Dictionary<int, EffectUI>();
         private Dictionary<int, bool> _itemHasNew = new Dictionary<int, bool>();
 
         private Dictionary<int, int> _itemIdList = new Dictionary<int, int>();
         private Dictionary<int, GComponent> _itemObjList = new Dictionary<int, GComponent>();
-        private List<int> _recordOpenIndex = new List<int>();  //记录打开过得item位置
-        private List<int> _recordTurnIndex = new List<int>();  //记录播放过item位置
-        private int _chooseIndex = -1;  //当前选中的index
-        private int _countShow = 0;   //第几次展示
-        private bool _handClick = false;   //手动点击开启
-        private bool _AnimationWait = true;   //抽卡动画等待加载完毕
-        bool _touchLoaBg = true;    //防止点击背景事件太快
+        private List<int> _recordOpenIndex = new List<int>(); //记录打开过得item位置
+        private List<int> _recordTurnIndex = new List<int>(); //记录播放过item位置
+        private int _chooseIndex = -1; //当前选中的index
+        private int _countShow = 0; //第几次展示
+        private bool _handClick = false; //手动点击开启
+        private bool _AnimationWait = true; //抽卡动画等待加载完毕
+        bool _touchLoaBg = true; //防止点击背景事件太快
 
         private EffectUI _effectUI1;
         private EffectUI _effectUI2;
         private EffectUI _effectUI3;
         private Dictionary<string, EffectUI> _effectUIDic = new Dictionary<string, EffectUI>();
 
+        private bool _allEffectsLoaded = false;
+        private int _loadingEffectCount = 0;
+
         public override void Dispose()
         {
             EffectUIPool.Recycle(_effectUI1);
@@ -41,6 +47,19 @@ namespace GFGGame
             EffectUIPool.Recycle(_effectUI3);
             _effectUI3 = null;
 
+            ClearAllEffects();
+
+            if (_ui != null)
+            {
+                _ui.Dispose();
+                _ui = null;
+            }
+
+            base.Dispose();
+        }
+
+        private void ClearAllEffects()
+        {
             for (int key = 0; key < _effListTen.Count; key++)
             {
                 if (_effListTen.ContainsKey(key))
@@ -55,6 +74,7 @@ namespace GFGGame
                     }
                 }
             }
+
             _effListTen.Clear();
 
             for (int key = 0; key < _effList.Count; key++)
@@ -65,14 +85,15 @@ namespace GFGGame
                     _effList[key] = null;
                 }
             }
+
             _effList.Clear();
 
-            if (_ui != null)
+            foreach (var v in _effectUIDic)
             {
-                _ui.Dispose();
-                _ui = null;
+                EffectUIPool.Recycle(v.Value);
             }
-            base.Dispose();
+
+            _effectUIDic.Clear();
         }
 
         protected override void OnInit()
@@ -84,17 +105,7 @@ namespace GFGGame
             isfullScreen = true;
 
             _ui.m_loaBg.onClick.Add(OnClickLoaBg);
-            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
-
             _ui.m_BtnPass.onClick.Add(OnClickBtnPass);
-
-            UpdateEffect();
-        }
-        private void UpdateEffect()
-        {
-            _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing");
-            _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI");
-            _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
         }
 
         protected override void AddEventListener()
@@ -113,36 +124,13 @@ namespace GFGGame
             EventAgent.RemoveEventListener(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE, OthershowViewClose);
         }
 
-        protected void OthershowViewClose()
-        {
-            _ui.m_touchFlipOpen.touchable = false;
-        }
-
-        protected void ReferNextShow()
-        {
-            if (GetSuitItemController.isAuto)
-                return;
-
-            int suitId = 0;
-            if(_itemIdList.ContainsKey(_chooseIndex))
-                suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemIdList[_chooseIndex]);
-
-            if (_chooseIndex != -1 && suitId > 0)
-                ClickItem(_chooseIndex);
-            else
-            {
-                if (_handClick)
-                {
-                    _handClick = false;
-                    _ui.m_touchFlipOpen.touchable = false;
-                }
-            }
-        }
-
         protected override void OnShown()
         {
             base.OnShown();
+
+            _allEffectsLoaded = false;
             _touchLoaBg = false;
+            _rewardList.Clear();
             _rewardList.AddRange(this.viewData as List<ItemData>);
             _itemIdList.Clear();
             _itemObjList.Clear();
@@ -151,7 +139,37 @@ namespace GFGGame
             _itemHasNew.Clear();
             _ui.m_BtnPass.visible = false;
             _ui.m_touchFlipOpen.touchable = false;
-            
+
+            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
+
+            // 异步加载所有特效
+            Timers.inst.StartCoroutine(LoadAllEffects(() =>
+            {
+                _allEffectsLoaded = true;
+                SetupViewAfterEffectsLoaded();
+            }));
+        }
+
+        private IEnumerator LoadAllEffects(Action onComplete)
+        {
+            // 加载背景特效
+            _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing");
+            _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI");
+            _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
+
+            // 等待所有背景特效加载完成
+            while (_effectUI1.GetObj() == null || _effectUI2.GetObj() == null ||
+                   _effectUI3.GetObj() == null)
+            {
+                yield return null;
+            }
+
+            onComplete?.Invoke();
+        }
+
+        private void SetupViewAfterEffectsLoaded()
+        {
+            if (!_allEffectsLoaded) return;
 
             if (_rewardList.Count == 1)
             {
@@ -166,7 +184,8 @@ namespace GFGGame
                     UpdateItem(_ui.target.GetChild("item" + i).asCom, i, 10);
                 }
             }
-            //修改,因为加了抽奖动画,在进入后就直接筛选掉所有不是新的
+
+            // 修改,因为加了抽奖动画,在进入后就直接筛选掉所有不是新的
             for (int i = 0; i < _rewardList.Count; i++)
             {
                 UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(_itemObjList[i]);
@@ -175,38 +194,38 @@ namespace GFGGame
                     _recordTurnIndex.Add(i);
                     _recordOpenIndex.Add(i);
                 }
+
                 UI_LuckyBoxBonusShowItem.ProxyEnd();
             }
-            if(GetSuitItemController.isAuto)
+
+            if (GetSuitItemController.isAuto)
             {
                 OnClickBtnPass();
             }
-            Timers.inst.Add(0.5f, 1, UpDataTimeTouchLoaBg); 
+
+            Timers.inst.Add(0.5f, 1, UpDataTimeTouchLoaBg);
         }
 
         protected override void OnHide()
         {
             _rewardList.Clear();
-
             base.OnHide();
+
             Timers.inst.Remove(UpDataTime);
             Timers.inst.Remove(UpClickDataTime);
             Timers.inst.Remove(touchFlipOpen);
             Timers.inst.Remove(UpDataTimeTouchLoaBg);
+
             GetSuitItemController.isAuto = false;
             _touchLoaBg = true;
 
-            foreach (var v in _effectUIDic)
-            {
-                EffectUIPool.Recycle(v.Value);
-            }
-
-            _effectUIDic.Clear();
             EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_BONUS_VIEW_CLOSE);
         }
 
         private void UpdateItem(GComponent com, int index, int countType)
         {
+            if (!_allEffectsLoaded) return;
+
             UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(com);
             ItemData itemData = _rewardList[index];
             ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemData.id);
@@ -219,63 +238,20 @@ namespace GFGGame
             // 圆盘出现时等待玩家点击的特效
             switch (itemCfg.Rarity)
             {
-                case 1:
-
-                    break;
-                case 2:
-
-                    break;
                 case 3:
-                    _effectUIDic.Add("CK_Loop_Wait_Chen" + index, EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_Chen"));
+                    _effectUIDic.Add("CK_Loop_Wait_Chen" + index,
+                        EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_Chen"));
                     break;
                 case 4:
-                    _effectUIDic.Add("CK_Loop_Wait_GS" + index, EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_GS"));
+                    _effectUIDic.Add("CK_Loop_Wait_GS" + index,
+                        EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_GS"));
                     break;
                 case 5:
-                    _effectUIDic.Add("CK_Loop_Wait_Jin" + index, EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_Jin"));
+                    _effectUIDic.Add("CK_Loop_Wait_Jin" + index,
+                        EffectUIPool.CreateEffectUI(item.m_waitClick_eff, "ui_LuckyBox", "CK_Loop_Wait_Jin"));
                     break;
             }
 
-            //带特效的处理先注释
-            //item.m_comIcon.m_holder.visible = false;
-            //item.m_comIcon.m_holder1.visible = false;
-            //if (itemCfg.rarity > 2) { 
-            //    string resPath = itemCfg.rarity == ConstDressRarity.Rarity_TIANYI ? "CK_all_01" : "CK_all_02";
-            //    GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1;
-            //    holder.visible = true;
-            //    if (countType == 10 && (!_effListTen.ContainsKey(index) ||
-            //        ((itemCfg.rarity == 3 && !_effListTen[index].ContainsKey(0)) || (itemCfg.rarity == 4 && !_effListTen[index].ContainsKey(1)))))
-            //    {
-            //        EffectUI _effectUI = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath);
-
-            //        if (!_effListTen.ContainsKey(index))
-            //        {
-            //            Dictionary<int, EffectUI> effectList = new Dictionary<int, EffectUI>();
-            //            if (itemCfg.rarity == 3)
-            //                effectList.Add(0, _effectUI);
-            //            else if (itemCfg.rarity == 4)
-            //                effectList.Add(1, _effectUI);
-            //            _effListTen.Add(index, effectList);
-            //        }
-            //        else {
-            //            if (itemCfg.rarity == 3)
-            //                _effListTen[index].Add(0, _effectUI);
-            //            else if (itemCfg.rarity == 4)
-            //                _effListTen[index].Add(1, _effectUI);
-            //        }
-            //    }
-
-            //    if (countType == 1 && 
-            //        ((itemCfg.rarity == 3 && !_effList.ContainsKey(0)) || (itemCfg.rarity == 4 && !_effList.ContainsKey(1))))
-            //    {
-            //        EffectUI _effectUI = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath);
-            //        if (itemCfg.rarity == 3)
-            //            _effList.Add(0, _effectUI);
-            //        else if (itemCfg.rarity == 4)
-            //            _effList.Add(1, _effectUI);
-            //    }
-            //}
-
             int count = 0;
             bool isFirst = false;
             for (int i = 0; i < _rewardList.Count; i++)
@@ -283,16 +259,19 @@ namespace GFGGame
                 if (_rewardList[i].id == itemData.id) count++;
                 if (count == 1 && i == index) isFirst = true;
             }
+
             item.m_comIcon.m_imgNew.visible = count == ItemDataManager.GetItemNum(itemData.id) && isFirst;
             if (_itemHasNew.ContainsKey(index))
                 _itemHasNew[index] = item.m_comIcon.m_imgNew.visible;
             else
                 _itemHasNew.Add(index, item.m_comIcon.m_imgNew.visible);
+
             item.m_t0.Play();
             if (item.target.data == null)
             {
                 item.target.onClick.Add(ShowItemTips);
             }
+
             item.target.data = index;
 
             _itemIdList.Add(index, itemCfg.Id);
@@ -303,10 +282,8 @@ namespace GFGGame
 
         private void ShowItemTips(EventContext context)
         {
-            if (!_touchLoaBg)
-            {
-                return;
-            }
+            if (!_allEffectsLoaded || !_touchLoaBg) return;
+
             _touchLoaBg = false;
             Timers.inst.Add(0.5f, 1, UpDataTimeTouchLoaBg);
 
@@ -314,11 +291,12 @@ namespace GFGGame
             int index = (int)obj.data;
             _chooseIndex = index;
             GoodsItemTipsController.ShowItemTips(_itemIdList[index]);
-            //HandClickItem(index);
         }
 
         private void HandClickItem(int index)
         {
+            if (!_allEffectsLoaded) return;
+
             _ui.m_touchFlipOpen.touchable = true;
             _handClick = true;
             ClickItem(index);
@@ -328,6 +306,8 @@ namespace GFGGame
 
         private void UpClickDataTime(object param = null)
         {
+            if (!_allEffectsLoaded) return;
+
             int index = (int)param;
             Timers.inst.Remove(UpClickDataTime);
             if (_recordTurnIndex.Contains(index) && _recordOpenIndex.Contains(index))
@@ -341,6 +321,8 @@ namespace GFGGame
 
         void ClickItem(int index)
         {
+            if (!_allEffectsLoaded) return;
+
             if (_recordOpenIndex.Count >= _rewardList.Count)
                 _ui.m_BtnPass.visible = false;
 
@@ -364,12 +346,11 @@ namespace GFGGame
 
         private void OnClickLoaBg(EventContext context)
         {
-            if (!_touchLoaBg)
-            {
-                return;
-            }
+            if (!_allEffectsLoaded || !_touchLoaBg) return;
+
             _touchLoaBg = false;
             Timers.inst.Add(0.5f, 1, UpDataTimeTouchLoaBg);
+
             if (_recordOpenIndex.Count >= _rewardList.Count)
             {
                 _chooseIndex = -1;
@@ -391,6 +372,8 @@ namespace GFGGame
 
         private void OnClickBtnPass()
         {
+            if (!_allEffectsLoaded) return;
+
             for (int index = 0; index < _rewardList.Count; index++)
             {
                 if (!_recordOpenIndex.Contains(index))
@@ -402,6 +385,7 @@ namespace GFGGame
                         if (_rewardList[i].id == _rewardList[index].id) count++;
                         if (count == 1 && i == index) isFirst = true;
                     }
+
                     bool open = count == ItemDataManager.GetItemNum(_rewardList[index].id) && isFirst;
 
                     if (!open)
@@ -411,24 +395,31 @@ namespace GFGGame
                     }
                 }
             }
+
             ClickPass();
         }
 
         private void ClickPass()
         {
+            if (!_allEffectsLoaded) return;
+
             GetSuitItemController.isAuto = true;
             _ui.m_touchFlipOpen.touchable = true;
             _ui.m_BtnPass.visible = false;
+
             for (int i = 0; i < _rewardList.Count; i++)
             {
                 TurnItem(i);
             }
+
             //展示获得物品
             Timers.inst.Add(LuckyBoxDataManager.ANIMATION_TIME, 0, UpDataTime);
         }
 
         private void UpDataTime(object param = null)
         {
+            if (!_allEffectsLoaded) return;
+
             _ui.m_touchFlipOpen.touchable = true;
             if (_recordTurnIndex.Count >= _rewardList.Count)
             {
@@ -448,92 +439,178 @@ namespace GFGGame
             }
         }
 
-        //控制展示获得物品界面
         private void ShowTurnItem(int index)
         {
+            if (!_allEffectsLoaded || !_AnimationWait) return;
+
             UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(_itemObjList[index]);
-            if (!_AnimationWait)
+            if (!item.m_comIcon.m_imgNew.visible)
+            {
+                _recordTurnIndex.Add(index);
+                _ui.m_touchFlipOpen.touchable = false;
+                UI_LuckyBoxBonusShowItem.ProxyEnd();
                 return;
+            }
 
+            _countShow += 1;
+            //判断是否有套装需要展示
+            int suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemIdList[index]);
+            ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemIdList[index]);
 
-            if (item.m_comIcon.m_imgNew.visible)
+            if (suitId > 0 && itemCfg.ItemType != ConstItemType.CARD)
             {
-                _countShow += 1;
-                //判断是否有套装需要展示
-                int suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemIdList[index]);
-                ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemIdList[index]);
-                if (suitId > 0 && itemCfg.ItemType != ConstItemType.CARD)
+                if (_countShow == 1)
                 {
-                    if (_countShow == 1)
-                    {
-                        ViewManager.Hide<SuitItemView>();
-                        ViewManager.Hide<LuckyBoxNewCardView>();
-                        ViewManager.Hide<GetSuitItemVIew>();
-                        _rewardItemList.Clear();
-                        _rewardItemList.Add(_rewardList[index]);
-                        ViewManager.Show<LuckyBoxNewDressView>(_rewardItemList);
-                    }
-                    else
+                    ViewManager.Hide<SuitItemView>();
+                    ViewManager.Hide<LuckyBoxNewCardView>();
+                    ViewManager.Hide<GetSuitItemVIew>();
+                    _rewardItemList.Clear();
+                    _rewardItemList.Add(_rewardList[index]);
+                    ViewManager.Show<LuckyBoxNewDressView>(_rewardItemList);
+                }
+                else
+                {
+                    ViewManager.Hide<LuckyBoxNewDressView>();
+                    ViewManager.Hide<LuckyBoxNewCardView>();
+                    int count = 0;
+                    int totalCount = 0;
+                    DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
+
+                    if (_countShow == 2) //展示进度条界面
                     {
-                        ViewManager.Hide<LuckyBoxNewDressView>();
-                        ViewManager.Hide<LuckyBoxNewCardView>();
-                        int count = 0;
-                        int totalCount = 0;
-                        DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
-                        if (_countShow == 2)   //展示进度条界面
+                        int countSuitId = 0;
+                        for (int i = index + 1; i < _rewardList.Count; i++)
                         {
-                            int countSuitId = 0;
-                            for (int i = index + 1; i < _rewardList.Count; i++)
+                            _itemHasNew.TryGetValue(i, out bool isNew);
+                            var itemRewardCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_rewardList[i].id);
+                            if (isNew && itemRewardCfg.ItemType == ConstItemType.DRESS_UP &&
+                                itemRewardCfg.SuitId == suitId)
                             {
-                                _itemHasNew.TryGetValue(i, out bool isNew);
-                                var itemRewardCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_rewardList[i].id);
-                                if (isNew && itemRewardCfg.ItemType == ConstItemType.DRESS_UP && itemRewardCfg.SuitId == suitId) { 
-                                    countSuitId++;
-                                }
-
+                                countSuitId++;
                             }
-                            count = count - countSuitId;
-                            ViewManager.Show<SuitItemView>(new object[] { suitId, countSuitId });
-                        }
-                        else if (_countShow == 3) //展示集齐套装界面
-                        {
-                            ViewManager.Hide<SuitItemView>();
-                            ViewManager.Show<GetSuitItemVIew>(suitId);
-                            _AnimationWait = false;
                         }
 
-                        //判断是否需要显示集齐套装界面(需要的时候晚3个定时器时间)
-                        if (count <= 0 || totalCount <= 0 || count < totalCount || (count >= totalCount && _countShow > 5))
+                        count = count - countSuitId;
+                        ViewManager.Show<SuitItemView>(new object[] { suitId, countSuitId });
+                    }
+                    else if (_countShow == 3) //展示集齐套装界面
+                    {
+                        ViewManager.Hide<SuitItemView>();
+                        ViewManager.Show<GetSuitItemVIew>(suitId);
+                        _AnimationWait = false;
+                    }
+
+                    //判断是否需要显示集齐套装界面(需要的时候晚3个定时器时间)
+                    if (count <= 0 || totalCount <= 0 || count < totalCount || (count >= totalCount && _countShow > 5))
+                    {
+                        _recordTurnIndex.Add(index);
+                        _countShow = 0;
+                        if (_handClick)
                         {
-                            _recordTurnIndex.Add(index);
-                            _countShow = 0;
-                            if (_handClick)
-                            {
-                                _handClick = false;
-                                _ui.m_touchFlipOpen.touchable = false;
-                            }
+                            _handClick = false;
+                            _ui.m_touchFlipOpen.touchable = false;
                         }
                     }
                 }
-                else
-                {
-                    //词牌和不是套装进这里
-                    ViewManager.Hide<SuitItemView>();
-                    ViewManager.Hide<LuckyBoxNewCardView>();
-                    ViewManager.Hide<GetSuitItemVIew>();
-                    _rewardItemList.Clear();
-                    _rewardItemList.Add(_rewardList[index]);
-                    ViewManager.Show<LuckyBoxNewDressView>(_rewardItemList);
-                    _recordTurnIndex.Add(index);
-                    _countShow = 0;
-                    Timers.inst.Add(1.5f, 1, touchFlipOpen);  //防止点击太快
-                }
             }
             else
             {
+                //词牌和不是套装进这里
+                ViewManager.Hide<SuitItemView>();
+                ViewManager.Hide<LuckyBoxNewCardView>();
+                ViewManager.Hide<GetSuitItemVIew>();
+                _rewardItemList.Clear();
+                _rewardItemList.Add(_rewardList[index]);
+                ViewManager.Show<LuckyBoxNewDressView>(_rewardItemList);
                 _recordTurnIndex.Add(index);
-                _ui.m_touchFlipOpen.touchable = false;
+                _countShow = 0;
+                Timers.inst.Add(1.5f, 1, touchFlipOpen); //防止点击太快
             }
+
+            UI_LuckyBoxBonusShowItem.ProxyEnd();
+        }
+
+        private void TurnItem(int index)
+        {
+            if (!_allEffectsLoaded || _recordOpenIndex.Contains(index)) return;
+
+            // 删除 "等待翻开" 的特效
+            if (_effectUIDic.ContainsKey("CK_Loop_Wait_Chen" + index))
+            {
+                EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_Chen" + index]);
+                _effectUIDic.Remove("CK_Loop_Wait_Chen" + index);
+            }
+
+            if (_effectUIDic.ContainsKey("CK_Loop_Wait_GS" + index))
+            {
+                EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_GS" + index]);
+                _effectUIDic.Remove("CK_Loop_Wait_GS" + index);
+            }
+
+            if (_effectUIDic.ContainsKey("CK_Loop_Wait_Jin" + index))
+            {
+                EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_Jin" + index]);
+                _effectUIDic.Remove("CK_Loop_Wait_Jin" + index);
+            }
+
+            UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(_itemObjList[index]);
+            if (!item.m_comIcon.m_imgNew.visible && !_recordTurnIndex.Contains(index))
+            {
+                _recordTurnIndex.Add(index);
+            }
+
+            ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemIdList[index]);
+
+            // 点击特效
+            if (!_effectUIDic.ContainsKey("CK_Cirle_DJ" + index))
+            {
+                _effectUIDic.Add("CK_Cirle_DJ" + index,
+                    EffectUIPool.CreateEffectUI(item.m_comIcon.m_click_eff, "ui_LuckyBox", "CK_Cirle_DJ"));
+            }
+            else
+            {
+                _effectUIDic["CK_Cirle_DJ" + index] =
+                    EffectUIPool.CreateEffectUI(item.m_comIcon.m_click_eff, "ui_LuckyBox", "CK_Cirle_DJ");
+            }
+
+            // 翻开特效
+            switch (itemCfg.Rarity)
+            {
+                case 1:
+                    _effectUIDic.Add("CK_OpenAfter_LanHui_UI" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_HuiLan_UI"));
+                    _effectUIDic.Add("CK_OpenAfter_LanHui_TX" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox",
+                            "CK_OpenAfter_LanHui_TX"));
+                    break;
+                case 2:
+                    _effectUIDic.Add("CK_OpenAfter_LanHui_UI" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_LanHui_UI"));
+                    _effectUIDic.Add("CK_OpenAfter_LanHui_TX" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox",
+                            "CK_OpenAfter_LanHui_TX"));
+                    break;
+                case 3:
+                    _effectUIDic.Add("CK_OpenAfter_Chen_UI" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_Chen_UI"));
+                    _effectUIDic.Add("CK_OpenAfter_Chen_TX" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_Chen_TX"));
+                    break;
+                case 4:
+                    _effectUIDic.Add("CK_OpenAfter_GS_UI" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_GS_UI"));
+                    _effectUIDic.Add("CK_OpenAfter_GS_TX" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_GS_TX"));
+                    break;
+                case 5:
+                    _effectUIDic.Add("CK_OpenAfter_Jin_UI" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_Jin_UI"));
+                    _effectUIDic.Add("CK_OpenAfter_Jin_TX" + index,
+                        EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_Jin_TX"));
+                    break;
+            }
+
+            _recordOpenIndex.Add(index);
             UI_LuckyBoxBonusShowItem.ProxyEnd();
         }
 
@@ -543,88 +620,35 @@ namespace GFGGame
             _ui.m_touchFlipOpen.touchable = false;
         }
 
-        private void TurnItem(int index)
+        protected void OthershowViewClose()
         {
-            if (!_recordOpenIndex.Contains(index))
-            {
-                // 删除 “等待翻开” 的特效
-                if (_effectUIDic.ContainsKey("CK_Loop_Wait_Chen" + index))
-                {
-                    EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_Chen" + index]);
-                    _effectUIDic.Remove("CK_Loop_Wait_Chen" + index);
-                }
-                if (_effectUIDic.ContainsKey("CK_Loop_Wait_GS" + index))
-                {
-                    EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_GS" + index]);
-                    _effectUIDic.Remove("CK_Loop_Wait_GS" + index);
-                }
-                if (_effectUIDic.ContainsKey("CK_Loop_Wait_Jin" + index))
-                {
-                    EffectUIPool.Recycle(_effectUIDic["CK_Loop_Wait_Jin" + index]);
-                    _effectUIDic.Remove("CK_Loop_Wait_Jin" + index);
-                }
-
-                UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(_itemObjList[index]);
-                if (!item.m_comIcon.m_imgNew.visible)
-                {
-                    if(!_recordTurnIndex.Contains(index))
-                    {
-                        _recordTurnIndex.Add(index);
-                    }
-                }
-                    
-
-                //先翻开牌面 
-                //item.m_comIcon.m_FlipOpenType.selectedIndex = 0;
-                //item.m_t1.Play();
-                //item.m_t2.Play();
-
-                ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_itemIdList[index]);
+            _ui.m_touchFlipOpen.touchable = false;
+        }
 
-                // 点击特效
-                if (!_effectUIDic.ContainsKey("CK_Cirle_DJ" + index))
-                {
-                    _effectUIDic.Add("CK_Cirle_DJ" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_click_eff, "ui_LuckyBox", "CK_Cirle_DJ"));
-                }
-                else
-                {
-                    _effectUIDic["CK_Cirle_DJ" + index] = EffectUIPool.CreateEffectUI(item.m_comIcon.m_click_eff, "ui_LuckyBox", "CK_Cirle_DJ");
-                }
-                    // 翻开特效
-                switch (itemCfg.Rarity)
-                {
-                    case 1:
-                        _effectUIDic.Add("CK_OpenAfter_LanHui_UI" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_HuiLan_UI"));
-                        _effectUIDic.Add("CK_OpenAfter_LanHui_TX" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_LanHui_TX"));
-                        break;
-                    case 2:
-                        _effectUIDic.Add("CK_OpenAfter_LanHui_UI" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_LanHui_UI"));
-                        _effectUIDic.Add("CK_OpenAfter_LanHui_TX" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_LanHui_TX"));
-                        break;
-                    case 3:
-                        _effectUIDic.Add("CK_OpenAfter_Chen_UI" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_Chen_UI"));
-                        _effectUIDic.Add("CK_OpenAfter_Chen_TX" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_Chen_TX"));
-                        break;
-                    case 4:
-                        _effectUIDic.Add("CK_OpenAfter_GS_UI" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_GS_UI"));
-                        _effectUIDic.Add("CK_OpenAfter_GS_TX" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_GS_TX"));
-                        break;
-                    case 5:
-                        _effectUIDic.Add("CK_OpenAfter_Jin_UI" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_ui_eff, "ui_LuckyBox", "CK_OpenAfter_Jin_UI"));
-                        _effectUIDic.Add("CK_OpenAfter_Jin_TX" + index, EffectUIPool.CreateEffectUI(item.m_comIcon.m_flip_eff, "ui_LuckyBox", "CK_OpenAfter_Jin_TX"));
-                        break;
-                }
+        protected void ReferNextShow()
+        {
+            if (!_allEffectsLoaded || GetSuitItemController.isAuto) return;
 
+            int suitId = 0;
+            if (_itemIdList.ContainsKey(_chooseIndex))
+                suitId = SuitCfgArray.Instance.GetSuitIdOfItem(_itemIdList[_chooseIndex]);
 
-                //item.m_comIcon.m_t0.Play();
-                if(!_recordOpenIndex.Contains(index))
+            if (_chooseIndex != -1 && suitId > 0)
+                ClickItem(_chooseIndex);
+            else
+            {
+                if (_handClick)
                 {
-                    _recordOpenIndex.Add(index);
+                    _handClick = false;
+                    _ui.m_touchFlipOpen.touchable = false;
                 }
-                UI_LuckyBoxBonusShowItem.ProxyEnd();
             }
         }
 
+        protected void SetAnimationWait()
+        {
+            _AnimationWait = true;
+        }
 
         private void HideOtherShowWindow()
         {
@@ -633,10 +657,5 @@ namespace GFGGame
             ViewManager.Hide<LuckyBoxNewDressView>();
             ViewManager.Hide<LuckyBoxNewCardView>();
         }
-
-        private void SetAnimationWait()
-        {
-            _AnimationWait = true;
-        }
     }
 }

+ 83 - 27
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxNewDressView.cs

@@ -42,6 +42,7 @@ namespace GFGGame
                 _ui.Dispose();
                 _ui = null;
             }
+
             base.Dispose();
         }
 
@@ -50,17 +51,34 @@ namespace GFGGame
             base.OnInit();
             packageName = UI_LuckyBoxNewDressUI.PACKAGE_NAME;
             _ui = UI_LuckyBoxNewDressUI.Create();
+            if (_ui == null)
+            {
+                Debug.LogError("Failed to create UI_LuckyBoxNewDressUI!");
+                return;
+            }
+
             this.viewCom = _ui.target;
             isfullScreen = true;
-
             this.modal = true;
 
-            _ui.m_loaBg.onTouchBegin.Add(OnClickBg);
-            _ui.m_btnPass.onClick.Add(Hide);
-            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
+            if (_ui.m_loaBg != null)
+            {
+                _ui.m_loaBg.onTouchBegin.Add(OnClickBg);
+            }
+
+            if (_ui.m_btnPass != null)
+            {
+                _ui.m_btnPass.onClick.Add(Hide);
+            }
+
+            if (_ui.m_loaBg != null)
+            {
+                _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
+            }
 
             UpdateEffect();
         }
+
         private void UpdateEffect()
         {
             _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_ck", "ui_ck_zs");
@@ -68,15 +86,24 @@ namespace GFGGame
             _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI");
             _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
         }
+
         protected override void OnShown()
         {
             base.OnShown();
+
+            // 确保UI已经创建
+            if (_ui == null || _ui.m_t_open == null)
+            {
+                Debug.LogError("UI components not initialized properly!");
+                return;
+            }
+
             _ui.m_loaBg.touchable = false;
             _rewardParamList.Clear();
             _rewardList.Clear();
             _rewardParamList.AddRange(this.viewData as List<ItemData>);
             _rewardList = this.viewData as List<ItemData>;
-            //_ui.m_btnPass.visible = false;
+
             _newRewardList.Clear();
             _oldRewardList.Clear();
             for (int i = 0; i < _rewardList.Count; i++)
@@ -97,35 +124,49 @@ namespace GFGGame
             UpdateView();
             Timers.inst.Add(0.5f, 1, OnTimerClick);
         }
+
         private void UpdateView()
         {
-            if (_effectUI5 != null)
+            // 确保UI组件存在
+            if (_ui == null || _ui.m_comCard == null || _ui.m_comCard.m_holder == null ||
+                _ui.m_comCard.m_holder1 == null || _ui.m_comCard.m_holder_get == null)
             {
-                EffectUIPool.Recycle(_effectUI5);
-                _effectUI5 = null;
+                Debug.LogError("UI components not initialized properly!");
+                return;
             }
-            if (_effectUI6 != null)
-            {
-                EffectUIPool.Recycle(_effectUI6);
-                _effectUI6 = null;
-            }
-            if (_effectUI7 != null)
+
+            // 清理旧特效
+            EffectUIPool.Recycle(_effectUI5);
+            _effectUI5 = null;
+            EffectUIPool.Recycle(_effectUI6);
+            _effectUI6 = null;
+            EffectUIPool.Recycle(_effectUI7);
+            _effectUI7 = null;
+
+            _rewardList = _newRewardList.Count > 0 ? _newRewardList : _oldRewardList;
+
+            if (_rewardList.Count - 1 < 0)
             {
-                EffectUIPool.Recycle(_effectUI7);
-                _effectUI7 = null;
+                Debug.LogWarning("No rewards to show");
+                return;
             }
-            //_ui.m_btnPass.visible = _newRewardList.Count <= 1;
-            _rewardList = _newRewardList.Count > 0 ? _newRewardList : _oldRewardList;
 
-            if (_rewardList.Count - 1 < 0) return;
             ItemData itemdata = _rewardList[_rewardList.Count - 1];
             ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemdata.id);
+            if (itemCfg == null)
+            {
+                Debug.LogError($"Item config not found for id: {itemdata.id}");
+                return;
+            }
+
+            // 根据稀有度创建特效
             switch (itemCfg.Rarity)
             {
                 case ConstDressRarity.Rarity_TIANYI:
                     _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_LuckyBox", "CK_Yellow_01");
                     _ui.m_comCard.m_holder.visible = true;
-                    _effectUI6 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder1, "ui_LuckyBox", "CK_Yellow_01_top");
+                    _effectUI6 =
+                        EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder1, "ui_LuckyBox", "CK_Yellow_01_top");
                     _ui.m_comCard.m_holder1.visible = true;
                     break;
                 case ConstDressRarity.Rarity_GUOSE:
@@ -135,7 +176,8 @@ namespace GFGGame
                 case ConstDressRarity.Rarity_DIANCANG:
                     _effectUI5 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder, "ui_LuckyBox", "CK_Purple_02");
                     _ui.m_comCard.m_holder.visible = true;
-                    _effectUI6 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder1, "ui_LuckyBox", "CK_Purple_02_top");
+                    _effectUI6 =
+                        EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder1, "ui_LuckyBox", "CK_Purple_02_top");
                     _ui.m_comCard.m_holder1.visible = true;
                     break;
                 case ConstDressRarity.Rarity_ZHENXI:
@@ -147,30 +189,40 @@ namespace GFGGame
                     _ui.m_comCard.m_holder.visible = true;
                     break;
             }
+
             _effectUI7 = EffectUIPool.CreateEffectUI(_ui.m_comCard.m_holder_get, "ui_LuckyBox", "CK_OneBigCard_end");
 
+            // 更新UI显示
             _ui.m_comCard.m_loaType.url = ResPathUtil.GetCommonGameResPath("hz_bq_shuxing_" + itemCfg.Rarity);
             _ui.m_comCard.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
             _ui.m_comCard.m_loaProperty.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.MainScore);
             _ui.m_comCard.m_txtName.text = itemCfg.Name;
             _ui.m_comCard.m_txtDiscribe.text = itemCfg.Desc;
-            if (itemCfg.ItemType == ConstItemType.CARD)
+
+            // 确保过渡动画对象存在
+            if (_ui.m_t_open != null)
             {
-                _ui.m_t_open.Play(() =>
+                if (itemCfg.ItemType == ConstItemType.CARD)
                 {
+                    //_ui.m_t_open.Play(() => { ViewManager.Show<LuckyBoxNewCardView>(itemCfg.Id); });
                     ViewManager.Show<LuckyBoxNewCardView>(itemCfg.Id);
-                });
+                }
+                else
+                {
+                    //_ui.m_t_open.Play();
+                }
             }
             else
             {
-                _ui.m_t_open.Play();
+                Debug.LogError("Transition m_t_open is null!");
             }
-            if (LuckyBoxDataManager.Instance.FirstRewardList.ContainsKey(_rewardList.Count - 1) == true)
+
+            if (LuckyBoxDataManager.Instance.FirstRewardList.ContainsKey(_rewardList.Count - 1))
             {
                 LuckyBoxDataManager.Instance.FirstRewardList.Remove(_rewardList.Count - 1);
             }
-            _rewardList.RemoveAt(_rewardList.Count - 1);
 
+            _rewardList.RemoveAt(_rewardList.Count - 1);
         }
 
         private void OnTimerClick(object param)
@@ -198,6 +250,7 @@ namespace GFGGame
             //    }
             //});
         }
+
         private int GetThisCount(int itemId, List<ItemData> rewards)
         {
             int count = 0;
@@ -208,8 +261,10 @@ namespace GFGGame
                     count++;
                 }
             }
+
             return count;
         }
+
         private bool IsAddToNewRewardList(int itemId)
         {
             for (int i = 0; i < _newRewardList.Count; i++)
@@ -219,6 +274,7 @@ namespace GFGGame
                     return true;
                 }
             }
+
             return false;
         }
 

+ 131 - 134
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxStarView.cs

@@ -17,27 +17,24 @@ namespace GFGGame
         private List<GObject> comStars = new List<GObject>();
         private List<GObject> clickComStars = new List<GObject>();
         private List<GObject> notClickComStars = new List<GObject>();
-
-        // private List<GameObject> _gameObjects = new List<GameObject>();
-        // private List<GoWrapper> _wrappers = new List<GoWrapper>();
-        // private List<GameObject> _gameObjects1 = new List<GameObject>();
-        // private List<GoWrapper> _wrappers1 = new List<GoWrapper>();
         private List<EffectUI> dicEffect = new List<EffectUI>();
         private List<EffectUI> effObj = new List<EffectUI>();
         private EffectUI _effectUI1;
         private EffectUI _effectUI2;
         private EffectUI _effectUI3;
         private EffectUI _effectUI4;
-        private GObject curComStar;//当前选中的星星
-        private Vector2 lastPos;//鼠标的上一个位置,每颗星星初始时默认为Vector2.right;
+        private GObject curComStar; //当前选中的星星
+        private Vector2 lastPos; //鼠标的上一个位置,每颗星星初始时默认为Vector2.right;
 
         private List<ItemData> _rewardList;
+        private bool _allEffectsLoaded = false;
 
-        private const int checkDistance = 40;//鼠标靠近星星周围加减40都算选中星星
-        private const int imgLineWidth = 10;//线的原始长度
-        private bool _isLuckyBox = true;//是抽奖(true),是限时主题活动(false)
+        private const int checkDistance = 40; //鼠标靠近星星周围加减40都算选中星星
+        private const int imgLineWidth = 10; //线的原始长度
+        private bool _isLuckyBox = true; //是抽奖(true),是限时主题活动(false)
 
         private bool showGuide = false;
+
         public override void Dispose()
         {
             EffectUIPool.Recycle(_effectUI1);
@@ -48,29 +45,43 @@ namespace GFGGame
             _effectUI3 = null;
             EffectUIPool.Recycle(_effectUI4);
             _effectUI4 = null;
+
             if (_ui != null)
             {
                 _ui.Dispose();
                 _ui = null;
             }
+
+            ClearAllEffects();
             base.Dispose();
         }
-        protected override void OnHide()
+
+        private void ClearAllEffects()
         {
-            base.OnHide();
             for (int i = 0; i < dicEffect.Count; i++)
             {
                 EffectUIPool.Recycle(dicEffect[i]);
                 dicEffect[i] = null;
             }
+
             for (int i = 0; i < effObj.Count; i++)
             {
                 EffectUIPool.Recycle(effObj[i]);
                 effObj[i] = null;
             }
 
+            dicEffect.Clear();
+            effObj.Clear();
+        }
+
+        protected override void OnHide()
+        {
+            base.OnHide();
+            ClearAllEffects();
+
             int index = 0;
-            GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
+            GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex,
+                _ui.m_ctrlRewardsType.selectedIndex, index));
             while (star != null && star.visible == true)
             {
                 UI_ComStar comStar = UI_ComStar.Proxy(star);
@@ -80,18 +91,19 @@ namespace GFGGame
                     var starchild = comStar.target.RemoveChildAt(i);
                     starchild.Dispose();
                 }
+
                 index++;
-                star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
+                star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex,
+                    _ui.m_ctrlRewardsType.selectedIndex, index));
                 UI_ComStar.ProxyEnd();
             }
+
             notClickComStars.Clear();
             clickComStars.Clear();
-            dicEffect.Clear();
-            effObj.Clear();
-
             Timers.inst.Remove(CheckGuide);
-            Debug.Log("OnHide  LuckyBoxStarView");
+            Debug.Log("OnHide LuckyBoxStarView");
         }
+
         protected override void OnInit()
         {
             base.OnInit();
@@ -101,48 +113,72 @@ namespace GFGGame
 
             _ui.m_btnBack.visible = false;
             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
+        }
+
+        protected override void OnShown()
+        {
+            base.OnShown();
+            Debug.Log("OnShown: LuckyBoxStarView");
+
+            _allEffectsLoaded = false;
+            _ui.m_star.visible = true;
+            _ui.m_effEnd.visible = false;
+
+            _rewardList = LuckyBoxDataManager.Instance.RewardList;
+            _ui.m_ctrlBuyType.selectedIndex = _rewardList != null && _rewardList.Count > 1 ? 1 : 0;
 
-            UpdateEffect();
+            _isLuckyBox = LuckyBoxDataManager.Instance.luckyBoxIds.IndexOf(LuckyBoxDataManager.Instance.currentBoxId) >=
+                          0;
+            _ui.m_ctrlRewardsType.selectedIndex = LuckyBoxDataManager.Instance.luckyBoxIndex;
+            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
+
+            // 异步加载所有特效
+            Timers.inst.StartCoroutine(LoadAllEffects(() =>
+            {
+                _allEffectsLoaded = true;
+                SetupViewAfterEffectsLoaded();
+            }));
         }
-        private void UpdateEffect()
+
+        private IEnumerator LoadAllEffects(Action onComplete)
         {
+            // 加载背景特效
             _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing");
             _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "bg_thing");
             _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
             _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_holder_star_sky, "ui_LuckyBox", "Bg_Sky_lizi");
+
+            // 等待所有背景特效加载完成
+            while (_effectUI1.GetObj() == null || _effectUI2.GetObj() == null ||
+                   _effectUI3.GetObj() == null || _effectUI4.GetObj() == null)
+            {
+                yield return null;
+            }
+
+            onComplete?.Invoke();
         }
-        protected override void OnShown()
+
+        private void SetupViewAfterEffectsLoaded()
         {
-            base.OnShown();
-            Debug.Log("OnShown:  LuckyBoxStarView");
-            _ui.m_star.visible = true;
+            if (!_allEffectsLoaded) return;
+
+            // 设置触摸事件
             _ui.target.onTouchBegin.Add(OnClickUIBegin);
             _ui.target.onTouchMove.Add(OnClickUIMove);
             _ui.target.onTouchEnd.Add(OnClickUIEnd);
-            _ui.m_effEnd.visible = false;
-            _rewardList = LuckyBoxDataManager.Instance.RewardList;
-            _ui.m_ctrlBuyType.selectedIndex = _rewardList != null && _rewardList.Count > 1 ? 1 : 0;
-
-            _isLuckyBox = LuckyBoxDataManager.Instance.luckyBoxIds.IndexOf(LuckyBoxDataManager.Instance.currentBoxId) >= 0;
-            _ui.m_ctrlRewardsType.selectedIndex = LuckyBoxDataManager.Instance.luckyBoxIndex;// _isLuckyBox ? (LuckyBoxDataManager.Instance.currentBoxId - 1) : 0;
-            // string resPath = string.Format("cj_tp_{0}", _isLuckyBox ? LuckyBoxDataManager.Instance.currentBoxId : 1);
-            _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
 
+            showGuide = GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX_LINE) <= 0;
             ResetStartView();
             Timers.inst.AddUpdate(CheckGuide);
         }
 
         private void ResetStartView()
         {
-            showGuide = GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX_LINE) <= 0;
-
             curComStar = null;
-            for (int i = 0; i < comStars.Count; i++) {
-                comStars.RemoveAt(i);
-            }
             comStars.Clear();
             int index = 0;
-            GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
+            GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex,
+                _ui.m_ctrlRewardsType.selectedIndex, index));
 
             while (star != null && star.visible == true)
             {
@@ -155,27 +191,37 @@ namespace GFGGame
 
                 float scale = Random.Range(0.5f, 1f);
                 float rotation = Random.Range(0, 360);
-                GComponent gcom = CreateEffect(comStar, 1, _isLuckyBox ? "STAR_Ready_Bule" : "STAR_Ready"); ;
-                gcom.visible = true;
-                comStar.target.AddChildAt(gcom, 1);
-                gcom.scale = new Vector2(scale, scale);
-                gcom.rotation = rotation;
-
-                GComponent gcom1 = CreateEffect(comStar, 2, _isLuckyBox ? "STAR_Bule" : "STAR");
-                gcom1.visible = false;
-                comStar.target.AddChildAt(gcom1, 2);
-                gcom1.scale = new Vector2(scale, scale);
-                gcom1.rotation = rotation;
+
+                // 创建星星特效
+                CreateStarEffect(comStar, scale, rotation);
 
                 star.data = new Vector2(comStar.target.x, comStar.target.y);
                 comStars.Add(star);
 
                 index++;
-                star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
+                star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex,
+                    _ui.m_ctrlRewardsType.selectedIndex, index));
                 UI_ComStar.ProxyEnd();
             }
+        }
 
+        private void CreateStarEffect(UI_ComStar comStar, float scale, float rotation)
+        {
+            // 创建准备状态的星星
+            GComponent gcom = CreateEffect(comStar, 1, _isLuckyBox ? "STAR_Ready_Bule" : "STAR_Ready");
+            gcom.visible = true;
+            comStar.target.AddChildAt(gcom, 1);
+            gcom.scale = new Vector2(scale, scale);
+            gcom.rotation = rotation;
+
+            // 创建激活状态的星星
+            GComponent gcom1 = CreateEffect(comStar, 2, _isLuckyBox ? "STAR_Bule" : "STAR");
+            gcom1.visible = false;
+            comStar.target.AddChildAt(gcom1, 2);
+            gcom1.scale = new Vector2(scale, scale);
+            gcom1.rotation = rotation;
         }
+
         private GComponent CreateEffect(UI_ComStar comStar, int index, string name)
         {
             GComponent gcom;
@@ -186,26 +232,34 @@ namespace GFGGame
             else
             {
                 gcom = UIPackage.CreateObject("LuckyBox", "ComHolder").asCom;
-                EffectUI _effectUI = EffectUIPool.CreateEffectUI(gcom.GetChild("holder").asGraph, "ui_LuckyBox", name,120);
+                EffectUI _effectUI =
+                    EffectUIPool.CreateEffectUI(gcom.GetChild("holder").asGraph, "ui_LuckyBox", name, 120);
                 dicEffect.Add(_effectUI);
             }
+
             return gcom;
         }
+
         private void OnClickUIBegin(EventContext context)
         {
+            if (!_allEffectsLoaded) return;
+
             context.CaptureTouch();
             InputEvent inputEvent = (InputEvent)context.data;
             Vector2 mousePos = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
             CheckNearbyPos(mousePos);
         }
+
         private void OnClickUIMove(EventContext context)
         {
+            if (!_allEffectsLoaded) return;
+
             InputEvent inputEvent = (InputEvent)context.data;
             Vector2 mousePos = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
 
             CheckNearbyPos(mousePos);
 
-            if (comStars.Count == 0)//所有星星都点亮了主动结束
+            if (comStars.Count == 0) //所有星星都点亮了主动结束
             {
                 this.OnClickUIEnd();
             }
@@ -223,11 +277,12 @@ namespace GFGGame
                     {
                         SetCurComStarTransfrom(comStarPos);
                     }
+
                     UI_ComStar comStar = UI_ComStar.Proxy(comStars[i]);
                     comStar.target.GetChildAt(2).asCom.visible = true;
-                    // comStar.target.GetChildAt(1).asCom.visible = false;
                     string resPath = _isLuckyBox ? "LINE_Bule" : "LINE";
-                    EffectUI _effectUI = EffectUIPool.CreateEffectUI(comStar.m_comLine.m_holder, "ui_LuckyBox", resPath,120);
+                    EffectUI _effectUI =
+                        EffectUIPool.CreateEffectUI(comStar.m_comLine.m_holder, "ui_LuckyBox", resPath, 120);
                     effObj.Add(_effectUI);
                     UI_ComStar.ProxyEnd();
 
@@ -236,7 +291,6 @@ namespace GFGGame
 
                     clickComStars.Add(comStars[i]);
                     comStars.RemoveAt(i);
-
                 }
                 else
                 {
@@ -248,98 +302,44 @@ namespace GFGGame
                     }
                 }
             }
-
-
         }
+
         private void SetCurComStarTransfrom(Vector2 targetPos)
         {
-
             Vector2 curPos = targetPos - (Vector2)curComStar.data;
             float angle = Vector3.Angle(lastPos, curPos); //求出两向量之间的夹角 
-            Vector3 normal = Vector3.Cross(lastPos, curPos);//叉乘求出法线向量 
-            angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.forward));  //Mathf.Sign()求符号,Vector3.Dot()求方向,求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向 
+            Vector3 normal = Vector3.Cross(lastPos, curPos); //叉乘求出法线向量 
+            angle *= Mathf.Sign(Vector3.Dot(normal,
+                Vector3.forward)); //Mathf.Sign()求符号,Vector3.Dot()求方向,求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向 
 
             UI_ComStar comStar = UI_ComStar.Proxy(curComStar);
             comStar.m_comLine.target.rotation += angle;
             comStar.m_comLine.target.width = Vector2.Distance(targetPos, (Vector2)curComStar.data);
             UI_ComStar.ProxyEnd();
-
         }
 
         private void OnClickUIEnd()
         {
-            if (clickComStars.Count <= 0) return;
+            if (!_allEffectsLoaded || clickComStars.Count <= 0) return;
 
             UI_ComStar comStar = UI_ComStar.Proxy(clickComStars[clickComStars.Count - 1]);
             comStar.m_comLine.target.visible = false;
             UI_ComStar.ProxyEnd();
 
-
             if (showGuide && clickComStars.Count < 2)
             {
                 ResetStartView();
             }
             else
             {
-                // CheckNotClickComStar();
-                // SetComStarDarken();
                 RemoveListener();
-                // Timers.inst.Add(1f, 1, SetClickComStarAni);
                 Timers.inst.Add(0.5f, 1, SetEndEffect);
             }
         }
-        // private void CheckNotClickComStar()
-        // {
-        //     int index = 0;
-        //     GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
-
-        //     while (star != null && star.visible == true)
-        //     {
-        //         if (clickComStars.IndexOf(star) < 0)
-        //         {
-        //             notClickComStars.Add(star);
-        //         }
-        //         index++;
-        //         star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
-        //     }
-        // }
-
-        // private void SetComStarDarken()
-        // {
-
-        //     for (int i = 0; i < notClickComStars.Count; i++)
-        //     {
-        //         UI_ComStar notClickComStar = UI_ComStar.Proxy(notClickComStars[i]);
-        //         notClickComStar.m_comLine.target.visible = false;
-        //         notClickComStar.target.GetChildAt(3).asCom.visible = true;
-        //         notClickComStar.target.GetChildAt(1).asCom.visible = false;
-        //         UI_ComStar.ProxyEnd();
-
-        //     }
-
-        // }
-
-        // private void SetClickComStarAni(object param)
-        // {
-        //     for (int i = 0; i < clickComStars.Count; i++)
-        //     {
-        //         UI_ComStar comStar = UI_ComStar.Proxy(clickComStars[i]);
-        //         comStar.target.GetChildAt(4).asCom.visible = true;
-        //         UI_ComStar.ProxyEnd();
-
-        //     }
-        //     Timers.inst.Add(0.5f, 1, SetEndEffect);
-        // }
+
         private void SetEndEffect(object param)
         {
-            //_ui.m_effEnd.visible = true;
-            //_ui.m_effEnd.SetPlaySettings(0, -1, 1, -1);
-            _ui.m_t0.Play(()=>
-            {
-                ClickUIEnd(null);
-            });
-            //Timers.inst.Add(0.4f, 1, ClickUIEnd);
-
+            _ui.m_t0.Play(() => { ClickUIEnd(null); });
             TryCompleteGuide();
         }
 
@@ -347,21 +347,18 @@ namespace GFGGame
         {
             if (curComStar != null)
             {
-
                 RemoveListener();
-                //ViewManager.Show<LuckyBoxBonusView>(new object[] { _rewardList });
                 this.Hide();
                 LuckyBoxVideoView.Instance.Show(_rewardList);
-                //ViewManager.Show<LuckyBoxBonusShowView>(_rewardList);
-                
-                //ViewManager.Show<LuckyBoxNewDressView>(_rewardList);
-
             }
         }
 
         private bool IsSamePos(Vector2 mousePos, Vector2 comStarPos)
         {
-            return (mousePos.x < comStarPos.x + checkDistance) && (mousePos.x > comStarPos.x - checkDistance) && (mousePos.y < comStarPos.y + checkDistance) && (mousePos.y > comStarPos.y - checkDistance);
+            return (mousePos.x < comStarPos.x + checkDistance) &&
+                   (mousePos.x > comStarPos.x - checkDistance) &&
+                   (mousePos.y < comStarPos.y + checkDistance) &&
+                   (mousePos.y > comStarPos.y - checkDistance);
         }
 
         private void RemoveListener()
@@ -369,7 +366,6 @@ namespace GFGGame
             _ui.target.onTouchBegin.Remove(OnClickUIBegin);
             _ui.target.onTouchMove.Remove(OnClickUIMove);
             _ui.target.onTouchEnd.Remove(OnClickUIEnd);
-
         }
 
         private void OnClickBtnBack()
@@ -378,8 +374,11 @@ namespace GFGGame
             RemoveListener();
             ViewManager.Show<LuckyBoxView>();
         }
+
         private void CheckGuide(object param)
         {
+            if (!_allEffectsLoaded) return;
+
             if (GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX_LINE) <= 0)
             {
                 UpdateToCheckGuide(null);
@@ -392,30 +391,28 @@ namespace GFGGame
 
         protected override void UpdateToCheckGuide(object param)
         {
+            if (!_allEffectsLoaded || !ViewManager.CheckIsTopView(this.viewCom)) return;
 
-            if (!ViewManager.CheckIsTopView(this.viewCom)) return;
-           // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX_LINE);
-            // GuideController.TryCompleteGuide(ConstGuideId.LUCKY_BOX, 4);
-            GuideController.TryGuide(null, ConstGuideId.LUCKY_BOX_LINE, 1, "点击将星连接在一起。", -1, true, (int)(this.viewCom.height - 200), true);
+            GuideController.TryGuide(null, ConstGuideId.LUCKY_BOX_LINE, 1, "点击将星连接在一起。", -1, true,
+                (int)(this.viewCom.height - 200), true);
             TryCompleteGuide();
         }
+
         protected override void TryCompleteGuide()
         {
+            if (!_allEffectsLoaded) return;
+
             if (clickComStars.Count >= 2)
             {
-                // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX_LINE);
-
                 GuideController.TryCompleteGuideIndex(ConstGuideId.LUCKY_BOX_LINE, 1);
                 GuideController.TryCompleteGuide(ConstGuideId.LUCKY_BOX_LINE, 1);
             }
             else
             {
-                GuideDataManager.SetGuideIndexState(GuideDataManager.currentGuideId, GuideDataManager.currentGuideIdIndex, 0);
+                GuideDataManager.SetGuideIndexState(GuideDataManager.currentGuideId,
+                    GuideDataManager.currentGuideIdIndex, 0);
                 GuideDataManager.currentGuideIdIndex = 3;
             }
-
-
         }
-
     }
 }