Procházet zdrojové kódy

UI界面上的换装对象优化

guodong před 2 roky
rodič
revize
33bcd406c3

+ 10 - 35
GameClient/Assets/Game/HotUpdate/Views/ClothingFoster/ClothingView.cs

@@ -12,13 +12,9 @@ namespace GFGGame
     {
         private UI_ClothingUI _ui;
         private ValueBarController _valueBarController;
-        private GameObject _scenePrefab;
-        private GameObject _sceneObject;
-        private GoWrapper _wrapper;
+        private DressUpObjUI _dressUpObjUI;
         private GameObject _gameobject1;
         private GoWrapper _wrapper1;
-        private DressUpObj _dressUpObj;
-        private bool _actionIsPic;
 
         private List<int> _suitIds;//已解锁套装列表
         private SortedList _propertyList = new SortedList();
@@ -36,18 +32,16 @@ namespace GFGGame
                 _ui = null;
             }
             base.Dispose();
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-                _wrapper.Dispose();
-                _wrapper = null;
-            }
             if (_valueBarController != null)
             {
                 _valueBarController.Dispose();
                 _valueBarController = null;
             }
+            if(_dressUpObjUI != null)
+            {
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
+            }
             SceneController.DestroyObjectFromView(_gameobject1, _wrapper1);
             _propertyList.Clear();
             _addPropertyList.Clear();
@@ -65,8 +59,7 @@ namespace GFGGame
             isfullScreen = true;
             // this.clickBlankToClose = false;
             _valueBarController = new ValueBarController(_ui.m_valueBar);
-            _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneSuitFoster"));
-            _dressUpObj = new DressUpObj();
+            _dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
 
             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
             _ui.m_btnLeft.onClick.Add(() => { OnClickBtnDirection(-1); });
@@ -172,29 +165,11 @@ namespace GFGGame
 
         private void UpdateSuitView(bool isPic = true)
         {
-            _actionIsPic = isPic;
             SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
             _ui.m_txtName.text = suitCfg.name;
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            _sceneObject = GameObject.Instantiate(_scenePrefab);
-            int scale = 100;
-            _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
-            _dressUpObj.setSceneObj(_sceneObject, false, true, null, false);
-            _dressUpObj.PutOnDefaultDressUpData();
-            _dressUpObj.PutOnSuitCfg(_suitId, isPic, new int[] { ConstDressUpItemType.BEI_JING });
-            if (_wrapper == null)
-            {
-                _wrapper = new GoWrapper(_sceneObject);
-                _ui.m_holder.SetNativeObject(_wrapper);
-            }
-            else
-            {
-                _wrapper.wrapTarget = _sceneObject;
-            }
+            _dressUpObjUI.ResetSceneObj(100, false, true, null, false);
+            _dressUpObjUI.dressUpObj.PutOnSuitCfg(_suitId, isPic, new int[] { ConstDressUpItemType.BEI_JING });
+            _dressUpObjUI.UpdateWrapper(_ui.m_holder);
         }
         private void OnClickBtnDirection(int direction)
         {

+ 11 - 47
GameClient/Assets/Game/HotUpdate/Views/ClothingShop/ClothingShopView.cs

@@ -17,10 +17,7 @@ namespace GFGGame
         private readonly int[] HEAD_Y_ARR = new int[] { ConstDressUpItemType.FA_XING, ConstDressUpItemType.NEI_DA, ConstDressUpItemType.SHANG_YI, ConstDressUpItemType.TOU_SHI, ConstDressUpItemType.ER_SHI, ConstDressUpItemType.JING_SHI };
         private readonly int[] SHOES_Y_ARR = new int[] { ConstDressUpItemType.XIA_ZHUANG, ConstDressUpItemType.WA_ZI, ConstDressUpItemType.XIE_ZI, ConstDressUpItemType.SHOU_SHI, ConstDressUpItemType.YAO_SHI };
         private UI_ClothingShopUI _ui;
-        private GameObject _scenePrefab;
-        private GameObject _sceneObject;
-        private GoWrapper _wrapper;
-        private DressUpObj _dressUpObj;
+        private DressUpObjUI _dressUpObjUI;
         private ValueBarController _valueBarController;
         private List<ShopCfg> _dataList;
         private GImage _comSelected;
@@ -44,26 +41,20 @@ namespace GFGGame
                 _valueBarController = null;
             }
 
