Browse Source

换装套装展示问题

HDY 4 months ago
parent
commit
36f8133b32
1 changed files with 41 additions and 24 deletions
  1. 41 24
      GameClient/Assets/Game/HotUpdate/Views/ClothingShop/ClothingShopView.cs

+ 41 - 24
GameClient/Assets/Game/HotUpdate/Views/ClothingShop/ClothingShopView.cs

@@ -7,6 +7,7 @@ using System;
 using System.Linq;
 using cfg.GfgCfg;
 using ET;
+using DG.Tweening;
 
 namespace GFGGame
 {
@@ -88,7 +89,7 @@ namespace GFGGame
             //isReturnView = true;
 
             _valueBarController = new ValueBarController(_ui.m_valueBar);
-            _dressUpObjUI = new DressUpObjUI("SceneDressUp");
+            //_dressUpObjUI = new DressUpObjUI("SceneDressUp");
 
             _comSelected = new GImage();
             _comSelected.x = -5;
@@ -210,6 +211,8 @@ namespace GFGGame
             _valueBarController.OnHide();
             _selectedItemId = 0;
             Timers.inst.Remove(CheckGuide);
+            Timers.inst.Remove(OnTimerUpDate);
+
         }
 
         protected override void RemoveEventListener()
@@ -255,8 +258,44 @@ namespace GFGGame
 
         private EaseType ease = EaseType.CubicOut;
 
+
+        private void OnTimerUpDate(object param = null)
+        {
+            bool tween = (bool)param;
+            _dressUpObjUI.UpdateWrapper(_ui.m_compHolder.m_compMover.m_holder);
+
+            // 根据服装类型设置动画
+            int type = ItemUtilCS.GetItemSubType(_cfgSelected.ItemId);
+            float duration = tween ? DURATION : 0;
+
+            if (Array.IndexOf(HEAD_Y_ARR, type) >= 0)
+            {
+                _ui.m_compHolder.m_compMover.target.TweenMoveY(HEAD_Y, duration).SetEase(ease);
+                _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(SCALE_MAX, SCALE_MAX), duration)
+                    .SetEase(ease);
+            }
+            else if (Array.IndexOf(SHOES_Y_ARR, type) >= 0)
+            {
+                _ui.m_compHolder.m_compMover.target.TweenMoveY(SHOES_Y, duration).SetEase(ease);
+                _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(SCALE_MAX, SCALE_MAX), duration)
+                    .SetEase(ease);
+            }
+            else
+            {
+                _ui.m_compHolder.m_compMover.target.TweenMoveY(BODY_Y, duration).SetEase(ease);
+                _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(1, 1), duration).SetEase(ease);
+            }
+        }
+
         private void UpdateRole(bool tween)
         {
+            if (_dressUpObjUI != null)
+            {
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
+            }
+            _dressUpObjUI = new DressUpObjUI("SceneDressUp");
+
             // 使用异步方式重置场景对象
             _dressUpObjUI.ResetSceneObjAsync(70, false, true, null, false, (sceneObj) =>
             {
@@ -264,29 +303,7 @@ namespace GFGGame
                 {
                     // 场景对象加载完成后添加服装
                     _dressUpObjUI.dressUpObj.AddOrRemove(_cfgSelected.ItemId, true, DressUpOption.Add);
-                    _dressUpObjUI.UpdateWrapper(_ui.m_compHolder.m_compMover.m_holder);
-
-                    // 根据服装类型设置动画
-                    int type = ItemUtilCS.GetItemSubType(_cfgSelected.ItemId);
-                    float duration = tween ? DURATION : 0;
-
-                    if (Array.IndexOf(HEAD_Y_ARR, type) >= 0)
-                    {
-                        _ui.m_compHolder.m_compMover.target.TweenMoveY(HEAD_Y, duration).SetEase(ease);
-                        _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(SCALE_MAX, SCALE_MAX), duration)
-                            .SetEase(ease);
-                    }
-                    else if (Array.IndexOf(SHOES_Y_ARR, type) >= 0)
-                    {
-                        _ui.m_compHolder.m_compMover.target.TweenMoveY(SHOES_Y, duration).SetEase(ease);
-                        _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(SCALE_MAX, SCALE_MAX), duration)
-                            .SetEase(ease);
-                    }
-                    else
-                    {
-                        _ui.m_compHolder.m_compMover.target.TweenMoveY(BODY_Y, duration).SetEase(ease);
-                        _ui.m_compHolder.m_compMover.target.TweenScale(new Vector2(1, 1), duration).SetEase(ease);
-                    }
+                    Timers.inst.Add(1f, 1, OnTimerUpDate, tween);
                 }
                 else
                 {