Browse Source

拍照道具添加数量限制

zhaoyang 3 năm trước cách đây
mục cha
commit
5a498dbdfa

+ 8 - 0
FGUIProject/assets/DressUp/PhotographUI.xml

@@ -23,5 +23,13 @@
     <component id="n5_7dea" name="ComSelectRes" src="7dea4f" fileName="components/ComSelect.xml" xy="0,1086">
       <relation target="" sidePair="center-center,bottom-bottom"/>
     </component>
+    <component id="n13_u7i8" name="btnUp" src="g3xa4h" fileName="components/Button8.xml" xy="12,633">
+      <relation target="" sidePair="bottom-bottom"/>
+      <Button icon="ui://mbo439wbxmtl4s"/>
+    </component>
+    <component id="n14_u7i8" name="btnDown" src="g3xa4h" fileName="components/Button8.xml" xy="8,796">
+      <relation target="" sidePair="bottom-bottom"/>
+      <Button icon="ui://mbo439wbxmtl4s"/>
+    </component>
   </displayList>
 </component>

+ 2 - 2
GameClient/Assets/Game/HotUpdate/DressUp/SceneController.cs

@@ -235,8 +235,8 @@ namespace GFGGame
                     size = GetGameObjectSize1(parentObj);
                     if (parentObj.name == "Role") boxCollider2D.size = size;
                     boxCollider2D.offset = -childGameObj.transform.localPosition;
-
-                    size = size * childGameObj.transform.localScale * parentObj.transform.localScale * 100;
+                    //* childGameObj.transform.localScale
+                    size = size * parentObj.transform.localScale * 100;
                     return size;
                 }
             }

+ 6 - 0
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/DressUp/UI_PhotographUI.cs

@@ -15,6 +15,8 @@ namespace UI.DressUp
         public GButton m_btnPhotograph;
         public GButton m_btnChoose;
         public UI_ComSelect m_ComSelectRes;
+        public GButton m_btnUp;
+        public GButton m_btnDown;
         public const string URL = "ui://mbo439wbbe944a";
         public const string PACKAGE_NAME = "DressUp";
         public const string RES_NAME = "PhotographUI";
@@ -70,6 +72,8 @@ namespace UI.DressUp
             m_btnPhotograph = (GButton)comp.GetChild("btnPhotograph");
             m_btnChoose = (GButton)comp.GetChild("btnChoose");
             m_ComSelectRes = (UI_ComSelect)UI_ComSelect.Create(comp.GetChild("ComSelectRes"));