-            if (_sceneObject != null)
+            if (_dressUpObjUI != null)
             {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-
-            if (_wrapper != null)
-            {
-                _wrapper.Dispose();
-                _wrapper = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
             if (_comSelected != null)
             {
                 _comSelected.RemoveFromParent();
                 _comSelected.Dispose();
             }
-            if (_dressUpObj != null)
+            if (_dressUpObjUI != null)
             {
-                _dressUpObj.Dispose();
-                _dressUpObj = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
             _cfgSelected = null;
 
@@ -85,8 +76,7 @@ namespace GFGGame
             isfullScreen = true;
 
             _valueBarController = new ValueBarController(_ui.m_valueBar);
-            _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
-            _dressUpObj = new DressUpObj();
+            _dressUpObjUI = new DressUpObjUI("SceneDressUp");
 
             _comSelected = new GImage();
             _comSelected.x = -5;
@@ -199,15 +189,6 @@ namespace GFGGame
         {
             base.OnHide();
             _valueBarController.OnHide();
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            if (_wrapper != null)
-            {
-                _wrapper.wrapTarget = null;
-            }
             _selectedItemId = 0;
             Timers.inst.Remove(CheckGuide);
 
@@ -254,26 +235,9 @@ namespace GFGGame
         }
         private void UpdateRole(bool tween)
         {
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            _sceneObject = GameObject.Instantiate(_scenePrefab);
-            int scale = 70;
-            _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
-            _dressUpObj.setSceneObj(_sceneObject, false, true, null, false);
-            _dressUpObj.PutOnDefaultDressUpData();
-            _dressUpObj.AddOrRemove(_cfgSelected.itemID, true);
-            if (_wrapper == null)
-            {
-                _wrapper = new GoWrapper(_sceneObject);
-                _ui.m_compHolder.m_compMover.m_holder.SetNativeObject(_wrapper);
-            }
-            else
-            {
-                _wrapper.wrapTarget = _sceneObject;
-            }
+            _dressUpObjUI.ResetSceneObj(70, false, true, null, false);
+            _dressUpObjUI.dressUpObj.AddOrRemove(_cfgSelected.itemID, true);
+            _dressUpObjUI.UpdateWrapper(_ui.m_compHolder.m_compMover.m_holder);
             int type = ItemUtilCS.GetItemSubType(_cfgSelected.itemID);
             float duration = DURATION;
             if (!tween)

+ 11 - 46
GameClient/Assets/Game/HotUpdate/Views/ClothingSynthetic/ClothingSyntheticView.cs

@@ -34,10 +34,7 @@ namespace GFGGame
         private readonly int[] SHOES_Y_ARR = new int[] { ConstDressUpItemType.WA_ZI, ConstDressUpItemType.XIE_ZI };
 
         private UI_ClothingSyntheticUI _ui;
-        private GameObject _scenePrefab;
-        private GameObject _sceneObject;
-        private GoWrapper _wrapper;
-        private DressUpObj _dressUpObj;
+        private DressUpObjUI _dressUpObjUI;
         private ValueBarController _valueBarController;
         private GImage _imgSelected;
         private int _suitId;
@@ -57,10 +54,10 @@ namespace GFGGame
                 _valueBarController.Dispose();
                 _valueBarController = null;
             }
-            if (_sceneObject != null)
+            if (_dressUpObjUI != null)
             {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
 
             if (_imgSelected != null)
@@ -68,15 +65,10 @@ namespace GFGGame
                 _imgSelected.RemoveFromParent();
                 _imgSelected.Dispose();
             }
-            if (_dressUpObj != null)
+            if (_dressUpObjUI != null)
             {
-                _dressUpObj.Dispose();
-                _dressUpObj = null;
-            }
-            if (_wrapper != null)
-            {
-                _wrapper.Dispose();
-                _wrapper = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
 
             if (_ui != null)
@@ -99,8 +91,7 @@ namespace GFGGame
 
             _valueBarController = new ValueBarController(_ui.m_valueBar);
 
-            _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUpSynthetic"));
-            _dressUpObj = new DressUpObj();
+            _dressUpObjUI = new DressUpObjUI("SceneDressUpSynthetic");
 
             _imgSelected = new GImage();
             _imgSelected = UIPackage.CreateObject(UI_ClothingSyntheticUI.PACKAGE_NAME, "hc_kuang_4").asImage;
@@ -139,15 +130,6 @@ namespace GFGGame
         {
             base.OnHide();
             _valueBarController.OnHide();
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            if (_wrapper != null)
-            {
-                _wrapper.wrapTarget = null;
-            }
             _ui.m_listMaterias.selectedIndex = 0;
             Timers.inst.Remove(CheckGuide);
 
@@ -224,26 +206,9 @@ namespace GFGGame
 
         private void UpdateRole(bool tween)
         {
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            _sceneObject = GameObject.Instantiate(_scenePrefab);
-            int scale = 45;
-            _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
-            _dressUpObj.setSceneObj(_sceneObject, true, true, null, false);
-            _dressUpObj.PutOnDefaultDressUpData();
-            _dressUpObj.AddOrRemove(_selectedItemId, true);
-            if (_wrapper == null)
-            {
-                _wrapper = new GoWrapper(_sceneObject);
-                _ui.m_compHolder.m_compMover.m_holder.SetNativeObject(_wrapper);
-            }
-            else
-            {
-                _wrapper.wrapTarget = _sceneObject;
-            }
+            _dressUpObjUI.ResetSceneObj(45, true, true, null, false);
+            _dressUpObjUI.dressUpObj.AddOrRemove(_selectedItemId, true);
+            _dressUpObjUI.UpdateWrapper(_ui.m_compHolder.m_compMover.m_holder);
             int type = ItemUtilCS.GetItemSubType(_selectedItemId);
             float duration = DURATION;
             if (!tween)

+ 12 - 49
GameClient/Assets/Game/HotUpdate/Views/CommonGame/GetSuitItemVIew.cs

@@ -8,32 +8,23 @@ namespace GFGGame
     public class GetSuitItemVIew : BaseWindow
     {
         private UI_GetSuitItemUI _ui;
-        private GameObject _scenePrefab;
-        private GameObject _sceneObject;
-        private GoWrapper _wrapper;
         private GameObject _gameObject1;
         private GoWrapper _wrapper1;
-        private DressUpObj _dressUpObj;
+        private DressUpObjUI _dressUpObjUI;
 
         public override void Dispose()
         {
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-
             SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
-            if (_wrapper != null)
+            if (_dressUpObjUI != null)
             {
-                _wrapper.Dispose();
-                _wrapper = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
 
-            if (_dressUpObj != null)
+            if (_dressUpObjUI != null)
             {
-                _dressUpObj.Dispose();
-                _dressUpObj = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
             if (_ui != null)
             {
@@ -50,8 +41,7 @@ namespace GFGGame
             this.viewCom = _ui.target;
             isfullScreen = true;
 
-            _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
-            _dressUpObj = new DressUpObj();
+            _dressUpObjUI = new DressUpObjUI("SceneDressUp");
             _ui.m_bg.onClick.Add(OnClickBg);
 
             string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_tz");
@@ -70,15 +60,6 @@ namespace GFGGame
         protected override void OnHide()
         {
             base.OnHide();
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            if (_wrapper != null)
-            {
-                _wrapper.wrapTarget = null;
-            }
             if (this.viewCom == null || this.viewCom.root == null)
             {
 
@@ -144,28 +125,10 @@ namespace GFGGame
             _ui.m_probar.max = totalCount;
             _ui.m_probar.value = count;
             // UpdateItem(itemId);
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            _sceneObject = GameObject.Instantiate(_scenePrefab);
-            int scale = 70;
-            _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
-
-            _dressUpObj.setSceneObj(_sceneObject, false, true, null,  false);
-            _dressUpObj.PutOnDefaultDressUpData();
-            _dressUpObj.PutOnSuitCfg(suitId, false, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
-            if (_wrapper == null)
-            {
-                _wrapper = new GoWrapper(_sceneObject);
-                _ui.m_holder.SetNativeObject(_wrapper);
-            }
-            else
-            {
-                _wrapper.wrapTarget = _sceneObject;
-            }
-
+            
+            _dressUpObjUI.ResetSceneObj(70, false, true, null,  false);
+            _dressUpObjUI.dressUpObj.PutOnSuitCfg(suitId, false, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
+            _dressUpObjUI.UpdateWrapper(_ui.m_holder);
         }
     }
 }

+ 0 - 1
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpFightView.cs

@@ -185,7 +185,6 @@ namespace GFGGame
             {
                 _sceneObject = GameObject.Instantiate(_scenePrefab);
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
-                MyDressUpHelper.dressUpObj.PutOnDefaultDressUpData();
             }
             _ui.m_txtDressLimit.text = string.Format("饰品穿戴限制:{0}/{1}", MyDressUpHelper.GetCurrentOrnamentCount(), GlobalCfgArray.globalCfg.dressLimitCount);
 

+ 11 - 43
GameClient/Assets/Game/HotUpdate/Views/FieldGuide/SuitShowView.cs

@@ -10,30 +10,21 @@ namespace GFGGame
         private UI_SuitShowUI _ui;
         private int _suitTypeId;
         private int _suitId;
-        private GameObject _scenePrefab;
-        private GameObject _sceneObject;
-        private GoWrapper _wrapper;
-        private DressUpObj _dressUpObj;
+        private DressUpObjUI _dressUpObjUI;
         private bool _actionIsPic;
         private List<int> _suitIds;
 
         public override void Dispose()
         {
-            if (_sceneObject != null)
+            if (_dressUpObjUI != null)
             {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
-
-            if (_wrapper != null)
-            {
-                _wrapper.Dispose();
-                _wrapper = null;
-            }
-            if (_dressUpObj != null)
+            if (_dressUpObjUI != null)
             {
-                _dressUpObj.Dispose();
-                _dressUpObj = null;
+                _dressUpObjUI.Dispose();
+                _dressUpObjUI = null;
             }
             if (_ui != null)
             {
@@ -52,8 +43,7 @@ namespace GFGGame
             isfullScreen = true;
             this.clickBlankToClose = false;
 
-            _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
-            _dressUpObj = new DressUpObj();
+            _dressUpObjUI = new DressUpObjUI("SceneDressUp");
 
             _ui.m_btnBack.onClick.Add(OnClickBtnBack);
 
@@ -100,11 +90,6 @@ namespace GFGGame
         protected override void OnHide()
         {
             base.OnHide();
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
         }
         protected override void RemoveEventListener()
         {
@@ -127,26 +112,9 @@ namespace GFGGame
             _actionIsPic = isPic;
             SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
             _ui.m_txtSuitName.text = suitCfg.name;
-            if (_sceneObject != null)
-            {
-                GameObject.Destroy(_sceneObject);
-                _sceneObject = null;
-            }
-            _sceneObject = GameObject.Instantiate(_scenePrefab);
-            int scale = 100;
-            _sceneObject.transform.localScale = new Vector3(scale, scale, scale);
-            _dressUpObj.setSceneObj(_sceneObject, false,true,null,false);
-            _dressUpObj.PutOnDefaultDressUpData();
-            _dressUpObj.PutOnSuitCfg(_suitId, isPic, new int[] { ConstDressUpItemType.BEI_JING });
-            if (_wrapper == null)
-            {
-                _wrapper = new GoWrapper(_sceneObject);
-                _ui.m_holder.SetNativeObject(_wrapper);
-            }
-            else
-            {
-                _wrapper.wrapTarget = _sceneObject;
-            }
+            _dressUpObjUI.ResetSceneObj(100, false,true,null,false);
+            _dressUpObjUI.dressUpObj.PutOnSuitCfg(_suitId, isPic, new int[] { ConstDressUpItemType.BEI_JING });
+            _dressUpObjUI.UpdateWrapper(_ui.m_holder);
             UpdateSuitBoxStatus();
         }