+            m_btnUp = (GButton)comp.GetChild("btnUp");
+            m_btnDown = (GButton)comp.GetChild("btnDown");
         }
         public void Dispose(bool disposeTarget = false)
         {
@@ -83,6 +87,8 @@ namespace UI.DressUp
             m_btnChoose = null;
             m_ComSelectRes.Dispose();
             m_ComSelectRes = null;
+            m_btnUp = null;
+            m_btnDown = null;
             if(disposeTarget && target != null)
             {
                 target.RemoveFromParent();

+ 30 - 18
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs

@@ -15,11 +15,8 @@ namespace GFGGame
         private UI_PhotographUI _ui;
         private GameObject _scenePrefab;
         private GameObject _sceneObject;
-        // private DressUpObjDataCache equipDataCache;
 
-        // private const string MOVE = "MOVE";
-        // private const string SCALE = "SCALE";
-        // private const string ROTATION = "ROTATION";
+        private const int MAX_COUNT = 20;
         private const float MaxScale = 2;
         private const float MinScale = 0.1f;
         private const string BgResPath = "Bg/BgRes";
@@ -29,16 +26,9 @@ namespace GFGGame
         private const string RoleName = "Role";
         private const string NpcPath = "Scene/Npc";
         private const string BgResName = "BgRes";
-        // private const string BorderResName = "BorderRes";
-
-        // private GameObject bodyParent;
-        // private GameObject bgParent;
-        // private GameObject npcParent;
-        // private GameObject borderParent;
-        // private GameObject sceneParent;
 
         private List<int> _listData = null;//当前选择的资源数据
-        public List<int> _equipRoleData = new List<int>();//当前穿戴的角色数据
+        private List<GameObject> _itemGameObjs = new List<GameObject>();
         public Dictionary<int, List<int>> _equipSceneData = new Dictionary<int, List<int>>();//当前穿戴的场景数据
         private Dictionary<GameObject, float> _equipDistance = new Dictionary<GameObject, float>();
 
@@ -94,17 +84,20 @@ namespace GFGGame
             _ui.m_comSelectBox.m_btnDelete.onTouchBegin.Add(OnTouchBtnDeleteBegin);
             _ui.m_comSelectBox.m_btnDelete.onTouchEnd.Add(OnTouchBtnDeleteEnd);
 
+            _ui.m_btnUp.onClick.Add(OnClickBtnUp);
+            _ui.m_btnDown.onClick.Add(OnClickBtnDown);
+
         }
 
         protected override void OnShown()
         {
             base.OnShown();
             Input.multiTouchEnabled = true;
-            // equipDataCache = EquipDataCache.cacher;
+
             PhotographDataManager.Instance.ClassifyEquipData();
-            _equipRoleData = PhotographDataManager.Instance._equipRoleData;
             _equipSceneData = PhotographDataManager.Instance._equipSceneData;
 
+            _itemGameObjs.Clear();
             if (_sceneObject == null)
             {
                 _sceneObject = GameObject.Instantiate(_scenePrefab);
@@ -159,6 +152,11 @@ namespace GFGGame
         }
         private void OnListItemClick(EventContext context)
         {
+            if (_itemGameObjs.Count >= MAX_COUNT)
+            {
+                PromptController.Instance.ShowFloatTextPrompt("最多穿戴" + MAX_COUNT + "件物品");
+                return;
+            }
             int itemID = (int)((context.data as GObject).data);
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
 
@@ -209,7 +207,7 @@ namespace GFGGame
             RaycastHit2D[] hit2Ds = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
             if (hit2Ds.Length > 0)
             {
-                // maxLayer++;
+
                 lastPos = Vector2.zero;
 
                 hitGameObj = SceneController.GetFirstHitObj(hit2Ds);
@@ -408,7 +406,8 @@ namespace GFGGame
         private void UpdateBody()
         {
             GameObject bodyParent = _sceneObject.transform.Find(RolePath).gameObject;
-            SceneController.UpdatePhotographBody(_equipRoleData.ToArray(), _sceneObject, bodyParent);
+            SceneController.UpdatePhotographBody(PhotographDataManager.Instance._equipRoleData.ToArray(), _sceneObject, bodyParent);
+            _itemGameObjs.Add(bodyParent);
 
             maxLayer = PhotographDataManager.Instance.GetMaxLayer(bodyParent, maxLayer) + 1;
         }
@@ -436,6 +435,8 @@ namespace GFGGame
             spr.sortingOrder = maxLayer;
             tf.localPosition = new Vector2(-spr.bounds.center.x, -spr.bounds.center.y);
             SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
+            _itemGameObjs.Add(tf.parent.gameObject);
+
         }
         private void UpdateBorder(ItemCfg itemCfg)
         {
@@ -467,6 +468,7 @@ namespace GFGGame
                 SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, 2, itemCfg.resLayer2);
 
                 maxLayer = PhotographDataManager.Instance.GetMaxLayer(parentGameObj, maxLayer) + 1;
+                _itemGameObjs.Add(parentGameObj);
 
                 if (!isDefaultLayer)
                 {
@@ -486,6 +488,7 @@ namespace GFGGame
                 SceneController.AddItemToScene(_sceneObject, parentGameObj, itemCfg.id, 1, itemCfg.resLayer1);
 
                 maxLayer = PhotographDataManager.Instance.GetMaxLayer(parentGameObj, maxLayer) + 1;
+                _itemGameObjs.Add(parentGameObj);
 
                 if (!isDefaultLayer)
                 {
@@ -553,6 +556,7 @@ namespace GFGGame
             {
                 GameObject.DestroyImmediate(memoryHitGameObj);
             }
+            _itemGameObjs.Remove(memoryHitGameObj);
             _ui.m_comSelectBox.target.visible = false;
 
         }
@@ -567,6 +571,15 @@ namespace GFGGame
             hitGameObj = null;
             memoryHitGameObj = null;
         }
+
+        private void OnClickBtnUp()
+        {
+
+        }
+        private void OnClickBtnDown()
+        {
+
+        }
         private void OnClickBtnPhotograph()
         {
             _ui.target.visible = false;
@@ -600,8 +613,7 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
-            // equipDataCache = null;
-            _equipRoleData.Clear();
+
             _equipSceneData.Clear();
             hitGameObj = null;
             memoryHitGameObj = null;

BIN
GameClient/Assets/ResIn/UI/DressUp/DressUp_fui.bytes