zhaoyang 2 жил өмнө
parent
commit
81f8d8aefc

+ 19 - 247
GameClient/Assets/Game/HotUpdate/Data/PhotographDataManager.cs

@@ -47,7 +47,7 @@ namespace GFGGame
                 {
                     if (listBgData.IndexOf(itemID) < 0) listBgData.Add(itemID);
                 }
-                else if (itemCfg.subType == ConstDressUpItemType.QIAN_JING || itemCfg.subType == ConstDressUpItemType.BEI_SHI || itemCfg.subType == ConstDressUpItemType.HUAN_JING)
+                else if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemID, false))
                 {
                     if (listSceneData.IndexOf(itemID) < 0) listSceneData.Add(itemID);
                 }
@@ -60,10 +60,12 @@ namespace GFGGame
                 }
                 else if (itemCfg.subType == ConstItemSubType.BOREDR)
                 {
+                    if (listBorderData.IndexOf(ConstItemID.BORDERID) < 0) listBorderData.Insert(0, ConstItemID.BORDERID);
                     if (listBorderData.IndexOf(itemID) < 0) listBorderData.Add(itemID);
                 }
                 else if (itemCfg.subType == ConstItemSubType.EFFECT)
                 {
+                    if (listEffectData.IndexOf(ConstItemID.EFFECTID) < 0) listEffectData.Insert(0, ConstItemID.EFFECTID);
                     if (listEffectData.IndexOf(itemID) < 0) listEffectData.Add(itemID);
                 }
             }
@@ -77,266 +79,36 @@ namespace GFGGame
             _equipSceneData.Clear();
             for (int i = 0; i < MyDressUpHelper.dressUpObj.itemList.Count; i++)
             {
-                ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(MyDressUpHelper.dressUpObj.itemList[i]);
-                if (itemCfg.subType == ConstDressUpItemType.QIAN_JING || itemCfg.subType == ConstDressUpItemType.BEI_SHI || itemCfg.subType == ConstDressUpItemType.HUAN_JING || itemCfg.subType == ConstDressUpItemType.FEN_WEI)
+                int itemId = MyDressUpHelper.dressUpObj.itemList[i];
+                if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneType(itemId, false))
                 {
-                    PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemCfg.id, out _equipSceneData);
+                    if (!_equipSceneData.ContainsKey(itemId))
+                    {
+                        _equipSceneData.Add(itemId, new List<int>());
+                    }
+                    _equipSceneData[itemId].Add(itemId);
                 }
             }
         }
-        public void AddEquipItem(Dictionary<int, List<int>> _equipSceneData, int itemID, out Dictionary<int, List<int>> equipSceneData)
-        {
-            if (!_equipSceneData.ContainsKey(itemID))
-            {
-                _equipSceneData.Add(itemID, new List<int>());
-            }
-            _equipSceneData[itemID].Add(itemID);
-            equipSceneData = _equipSceneData;
-        }
-
 
-        public List<int> GetListData(EnumPhotographType index)
+        public List<int> GetListData(EnumPhotographType type)
         {
-            List<int> _listData = null;
-            switch (index)
+            switch (type)
             {
                 case EnumPhotographType.BG:
-                    _listData = PhotographDataManager.Instance.listBgData;
-                    break;
+                    return listBgData;
                 case EnumPhotographType.NPC:
-                    _listData = PhotographDataManager.Instance.listNpcData;
-                    break;
+                    return listNpcData;
                 case EnumPhotographType.SCENE:
-                    _listData = PhotographDataManager.Instance.listSceneData;
-                    break;
+                    return listSceneData;
                 case EnumPhotographType.BORDER:
-                    _listData = PhotographDataManager.Instance.listBorderData;
-                    if (_listData.IndexOf(ConstItemID.BORDERID) < 0)
-                    {
-                        _listData.Insert(0, ConstItemID.BORDERID);
-                    }
-                    break;
+                    return listBorderData;
                 case EnumPhotographType.EFFECT:
-                    _listData = PhotographDataManager.Instance.listEffectData;
-                    if (_listData.IndexOf(ConstItemID.EffectID) < 0)
-                    {
-                        _listData.Insert(0, ConstItemID.EffectID);
-                    }
-                    break;
-            }
-            return _listData;
-        }
-
-
-        //是否点击在UI上
-        public bool IsTouchUI(GComponent viewCom)
-        {
-            GObject obj = GRoot.inst.touchTarget;
-            UI_PhotographUI _viewCom = UI_PhotographUI.Proxy(viewCom);
-            return _viewCom.m_comSelectBox.m_btnSize.GetChild("icon").asLoader == obj || _viewCom.m_comSelectBox.m_btnDelete.GetChild("icon").asLoader == obj || _viewCom.m_comSelectBox.m_btnFlip.GetChild("icon").asLoader == obj || _viewCom.m_btnBack == obj || _viewCom.m_btnChoose.GetChild("icon").asLoader == obj || _viewCom.m_btnPhotograph.GetChild("icon").asLoader == obj || _viewCom.m_btnUp.GetChild("icon").asLoader == obj || _viewCom.m_btnDown.GetChild("icon").asLoader == obj || _viewCom.m_btnGalleryJoin.GetChild("icon").asLoader == obj;
-        }
-
-
-        public void SetLayer(GameObject hitGameObj, string state)
-        {
-            if (state != "refresh")
-            {
-                int index = itemGameObjs.IndexOf(hitGameObj);
-                if (state != "top")
-                {
-                    if (index < 0)
-                    {
-                        PromptController.Instance.ShowFloatTextPrompt("未选中任物品");
-                        return;
-                    }
-                    if (index == 0 && state == "down")
-                    {
-                        PromptController.Instance.ShowFloatTextPrompt("已经在最下层了");
-                        return;
-                    }
-                    if (index == itemGameObjs.Count - 1 && state == "up")
-                    {
-                        PromptController.Instance.ShowFloatTextPrompt("已经在最上层了");
-                        return;
-                    }
-                }
-                GameObject gameObject = itemGameObjs[index];
-                itemGameObjs.RemoveAt(index);
-                if (state == "up")
-                {
-                    itemGameObjs.Insert((index + 1), gameObject);
-
-                }
-                else if (state == "down")
-                {
-                    itemGameObjs.Insert((index - 1), gameObject);
-
-                }
-                else if (state == "top")
-                {
-                    itemGameObjs.Add(gameObject);
-                }
-                else
-                {
-                    PromptController.Instance.ShowFloatTextPrompt(state + "操作失败");
-                    return;
-                }
-            }
-
-            for (int i = 0; i < itemGameObjs.Count; i++)
-            {
-                PhotographDataManager.Instance.ChangeLayer(itemGameObjs[i], i * 100, state);
-            }
-
-        }
-        private void ChangeLayer(GameObject parentObj, int layer, string state)
-        {
-            int count = 0;
-            if (state == "up" || state == "top")
-            {
-                count = layer - GetMinLayer(parentObj);
-            }
-            else if (state == "down")
-            {
-                count = layer - GetMaxLayer(parentObj);
-            }
-
-            int maxLayer = int.MinValue;
-            SpriteRenderer[] sps = parentObj.GetComponentsInChildren<SpriteRenderer>();
-            for (int i = 0; i < sps.Length; i++)
-            {
-                sps[i].sortingOrder = sps[i].sortingOrder + layer + count;
-                if (maxLayer < sps[i].sortingOrder)
-                {
-                    maxLayer = sps[i].sortingOrder;
-                }
-            }
-            for (int i = 0; i < parentObj.transform.childCount; i++)
-            {
-                Transform tf = parentObj.transform.GetChild(i);
-                string[] strs = tf.name.Split('_');
-                if (strs.Length > 1 && strs[1] == "eff")//子物体是特效
-                {
-                    DressUpUtil.SetParticleSortingOrder(tf.gameObject, maxLayer);
-                }
-            }
-        }
-        private int GetMaxLayer(GameObject parentObj)
-        {
-            int layer = int.MinValue;
-            for (int i = 0; i < parentObj.transform.childCount; i++)
-            {
-                Transform tf = parentObj.transform.GetChild(i);
-                SpriteRenderer sp = tf.GetComponent<SpriteRenderer>();
-                if (sp && layer < sp.sortingOrder)
-                {
-                    layer = sp.sortingOrder;
-                }
-            }
-            return layer;
-        }
-        public int GetMinLayer(GameObject parentObj)
-        {
-            int layer = int.MaxValue;
-            for (int i = 0; i < parentObj.transform.childCount; i++)
-            {
-                Transform tf = parentObj.transform.GetChild(i);
-                SpriteRenderer sp = tf.GetComponent<SpriteRenderer>();
-                if (sp && sp.sortingOrder < layer)
-                {
-                    layer = sp.sortingOrder;
-                }
-            }
-            return layer;
-        }
+                    return listEffectData;
+                default:
+                    return new List<int>();
 
-        public void SetBgPos(GameObject hitGameObj, Vector2 uiSize)
-        {
-            Vector2 size = hitGameObj.GetComponent<SpriteRenderer>().size;
-
-            float deviationWidth = (size.x - uiSize.x / 100) / 2;
-            float deviationHeigh = (size.y - uiSize.y / 100) / 2;
-            Vector2 pos = hitGameObj.transform.position;
-            if (pos.x <= -deviationWidth)
-            {
-                hitGameObj.transform.position = new Vector2(-deviationWidth, hitGameObj.transform.position.y);
-            }
-            if (pos.x >= deviationWidth)
-            {
-                hitGameObj.transform.position = new Vector2(deviationWidth, hitGameObj.transform.position.y);
-            }
-            if (pos.y <= -deviationHeigh)
-            {
-                hitGameObj.transform.position = new Vector2(hitGameObj.transform.position.x, -deviationHeigh);
-            }
-            if (pos.y >= deviationHeigh)
-            {
-                hitGameObj.transform.position = new Vector2(hitGameObj.transform.position.x, deviationHeigh);
             }
         }
-
-
-
-        public void AddItemGameObject(GameObject parentGameObj, bool setLayer)
-        {
-            itemGameObjs.Add(parentGameObj);
-
-            if (setLayer)
-            {
-                int index = itemGameObjs.Count - 1;
-                PhotographDataManager.Instance.ChangeLayer(itemGameObjs[index], index * 100, "up");
-            }
-            itemGameObjs.Sort((GameObject a, GameObject b) =>
-            {
-
-                int layerA = PhotographDataManager.Instance.GetMinLayer(a);
-                int layerB = PhotographDataManager.Instance.GetMinLayer(b);
-                if (layerA < layerB)
-                {
-                    return -1;
-                }
-                else if (layerA > layerB)
-                {
-                    return 1;
-                }
-                return 0;
-            });
-
-        }
-
-
-        /// <summary>
-        /// 将照片保存到本地
-        /// </summary>
-        public void SavePicturoToLocal(byte[] bytes, string fileName)
-        {
-            string path = Application.persistentDataPath + "/Pictures/WanshiJing/";
-            //判断目录是否存在,不存在则会创建目录
-            if (!Directory.Exists(path))
-            {
-                try
-                {
-                    Directory.CreateDirectory(path);
-                }
-                catch (Exception exception)
-                {
-                    throw new Exception("创建文件夹失败, error:" + exception.Message);
-
-                }
-            }
-            var filePath = path + fileName;
-            // byte[] bytes = tex.EncodeToJPG();//将纹理数据,转化成一个jpg图片
-            File.WriteAllBytes(filePath, bytes);
-            UpdateSystemPhoto(filePath);
-        }
-        //调用iOS或Android原生方法保存图片后更新相册.
-        private void UpdateSystemPhoto(string filePath)
-        {
-#if UNITY_ANDROID
-            AndroidJavaObject androidJavaObject = new AndroidJavaObject("com.gfg.gfglibrary.SaveImage"); //设置成我们aar库中的签名+类名
-            androidJavaObject.Call("scanFile", filePath, "已保存至本地"); //这里我们可以设置保存成功弹窗内容
-#endif
-        }
-
     }
 }

+ 159 - 27
GameClient/Assets/Game/HotUpdate/Data/PhotographSceneManager.cs

@@ -1,3 +1,5 @@
+using System;
+using System.Collections.Generic;
 using UnityEngine;
 
 namespace GFGGame
@@ -10,56 +12,186 @@ namespace GFGGame
         {
             Transform tf = sceneObject.transform.Find("Bg/BgRes");
             string resPath = ResPathUtil.GetDressUpPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
-            SceneController.SetSpriteRendererToTransform(tf, resPath);
+            SetSpriteRendererToTransform(tf, resPath);
             SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
             spr.sortingOrder = -200;
-            SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
+            SetBoxCollider2DToGameObject(tf.gameObject);
 
         }
+
         public void AddBorderItem(ItemCfg itemCfg)
         {
             Transform tf = sceneObject.transform.Find("Border/BorderRes");
+            string resPath = ResPathUtil.GetPhotographBorderPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
+            SetSpriteRendererToTransform(tf, resPath);
             SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
-            if (spr != null)
+            spr.sortingOrder = 10000;//边框在所有道具的上边
+            SetBoxCollider2DToGameObject(tf.gameObject);
+        }
+
+        public void AddNpcItem(ItemCfg itemCfg)
+        {
+            Transform tf = sceneObject.transform.Find("Scene/Npc/NpcRes");
+            string resPath = ResPathUtil.GetNpcPicFPath(itemCfg.res);
+            SetSpriteRendererToTransform(tf, resPath);
+            SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
+            tf.localPosition = new Vector2(-spr.bounds.center.x, -spr.bounds.center.y);
+            SetBoxCollider2DToGameObject(tf.gameObject);
+            AddItemGameObjectToList(tf.parent.gameObject, true);
+
+        }
+        public void AddBodyItem()
+        {
+            GameObject bodyParent = sceneObject.transform.Find("Scene/Role").gameObject;
+            UpdatePhotographBody(sceneObject, bodyParent);
+            AddItemGameObjectToList(bodyParent, false);
+        }
+
+        public void AddSceneItem(GameObject parentGameObj, ItemCfg itemCfg, int layer, bool setLayer, bool isOnlyEff = false)
+        {
+            if (isOnlyEff)
             {
-                spr.sprite = null;
+                AddOnlyEffItemToScene(sceneObject, parentGameObj, itemCfg.id, layer);
             }
-            if (itemCfg.id == ConstItemID.BORDERID)
+            else
             {
-                SceneController.DeleteBoxCollider2DFromGameObject(tf.gameObject);
-                return;
+                AddItemToScene(sceneObject, parentGameObj, itemCfg.id, layer);
             }
-            string resPath = ResPathUtil.GetPhotographBorderPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
-            SceneController.SetSpriteRendererToTransform(tf, resPath);
-            spr = tf.GetComponent<SpriteRenderer>();
-            spr.sortingOrder = 10000;//边框在所有道具的上边
-            SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
+            AddItemGameObjectToList(parentGameObj, setLayer);
         }
-        public void AddSceneItem(GameObject parentGameObj, ItemCfg itemCfg, int layer, bool setLayer)
+
+        //拍照场景添加单个道具
+        public void AddItemToScene(GameObject sceneObj, GameObject parentGameObj, int itemId, int resLayer)
         {
+            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
+            parentGameObj.transform.SetParent(sceneObj.transform.Find("Scene"), false);
 
-            // GameObject parentGameObj = new GameObject(string.Format("{0}_{1}", itemCfg.id, 0));
-            SceneController.AddItemToScene(sceneObject, parentGameObj, itemCfg.id, layer);
-            PhotographDataManager.Instance.AddItemGameObject(parentGameObj, setLayer);
+            DressUpUtil.AddItem(itemId, sceneObj, false, false, parentGameObj, resLayer);
+            GameObject gameObject = parentGameObj.transform.GetChild(0).gameObject;
+            SetBoxCollider2DToGameObject(gameObject);
 
+            if (itemCfg.isAni > 0)
+            {
+                gameObject.GetComponent<SpriteRenderer>().enabled = false;
+                DressUpUtil.AddItem(itemId, sceneObj, false, true, gameObject, resLayer);
+                gameObject.transform.GetChild(0).localPosition = gameObject.transform.GetChild(0).localPosition - gameObject.transform.localPosition;
+            }
         }
-        public void AddNpcItem(ItemCfg itemCfg)
+
+        private void AddOnlyEffItemToScene(GameObject sceneObj, GameObject parentGameObj, int itemId, int resLayer)
         {
-            Transform tf = sceneObject.transform.Find("Scene/Npc/NpcRes");
-            string resPath = ResPathUtil.GetNpcPicFPath(itemCfg.res);
-            SceneController.SetSpriteRendererToTransform(tf, resPath);
+            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
+            parentGameObj.transform.SetParent(sceneObj.transform.Find("Scene"), false);
+
+            GameObject gameObject = new GameObject(itemCfg.id.ToString());
+            gameObject.transform.SetParent(parentGameObj.transform);
+            string resPath = ResPathUtil.GetDressUpPath(itemCfg.res);
+            SetSpriteRendererToTransform(gameObject.transform, resPath);
+            SetBoxCollider2DToGameObject(gameObject);
+            gameObject.GetComponent<SpriteRenderer>().enabled = false;
+            DressUpUtil.AddItem(itemId, sceneObj, false, true, parentGameObj, resLayer);
+        }
+
+        //拍照角色
+        private void UpdatePhotographBody(GameObject sceneObj, GameObject parentObj)
+        {
+
+            PhotographDataManager.Instance.dressUpObj.setSceneObj(sceneObj, false, false, parentObj, false);
+            PhotographDataManager.Instance.dressUpObj.PutOnDressUpData(MyDressUpHelper.dressUpObj.DressUpDataClone());
+            GameObject gameObject = parentObj.transform.Find("BodyRes").gameObject;
+            if (MyDressUpHelper.dressUpObj.actionId > 0)
+            {
+                var suitCfg = SuitCfgArray.Instance.GetCfg(MyDressUpHelper.dressUpObj.actionId);
+                string resPath = ResPathUtil.GetDressUpPath(suitCfg.picRes);
+                SetSpriteRendererToTransform(gameObject.transform, resPath);
+                SetBoxCollider2DToGameObject(gameObject);
+                DressUpUtil.LoadSpritePos(suitCfg.picRes, out float x, out float y);
+                gameObject.transform.localPosition = new Vector3(x, y, gameObject.transform.localPosition.z);
+                gameObject.GetComponent<SpriteRenderer>().enabled = false;
+            }
+            else
+            {
+                PhotographUtil.Instance.SetGameObjectCenter(parentObj);
+                SetBoxCollider2DToGameObject(gameObject);
+            }
+        }
+
+        //向Transform添加SpriteRenderer并设置资源
+        private void SetSpriteRendererToTransform(Transform tf, string resPath)
+        {
+            tf.position = Vector3.zero;
             SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
+            if (spr == null)
+            {
+                tf.gameObject.AddComponent<SpriteRenderer>();
+                spr = tf.GetComponent<SpriteRenderer>();
+            }
+            DressUpUtil.ChangeAssetReleaser(tf.gameObject, resPath);
+            Sprite sp = GFGAsset.Load<Sprite>(resPath);
+            spr.sprite = sp;
+            spr.size = spr.sprite.bounds.size;//将节点设置为原图大小
 
-            tf.localPosition = new Vector2(-spr.bounds.center.x, -spr.bounds.center.y);
-            SceneController.SetBoxCollider2DToGameObject(tf.gameObject);
-            PhotographDataManager.Instance.AddItemGameObject(tf.parent.gameObject, true);
+        }
 
+        //向GameObject添加BoxCollider2D
+        private void SetBoxCollider2DToGameObject(GameObject gameObject)
+        {
+            BoxCollider2D polygonCollider2D = gameObject.GetComponent<BoxCollider2D>();
+            if (polygonCollider2D != null)
+            {
+                GameObject.Destroy(polygonCollider2D);
+            }
+            polygonCollider2D = gameObject.AddComponent<BoxCollider2D>();
+            polygonCollider2D.isTrigger = true;
+            polygonCollider2D.size = PhotographUtil.Instance.GetGameObjectBoundsSize(gameObject.transform.parent.gameObject) / 100;
         }
-        public void AddBodyItem()
+
+        private void AddItemGameObjectToList(GameObject parentGameObj, bool setLayer)
         {
-            GameObject bodyParent = sceneObject.transform.Find("Scene/Role").gameObject;
-            SceneController.UpdatePhotographBody(sceneObject, bodyParent);
-            PhotographDataManager.Instance.AddItemGameObject(bodyParent, false);
+            List<GameObject> itemGameObjs = PhotographDataManager.Instance.itemGameObjs;
+            itemGameObjs.Add(parentGameObj);
+
+            if (setLayer)
+            {
+                int index = itemGameObjs.Count - 1;
+                PhotographUtil.Instance.ChangeLayer(itemGameObjs[index], index * 100, "up");
+            }
+            itemGameObjs.Sort((GameObject a, GameObject b) =>
+            {
+
+                int layerA = PhotographUtil.Instance.GetMinLayer(a);
+                int layerB = PhotographUtil.Instance.GetMinLayer(b);
+                if (layerA < layerB)
+                {
+                    return -1;
+                }
+                else if (layerA > layerB)
+                {
+                    return 1;
+                }
+                return 0;
+            });
+
+        }
+
+        //移除指定GameObject的BoxCollider2D
+        public void DeleteBoxCollider2DFromGameObject(GameObject gameObject)
+        {
+            BoxCollider2D polygonCollider2D = gameObject.GetComponent<BoxCollider2D>();
+            if (polygonCollider2D != null)
+            {
+                GameObject.Destroy(polygonCollider2D);
+            }
+        }
+        //移除指定GameObject的SpriteRenderer
+        public void DeleteSpriteRendererFromGameObject(GameObject gameObject)
+        {
+
+            SpriteRenderer spriteRenderer = gameObject.GetComponent<SpriteRenderer>();
+            if (spriteRenderer != null)
+            {
+                GameObject.Destroy(spriteRenderer);
+            }
         }
     }
 }

+ 349 - 0
GameClient/Assets/Game/HotUpdate/Data/PhotographUtil.cs

@@ -0,0 +1,349 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using FairyGUI;
+using Live2D.Cubism.Rendering;
+using UI.DressUp;
+using UnityEngine;
+
+namespace GFGGame
+{
+    public class PhotographUtil : SingletonBase<PhotographUtil>
+    {
+
+        //传入父物体,返回边界大小
+        public Vector2 GetGameObjectBoxSize(GameObject parentObj)
+        {
+            Vector2 size = Vector2.one;
+            for (int i = 0; i < parentObj.transform.childCount; i++)
+            {
+                GameObject childGameObj = parentObj.transform.GetChild(i).gameObject;
+                BoxCollider2D boxCollider2D = childGameObj.GetComponent<BoxCollider2D>();
+                if (boxCollider2D != null)
+                {
+                    size = GetGameObjectBoundsSize(parentObj);
+                    size = size * boxCollider2D.transform.localScale;
+                    size.x = Math.Abs(size.x);
+                    size.y = Math.Abs(size.y);
+                    return size;
+                }
+            }
+            return Vector2.zero;
+        }
+        public Vector2 GetGameObjectBoundsSize(GameObject parentObj)
+        {
+            float right = int.MinValue;
+            float left = int.MaxValue;
+            float top = int.MinValue;
+            float bottom = int.MaxValue;
+
+            BoxCollider2D boxCollider2 = parentObj.GetComponentInChildren<BoxCollider2D>();
+            Vector2 pos = boxCollider2.transform.localPosition;
+            Vector2 size = boxCollider2.size * 100 * Math.Abs(parentObj.transform.localScale.x);
+
+            right = Math.Max(size.x / 2 + pos.x, right);
+            left = Math.Min(pos.x - size.x / 2, left);
+            top = Math.Max(size.y / 2 + pos.y, top);
+            bottom = Math.Min(pos.y - size.y / 2, bottom);
+
+
+
+            Vector2 boundsSize = new Vector2(right - left, top - bottom);
+            return boundsSize;
+
+        }
+
+
+        //设置物体中心点
+        public void SetGameObjectCenter(GameObject parentObj)
+        {
+            Transform parent = parentObj.transform;  // 2.选中技算
+            Vector3 postion = parent.position;
+            Quaternion rotation = parent.rotation;
+            Vector3 scale = parent.localScale;
+            parent.position = Vector3.zero;
+            parent.rotation = Quaternion.Euler(Vector3.zero);
+            parent.localScale = Vector3.one;
+            Vector3 center = Vector3.zero;
+            int index = 0;
+            foreach (Transform t in parent)
+            {
+                string[] strs = t.name.Split('_');
+                if (strs.Length > 1 && strs[1] == "eff") continue;//不计算特效大小
+                Renderer render = t.GetComponent<Renderer>();
+                if (render)
+                {
+                    index++;
+                    center += render.bounds.center;
+                }
+            }
+            center /= index;
+            Bounds bounds = new Bounds(center, Vector3.zero);
+            foreach (Transform t in parent)
+            {
+                string[] strs = t.name.Split('_');
+                if (strs.Length > 1 && strs[1] == "eff") continue;
+                Renderer render = t.GetComponent<Renderer>();
+                if (render) bounds.Encapsulate(render.bounds);
+            }
+
+            parent.position = postion;
+            parent.rotation = rotation;
+            parent.localScale = scale;
+
+            foreach (Transform t in parent)
+            {
+                string[] strs = t.parent.name.Split('_');
+                if (strs.Length > 1 && strs[1] == "eff") continue;
+                t.position = t.position - bounds.center;
+            }
+
+            parent.position = bounds.center + parent.position;
+
+
+        }
+
+
+        public GameObject GetFirstHitObj(RaycastHit2D[] hit2Ds)
+        {
+            int layer = int.MinValue;
+            GameObject gameObject = null;
+            for (int i = 0; i < hit2Ds.Length; i++)
+            {
+
+                int gameobjMaxlayer = GetMaxLayer(hit2Ds[i].collider.transform.parent.gameObject);
+                if (gameobjMaxlayer > layer)
+                {
+                    layer = gameobjMaxlayer;
+                    gameObject = hit2Ds[i].collider.gameObject;
+                }
+            }
+            return gameObject;
+        }
+
+        //是否点击在UI上
+        public bool IsTouchUI(GComponent viewCom)
+        {
+            GObject obj = GRoot.inst.touchTarget;
+            UI_PhotographUI _viewCom = UI_PhotographUI.Proxy(viewCom);
+            return _viewCom.m_comSelectBox.m_btnSize.GetChild("icon").asLoader == obj || _viewCom.m_comSelectBox.m_btnDelete.GetChild("icon").asLoader == obj || _viewCom.m_comSelectBox.m_btnFlip.GetChild("icon").asLoader == obj || _viewCom.m_btnBack == obj || _viewCom.m_btnChoose.GetChild("icon").asLoader == obj || _viewCom.m_btnPhotograph.GetChild("icon").asLoader == obj || _viewCom.m_btnUp.GetChild("icon").asLoader == obj || _viewCom.m_btnDown.GetChild("icon").asLoader == obj || _viewCom.m_btnGalleryJoin.GetChild("icon").asLoader == obj;
+        }
+
+
+        public void SetLayer(GameObject hitGameObj, string state)
+        {
+            List<GameObject> itemGameObjs = PhotographDataManager.Instance.itemGameObjs;
+            if (state != "refresh")
+            {
+                int index = itemGameObjs.IndexOf(hitGameObj);
+                if (state != "top")
+                {
+                    if (index < 0)
+                    {
+                        PromptController.Instance.ShowFloatTextPrompt("未选中任物品");
+                        return;
+                    }
+                    if (index == 0 && state == "down")
+                    {
+                        PromptController.Instance.ShowFloatTextPrompt("已经在最下层了");
+                        return;
+                    }
+                    if (index == itemGameObjs.Count - 1 && state == "up")
+                    {
+                        PromptController.Instance.ShowFloatTextPrompt("已经在最上层了");
+                        return;
+                    }
+                }
+                GameObject gameObject = itemGameObjs[index];
+                itemGameObjs.RemoveAt(index);
+                if (state == "up")
+                {
+                    itemGameObjs.Insert((index + 1), gameObject);
+
+                }
+                else if (state == "down")
+                {
+                    itemGameObjs.Insert((index - 1), gameObject);
+
+                }
+                else if (state == "top")
+                {
+                    itemGameObjs.Add(gameObject);
+                }
+                else
+                {
+                    PromptController.Instance.ShowFloatTextPrompt(state + "操作失败");
+                    return;
+                }
+            }
+
+            for (int i = 0; i < itemGameObjs.Count; i++)
+            {
+                ChangeLayer(itemGameObjs[i], i * 100, state);
+            }
+
+        }
+        public void ChangeLayer(GameObject parentObj, int layer, string state)
+        {
+            int count = 0;
+            if (state == "up" || state == "top")
+            {
+                count = layer - GetMinLayer(parentObj);
+            }
+            else if (state == "down")
+            {
+                count = layer - GetMaxLayer(parentObj);
+            }
+            int changeLayer = layer + count;
+
+            int maxLayer = int.MinValue;
+            SpriteRenderer[] sps = parentObj.GetComponentsInChildren<SpriteRenderer>();//选中道具可能含有静态图
+            for (int i = 0; i < sps.Length; i++)
+            {
+                int sortingOrder = sps[i].sortingOrder + changeLayer;
+                sps[i].sortingOrder = sortingOrder;
+
+                ParticleSystem[] particles = sps[i].gameObject.GetComponentsInChildren<ParticleSystem>();
+                for (int j = 0; j < particles.Length; j++)//静态图可能是动画
+                {
+                    var renderer = particles[j].GetComponent<Renderer>();
+                    if (renderer != null)
+                    {
+                        renderer.sortingOrder = sortingOrder;
+                    }
+                }
+
+                if (maxLayer < sortingOrder)
+                {
+                    maxLayer = sortingOrder;
+                }
+            }
+
+
+            for (int i = 0; i < parentObj.transform.childCount; i++)//选中道具可能含有特效
+            {
+                Transform tf = parentObj.transform.GetChild(i);
+                string[] strs = tf.name.Split('_');
+                if (strs.Length > 1 && strs[1] == "eff")//子物体是特效
+                {
+                    DressUpUtil.SetParticleSortingOrder(tf.gameObject, changeLayer, true);
+                }
+            }
+
+            var render = parentObj.GetComponentInChildren<CubismRenderController>();
+            if (render != null)
+            {
+                render.SortingOrder = render.SortingOrder + changeLayer;
+            }
+        }
+        private int GetMaxLayer(GameObject parentObj)
+        {
+            int layer = int.MinValue;
+            for (int i = 0; i < parentObj.transform.childCount; i++)
+            {
+                GameObject gameObject = parentObj.transform.GetChild(i).gameObject;
+                Transform tf = gameObject.transform;
+                SpriteRenderer sp = tf.GetComponent<SpriteRenderer>();
+                if (sp && layer < sp.sortingOrder)
+                {
+                    layer = sp.sortingOrder;
+
+                    ParticleSystem[] particles = sp.gameObject.GetComponentsInChildren<ParticleSystem>();
+                    for (int j = 0; j < particles.Length; j++)
+                    {
+                        var renderer = particles[j].GetComponent<Renderer>();
+                        if (renderer != null && layer < renderer.sortingOrder)
+                        {
+                            layer = renderer.sortingOrder;
+                        }
+                    }
+                }
+            }
+            return layer;
+        }
+        public int GetMinLayer(GameObject parentObj)
+        {
+            int layer = int.MaxValue;
+            for (int i = 0; i < parentObj.transform.childCount; i++)
+            {
+                GameObject gameObject = parentObj.transform.GetChild(i).gameObject;
+                Transform tf = gameObject.transform;
+                SpriteRenderer sp = tf.GetComponent<SpriteRenderer>();
+                if (sp && sp.sortingOrder < layer)
+                {
+                    layer = sp.sortingOrder;
+
+                    ParticleSystem[] particles = sp.gameObject.GetComponentsInChildren<ParticleSystem>();
+                    for (int j = 0; j < particles.Length; j++)
+                    {
+                        var renderer = particles[j].GetComponent<Renderer>();
+                        if (renderer != null && renderer.sortingOrder < layer)
+                        {
+                            layer = renderer.sortingOrder;
+                        }
+                    }
+                }
+            }
+            return layer;
+        }
+
+        public void SetBgPos(GameObject hitGameObj, Vector2 uiSize)
+        {
+            Vector2 size = hitGameObj.GetComponent<SpriteRenderer>().size;
+
+            float deviationWidth = (size.x - uiSize.x / 100) / 2;
+            float deviationHeigh = (size.y - uiSize.y / 100) / 2;
+            Vector2 pos = hitGameObj.transform.position;
+            if (pos.x <= -deviationWidth)
+            {
+                hitGameObj.transform.position = new Vector2(-deviationWidth, hitGameObj.transform.position.y);
+            }
+            if (pos.x >= deviationWidth)
+            {
+                hitGameObj.transform.position = new Vector2(deviationWidth, hitGameObj.transform.position.y);
+            }
+            if (pos.y <= -deviationHeigh)
+            {
+                hitGameObj.transform.position = new Vector2(hitGameObj.transform.position.x, -deviationHeigh);
+            }
+            if (pos.y >= deviationHeigh)
+            {
+                hitGameObj.transform.position = new Vector2(hitGameObj.transform.position.x, deviationHeigh);
+            }
+        }
+
+        /// <summary>
+        /// 将照片保存到本地
+        /// </summary>
+        public void SavePicturoToLocal(byte[] bytes, string fileName)
+        {
+            string path = Application.persistentDataPath + "/Pictures/WanshiJing/";
+            //判断目录是否存在,不存在则会创建目录
+            if (!Directory.Exists(path))
+            {
+                try
+                {
+                    Directory.CreateDirectory(path);
+                }
+                catch (Exception exception)
+                {
+                    throw new Exception("创建文件夹失败, error:" + exception.Message);
+
+                }
+            }
+            var filePath = path + fileName;
+            // byte[] bytes = tex.EncodeToJPG();//将纹理数据,转化成一个jpg图片
+            File.WriteAllBytes(filePath, bytes);
+            UpdateSystemPhoto(filePath);
+        }
+        //调用iOS或Android原生方法保存图片后更新相册.
+        private void UpdateSystemPhoto(string filePath)
+        {
+#if UNITY_ANDROID
+            AndroidJavaObject androidJavaObject = new AndroidJavaObject("com.gfg.gfglibrary.SaveImage"); //设置成我们aar库中的签名+类名
+            androidJavaObject.Call("scanFile", filePath, "已保存至本地"); //这里我们可以设置保存成功弹窗内容
+#endif
+        }
+
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Data/PhotographUtil.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a4c999a4b41d9fe45b078e8e70601472
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 22 - 19
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -248,7 +248,7 @@ namespace GFGGame
             var aniObjName = string.Format(FORMAT_ANIMATION_NAME, itemCfg.subType, layerId);
             TryRemoveAnimationObj(parentObj, aniObjName);
             string ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType);
-            
+
 
             if (itemCfg.isAni > 0 && showAni)
             {
@@ -443,29 +443,32 @@ namespace GFGGame
 
         public static void SetParticleSortingOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
         {
-            var count = gameObj.transform.childCount;
-            for (int i = 0; i < count; i++)
+            // var count = gameObj.transform.childCount;
+            // for (int i = 0; i < count; i++)
+            // {
+            //     var tf = gameObj.transform.GetChild(i);
+            //     var ps = tf.GetComponent<ParticleSystem>();
+            //     if (ps != null)
+            //     {
+
+            ParticleSystem[] particles = gameObj.transform.GetComponentsInChildren<ParticleSystem>();
+            for (int i = 0; i < particles.Length; i++)
             {
-                var tf = gameObj.transform.GetChild(i);
-                var ps = tf.GetComponent<ParticleSystem>();
-                if (ps != null)
+                var renderer = particles[i].GetComponent<Renderer>();
+                if (renderer != null)
                 {
-                    var renderer = ps.GetComponent<Renderer>();
-                    if (renderer != null)
+                    if (isAdd)
+                    {
+                        renderer.sortingOrder = renderer.sortingOrder + sortingOrder;
+                    }
+                    else
                     {
-                        if (isAdd)
-                        {
-                            renderer.sortingOrder = renderer.sortingOrder + sortingOrder;
-                        }
-                        else
-                        {
-
-                            renderer.sortingOrder = sortingOrder;
-                        }
+
+                        renderer.sortingOrder = sortingOrder;
                     }
                 }
             }
         }
-
     }
-}
+
+}

+ 1 - 199
GameClient/Assets/Game/HotUpdate/DressUp/SceneController.cs

@@ -37,7 +37,7 @@ namespace GFGGame
             spr1.sprite = sp1;
             //角色
             CustomSuitData suitSavedData = CustomSuitDataManager.GetCurrentSuitList();
-            MyDressUpHelper.dressUpObj.setSceneObj(sceneObj, false,true,null,false);
+            MyDressUpHelper.dressUpObj.setSceneObj(sceneObj, false, true, null, false);
             MyDressUpHelper.dressUpObj.PutOnDressUpData(suitSavedData.dressUpData);
         }
 
@@ -110,204 +110,6 @@ namespace GFGGame
             spr.sprite = sp;
         }
 
-        //拍照角色
-        public static void UpdatePhotographBody(GameObject sceneObj, GameObject parentObj)
-        {
-
-            PhotographDataManager.Instance.dressUpObj.setSceneObj(sceneObj,false, false, parentObj, false);
-            PhotographDataManager.Instance.dressUpObj.PutOnDressUpData(MyDressUpHelper.dressUpObj.DressUpDataClone());
-
-            GameObject gameObject = parentObj.transform.Find("Head").gameObject;
-
-            SceneController.SetBoxCollider2DToGameObject(gameObject);
-
-        }
-
-        //拍照场景添加单个道具
-        public static void AddItemToScene(GameObject sceneObj, GameObject parentGameObj, int itemId, int resLayer)
-        {
-            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
-
-            parentGameObj.transform.SetParent(sceneObj.transform.Find("Scene"), false);
-            DressUpUtil.AddItem(itemId, sceneObj, false, false, parentGameObj, resLayer);
-
-            // if (parentGameObj.transform.childCount > 1)
-            // {
-            //     if (resLayer == 1)
-            //     {
-            //         GameObject.DestroyImmediate(parentGameObj.transform.GetChild(1).gameObject);
-            //     }
-            //     else if (resLayer == 2)
-            //     {
-            //         GameObject.DestroyImmediate(parentGameObj.transform.GetChild(0).gameObject);
-            //     }
-            //     else if (resLayer == 3)
-            //     {
-
-            //     }
-            // }
-
-            SceneController.SetBoxCollider2DToGameObject(parentGameObj.transform.GetChild(0).gameObject);
-        }
-
-        //向Transform添加SpriteRenderer并设置资源
-        public static void SetSpriteRendererToTransform(Transform tf, string resPath)
-        {
-            tf.position = Vector3.zero;
-            SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
-            if (spr == null)
-            {
-                tf.gameObject.AddComponent<SpriteRenderer>();
-                spr = tf.GetComponent<SpriteRenderer>();
-            }
-            DressUpUtil.ChangeAssetReleaser(tf.gameObject, resPath);
-            Sprite sp = GFGAsset.Load<Sprite>(resPath);
-            spr.sprite = sp;
-            spr.size = spr.sprite.bounds.size;//将节点设置为原图大小
-            ItemTypeCfg typeCfg = ItemTypeCfgArray.Instance.GetCfg(ConstDressUpItemType.BEI_JING);
-
-        }
-
-        //向GameObject添加BoxCollider2D
-        public static void SetBoxCollider2DToGameObject(GameObject gameObject)
-        {
-            BoxCollider2D polygonCollider2D = gameObject.GetComponent<BoxCollider2D>();
-            if (polygonCollider2D != null)
-            {
-                GameObject.Destroy(polygonCollider2D);
-            }
-            polygonCollider2D = gameObject.AddComponent<BoxCollider2D>();
-            polygonCollider2D.isTrigger = true;
-
-        }
-
-        //移除指定GameObject的BoxCollider2D
-        public static void DeleteBoxCollider2DFromGameObject(GameObject gameObject)
-        {
-            BoxCollider2D polygonCollider2D = gameObject.GetComponent<BoxCollider2D>();
-            if (polygonCollider2D != null)
-            {
-                GameObject.Destroy(polygonCollider2D);
-            }
-        }
-
-        //传入父物体,返回体碰撞盒大小
-        public static Vector2 GetGameObjectSize(GameObject parentObj)
-        {
-            Vector2 size = Vector2.one;
-            for (int i = 0; i < parentObj.transform.childCount; i++)
-            {
-                GameObject childGameObj = parentObj.transform.GetChild(i).gameObject;
-                BoxCollider2D boxCollider2D = childGameObj.GetComponent<BoxCollider2D>();
-                if (boxCollider2D != null)
-                {
-                    size = GetGameObjectBoundsSize(parentObj);
-                    if (parentObj.name == "Role") boxCollider2D.size = size;
-                    boxCollider2D.offset = -childGameObj.transform.localPosition;
-                    //* childGameObj.transform.localScale
-                    size = size * parentObj.transform.localScale * 100;
-                    return size;
-                }
-            }
-            return Vector2.zero;
-        }
-        private static Vector2 GetGameObjectBoundsSize(GameObject parentObj)
-        {
-            float right = int.MinValue;
-            float left = int.MaxValue;
-            float top = int.MinValue;
-            float bottom = int.MaxValue;
-            for (int i = 0; i < parentObj.transform.childCount; i++)
-            {
-                Transform transform = parentObj.transform.GetChild(i);
-                SpriteRenderer sr = transform.GetComponent<SpriteRenderer>();
-
-                if (sr != null)
-                {
-                    Vector2 pos = transform.localPosition;
-                    Vector2 size = sr.bounds.size / parentObj.transform.localScale.x;
-                    Debug.Log("size:" + size + "     pos:" + pos);
-
-                    right = Math.Max(size.x / 2 + pos.x, right);
-                    left = Math.Min(pos.x - size.x / 2, left);
-                    top = Math.Max(size.y / 2 + pos.y, top);
-                    bottom = Math.Min(pos.y - size.y / 2, bottom);
-                }
-            }
-            Vector2 bounds = new Vector2(right - left, top - bottom);
-            Debug.Log("size:" + bounds);
-
-            return bounds;
-        }
-
-
-        //设置物体中心点
-        public static void SetGameObjectCenter(GameObject parentObj)
-        {
-            Transform parent = parentObj.transform;  // 2.选中技算
-            Vector3 postion = parent.position;
-            Quaternion rotation = parent.rotation;
-            Vector3 scale = parent.localScale;
-            parent.position = Vector3.zero;
-            parent.rotation = Quaternion.Euler(Vector3.zero);
-            parent.localScale = Vector3.one;
-            Vector3 center = Vector3.zero;
-            Renderer[] renders = parent.GetComponentsInChildren<Renderer>();
-            int index = 0;
-            foreach (Transform t in parent)
-            {
-                string[] strs = t.name.Split('_');
-                if (strs.Length > 1 && strs[1] == "eff") continue;//不计算特效大小
-                Renderer render = t.GetComponent<Renderer>();
-                if (render)
-                {
-                    index++;
-                    center += render.bounds.center;
-                }
-            }
-            center /= index;
-            Bounds bounds = new Bounds(center, Vector3.zero);
-            foreach (Transform t in parent)
-            {
-                string[] strs = t.name.Split('_');
-                if (strs.Length > 1 && strs[1] == "eff") continue;
-                Renderer render = t.GetComponent<Renderer>();
-                if (render) bounds.Encapsulate(render.bounds);
-            }
-
-            parent.position = postion;
-            parent.rotation = rotation;
-            parent.localScale = scale;
-
-            foreach (Transform t in parent)
-            {
-                string[] strs = t.parent.name.Split('_');
-                if (strs.Length > 1 && strs[1] == "eff") continue;
-                t.position = t.position - bounds.center;
-            }
-
-            parent.position = bounds.center + parent.position;
-
-        }
-
-
-        public static GameObject GetFirstHitObj(RaycastHit2D[] hit2Ds)
-        {
-            int layer = int.MinValue;
-            GameObject gameObject = null;
-            for (int i = 0; i < hit2Ds.Length; i++)
-            {
-                SpriteRenderer spr = hit2Ds[i].collider.gameObject.GetComponent<SpriteRenderer>();
-
-                if (spr && spr.sortingOrder > layer)
-                {
-                    gameObject = hit2Ds[i].collider.gameObject;
-                    layer = spr.sortingOrder;
-                }
-            }
-            return gameObject;
-        }
-
         public static void AddObjectToView(GameObject _gameObject, GoWrapper _wrapper, GGraph holder, string res, out GameObject gameObject, out GoWrapper wrapper, float scale = 100)
         {
             if (_gameObject != null)

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

@@ -65,7 +65,7 @@ namespace GFGGame
         private void OnClickBtnSave()
         {
             string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
-            PhotographDataManager.Instance.SavePicturoToLocal(bytes, fileName);
+            PhotographUtil.Instance.SavePicturoToLocal(bytes, fileName);
             _ui.m_btnSave.touchable = false;
 
         }

+ 62 - 73
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs

@@ -20,12 +20,12 @@ namespace GFGGame
         private const int MAX_COUNT = 8;
         private const float MaxScale = 2;
         private const float MinScale = 0.1f;
-        private const string BgResPath = "Bg/BgRes";
-        private const string BorderResPath = "Border/BorderRes";
-        private const string NpcResPath = "Scene/Npc/NpcRes";
+        // private const string BgResPath = "Bg/BgRes";
+        // private const string BorderResPath = "Border/BorderRes";
+        // private const string NpcResPath = "Scene/Npc/NpcRes";
         private const string RolePath = "Scene/Role";
-        private const string RoleName = "Role";
-        private const string NpcPath = "Scene/Npc";
+        private const string BodyResName = "BodyRes";
+        // private const string NpcPath = "Scene/Npc";
         private const string NpcName = "Npc";
         private const string BgResName = "BgRes";
         private const string Border = "Border";
@@ -96,7 +96,7 @@ namespace GFGGame
             _ui.m_comSelectBox.m_btnSize.onTouchEnd.Add(OnTouchBtnSizeEnd);
 
             _ui.m_comSelectBox.m_btnFlip.onTouchBegin.Add(OnTouchBtnFlipBegin);
-            _ui.m_comSelectBox.m_btnFlip.onTouchEnd.Add(OnTouchBtnFlipEnd);
+            // _ui.m_comSelectBox.m_btnFlip.onTouchEnd.Add(OnTouchBtnFlipEnd);
 
             _ui.m_comSelectBox.m_btnDelete.onTouchBegin.Add(OnTouchBtnDeleteBegin);
 
@@ -139,7 +139,7 @@ namespace GFGGame
             PhotographSceneManager.Instance.AddBgItem(ItemCfgArray.Instance.GetCfg(MyDressUpHelper.dressUpObj.bgId));
             PhotographSceneManager.Instance.AddBodyItem();
             UpdateScene();
-            PhotographDataManager.Instance.SetLayer(null, "refresh");
+            PhotographUtil.Instance.SetLayer(null, "refresh");
 
             _ui.m_txtCount.text = string.Format("{0}/{1}", PoemGalleryDataManager.Instance.MyWorksCountOfTheme, GlobalCfgArray.globalCfg.maxGalleryWorksCount);
 
@@ -230,9 +230,11 @@ namespace GFGGame
 
         private void AddSceneItem(ItemCfg itemCfg, bool setLayer)
         {
+            bool isOnlyEff = true;
             Vector3 pos = Vector3.zero;
             if (!string.IsNullOrEmpty(itemCfg.resLayer3))
             {
+                isOnlyEff = false;
                 GameObject parentGameObj3 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 3));
                 PhotographSceneManager.Instance.AddSceneItem(parentGameObj3, itemCfg, 3, setLayer);
                 if (setLayer)
@@ -243,23 +245,36 @@ namespace GFGGame
             }
             if (!string.IsNullOrEmpty(itemCfg.resLayer2))
             {
+                isOnlyEff = false;
                 GameObject parentGameObj2 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 2));
                 PhotographSceneManager.Instance.AddSceneItem(parentGameObj2, itemCfg, 2, setLayer);
                 if (setLayer)
                 {
                     parentGameObj2.transform.localPosition = pos == Vector3.zero ? -parentGameObj2.transform.GetChild(0).localPosition : pos;
-                    // parentGameObj2.transform.localPosition = -parentGameObj2.transform.GetChild(0).localPosition;
                     pos = parentGameObj2.transform.localPosition;
                 }
             }
             if (!string.IsNullOrEmpty(itemCfg.resLayer1))
             {
+                isOnlyEff = false;
                 GameObject parentGameObj1 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 1));
                 PhotographSceneManager.Instance.AddSceneItem(parentGameObj1, itemCfg, 1, setLayer);
 
                 if (setLayer)
                 {
                     parentGameObj1.transform.localPosition = pos == Vector3.zero ? -parentGameObj1.transform.GetChild(0).localPosition : pos;
+                    pos = parentGameObj1.transform.localPosition;
+                }
+            }
+
+            if (isOnlyEff && itemCfg.effLayer > 0)
+            {
+                GameObject parentGameObj1 = new GameObject(string.Format("{0}_{1}", itemCfg.id, "eff"));
+                PhotographSceneManager.Instance.AddSceneItem(parentGameObj1, itemCfg, 0, setLayer, true);
+
+                if (setLayer)
+                {
+                    parentGameObj1.transform.localPosition = pos == Vector3.zero ? -parentGameObj1.transform.GetChild(0).localPosition : pos;
                 }
             }
 
@@ -271,7 +286,7 @@ namespace GFGGame
             context.CaptureTouch();
             if (_ui.m_ComSelectRes.target.visible == true) return;//添加道具不监听场景点击
             if (Stage.inst.touchCount > 1 && hitGameObj != null || Stage.inst.touchCount == 1 && context.inputEvent.touchId != 0) return;//两根手指&&两指不是同时按下||一根手指但属于中途换指
-            if (PhotographDataManager.Instance.IsTouchUI(this.viewCom)) return;
+            if (PhotographUtil.Instance.IsTouchUI(this.viewCom)) return;
 
             RaycastHit2D[] hit2Ds = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
             if (hit2Ds.Length > 0)
@@ -279,10 +294,10 @@ namespace GFGGame
 
                 lastPos = Vector2.zero;
 
-                hitGameObj = SceneController.GetFirstHitObj(hit2Ds);
+                hitGameObj = PhotographUtil.Instance.GetFirstHitObj(hit2Ds);
 
                 _ui.m_comSelectBox.m_btnDelete.visible = true;
-                if (hitGameObj.name == "Body")//主角不可删除
+                if (hitGameObj.name == BodyResName)//主角不可删除
                 {
                     _ui.m_comSelectBox.m_btnDelete.visible = false;
                 }
@@ -294,12 +309,12 @@ namespace GFGGame
                     _ui.m_comSelectBox.target.visible = true;
                     if (hitGameObj.name != Border)
                     {
-                        PhotographDataManager.Instance.SetLayer(hitGameObj, "top");
+                        PhotographUtil.Instance.SetLayer(hitGameObj, "top");
                     }
 
                     if (!_equipDistance.ContainsKey(hitGameObj))
                     {
-                        SceneController.SetGameObjectCenter(hitGameObj);
+                        PhotographUtil.Instance.SetGameObjectCenter(hitGameObj);
                     }
                 }
                 memoryHitGameObj = hitGameObj;
@@ -324,8 +339,7 @@ namespace GFGGame
                     }
                 }
                 _ui.m_comSelectBox.target.rotation = rotation;
-                Debug.Log("rotation:" + _ui.m_comSelectBox.target.rotation + "   " + _ui.m_comSelectBox.target.rotationX + "    " + _ui.m_comSelectBox.target.rotationY);
-                _ui.m_comSelectBox.target.size = SceneController.GetGameObjectSize(hitGameObj);
+                _ui.m_comSelectBox.target.size = PhotographUtil.Instance.GetGameObjectBoxSize(hitGameObj);
                 ControllerSelectBoxPos();
 
             }
@@ -335,9 +349,8 @@ namespace GFGGame
         {
             if (hitGameObj == null) return;//未选中任何物体
             if (Stage.inst.touchCount > 1) return; //只监听1根手指
-            if (PhotographDataManager.Instance.IsTouchUI(this.viewCom)) return;
+            if (PhotographUtil.Instance.IsTouchUI(this.viewCom)) return;
 
-            Debug.Log("拖动");
             ControllerObjectPos();
             ControllerSelectBoxPos();
         }
@@ -353,7 +366,7 @@ namespace GFGGame
             hitGameObj.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition - distance);
             if (hitGameObj.name == BgResName)
             {
-                PhotographDataManager.Instance.SetBgPos(hitGameObj, _ui.target.size);
+                PhotographUtil.Instance.SetBgPos(hitGameObj, _ui.target.size);
             }
         }
         //选中框的位置
@@ -387,8 +400,8 @@ namespace GFGGame
             if (memoryHitGameObj == null) return;
             InputEvent inputEvent = (InputEvent)context.data;
 
-            Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
-            Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
+            Vector2 pt1 = this.viewCom.GlobalToLocal(inputEvent.position);
+            Vector2 pt2 = _ui.m_comSelectBox.target.xy;
             Vector2 curPos = pt1 - pt2;
 
             float angle = Vector3.Angle(lastPos, curPos); //求出两向量之间的夹角 
@@ -398,20 +411,20 @@ namespace GFGGame
             ControllerRotate(angle, memoryHitGameObj);
 
             float dist = Vector2.Distance(pt1, pt2);
-
             float ss = dist / lastDistance;
-            Debug.Log("dist:" + dist + "   lastDistance:" + lastDistance + "  ss:" + ss);
-            float newValue = Mathf.Clamp(ss * memoryHitGameObj.transform.localScale.x, 0.1f, 2);
-            ControllerScale(newValue, memoryHitGameObj);
-
-            if (newValue <= 0.1f) return;
-            Debug.Log("ss:" + ss + "    newValue:" + newValue);
-            lastDistance = dist;
-            Debug.Log("newValue:" + newValue);
-
-
+            float curValue = Math.Abs(memoryHitGameObj.transform.localScale.x);
+            float newValue = Mathf.Clamp(ss * curValue, 0.1f, 2);
 
+            ControllerScale(newValue, memoryHitGameObj, Math.Sign(memoryHitGameObj.transform.localScale.x));
 
+            if (newValue <= 0.1f)
+            {
+                lastDistance = Vector2.Distance(_ui.m_comSelectBox.m_btnDelete.xy, _ui.m_comSelectBox.m_btnSize.xy) / 2;
+            }
+            else
+            {
+                lastDistance = dist;
+            }
         }
         private void OnTouchBtnSizeEnd(EventContext context)
         {
@@ -432,7 +445,7 @@ namespace GFGGame
             float newValue = Mathf.Clamp(hitGameObj.transform.localScale.x + gesture.delta, 0.3f, 2);
             Debug.Log("双指缩放:" + newValue);
 
-            ControllerScale(newValue, hitGameObj);
+            ControllerScale(newValue, hitGameObj, Math.Sign(hitGameObj.transform.localScale.x));
         }
         //双指旋转
         private void OnRotate(EventContext context)
@@ -450,11 +463,11 @@ namespace GFGGame
         }
 
 
-        private void ControllerScale(float value, GameObject gameObject)
+        private void ControllerScale(float value, GameObject gameObject, int sign)
         {
             if (value > MaxScale || value < MinScale) return;
-            gameObject.transform.localScale = new Vector3(value, value, 1);
-            Vector2 size = SceneController.GetGameObjectSize(gameObject);
+            gameObject.transform.localScale = new Vector3(value * sign, value, value);
+            Vector2 size = PhotographUtil.Instance.GetGameObjectBoxSize(gameObject);
             _ui.m_comSelectBox.target.size = size;
         }
         private void ControllerRotate(float value, GameObject gameObject)
@@ -472,21 +485,10 @@ namespace GFGGame
         private void OnTouchBtnFlipBegin()//翻转
         {
             Transform transform = memoryHitGameObj.transform;
-            if (memoryHitGameObj.name == RoleName)
-            {
-                //transform.Rotate(Vector3.up, 180, Space.Self);
-                var newValue = -transform.localScale.x;
-                transform.localScale = new Vector3(newValue, transform.localScale.y, transform.localScale.z);
-                return;
-            }
-            for (int i = 0; i < transform.childCount; i++)
-            {
-                //transform.GetChild(i).Rotate(Vector3.up, 180, Space.Self);
-            }
-        }
-        private void OnTouchBtnFlipEnd()
-        {
+            var value = Math.Abs(transform.localScale.x);
+            // transform.localScale = new Vector3(-value, Math.Abs(value), 1);
 
+            ControllerScale(value, memoryHitGameObj, -Math.Sign(transform.localScale.x));
         }
 
         private void OnTouchBtnDeleteBegin()//删除
@@ -495,17 +497,14 @@ namespace GFGGame
             {
                 return;
             }
-            else if (memoryHitGameObj.transform.name == Border)
+            else if (memoryHitGameObj.transform.name == Border || memoryHitGameObj.transform.name == NpcName)
             {
-                ChangeItem(ConstItemID.BORDERID);
-            }
-            else if (memoryHitGameObj.transform.name == NpcName)
-            {
-                SpriteRenderer spriteRenderer = memoryHitGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
-                if (spriteRenderer != null)
-                {
-                    GameObject.Destroy(spriteRenderer);
-                }
+                memoryHitGameObj.transform.localPosition = Vector3.zero;
+                memoryHitGameObj.transform.localRotation = Quaternion.Euler(Vector3.zero);
+                memoryHitGameObj.transform.localScale = Vector3.one;
+                GameObject gameObject = memoryHitGameObj.transform.GetChild(0).gameObject;
+                PhotographSceneManager.Instance.DeleteSpriteRendererFromGameObject(gameObject);
+                PhotographSceneManager.Instance.DeleteBoxCollider2DFromGameObject(gameObject);
             }
             else
             {
@@ -533,11 +532,11 @@ namespace GFGGame
         private void OnClickBtnUp()
         {
 
-            PhotographDataManager.Instance.SetLayer(memoryHitGameObj, "up");
+            PhotographUtil.Instance.SetLayer(memoryHitGameObj, "up");
         }
         private void OnClickBtnDown()
         {
-            PhotographDataManager.Instance.SetLayer(memoryHitGameObj, "down");
+            PhotographUtil.Instance.SetLayer(memoryHitGameObj, "down");
         }
 
 
@@ -583,20 +582,10 @@ namespace GFGGame
                     bool pushResult = await PictureStorageHelper.PushToHWCloud(rsp[0].ToString(), bytes);
                     if (!pushResult) return;
 
-                    bool result = await PoemGallerySProxy.ReqNoticeGalleryWorksUploaded((long)(rsp[1]));
+                    bool result = await PoemGallerySProxy.ReqNoticeGalleryWorksUploaded((long)(rsp[1]), tex);
                     if (result)
                     {
-                        PoemGalleryData galleryData = new PoemGalleryData();
-                        galleryData.WorkId = (long)rsp[1];
-                        galleryData.Rank = 0;
-                        galleryData.AuthorId = RoleDataManager.roleId;
-                        galleryData.AuthorName = RoleDataManager.roleName;
-                        galleryData.CreateTime = TimeHelper.ServerNow();
-                        galleryData.ThemeOrder = PoemGalleryDataManager.Instance.ThemeOrder;
-                        galleryData.ThemeId = PoemGalleryDataManager.Instance.ThemeId;
-                        galleryData.Ntexture = new NTexture(tex);
-                        PoemGalleryDataManager.Instance.UpdateGalleryData(galleryData);
-                        PoemGalleryDataManager.Instance.MySelfDatas.Insert(0, galleryData.WorkId);
+
                         _ui.m_txtCount.text = string.Format("{0}/{1}", PoemGalleryDataManager.Instance.MyWorksCountOfTheme, GlobalCfgArray.globalCfg.maxGalleryWorksCount);
                         ViewManager.Hide<ModalStatusView>();
                         OnClickBtnBack();

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Poem/PoemPhotoShareView.cs

@@ -98,7 +98,7 @@ namespace GFGGame
             byte[] bytes = _curPhotoData.Bytes;
             string fileName = "wsj" + TimeHelper.ServerNowSecs + ".jpg";
 
-            PhotographDataManager.Instance.SavePicturoToLocal(bytes, fileName);
+            PhotographUtil.Instance.SavePicturoToLocal(bytes, fileName);
         }
         private void OnBtnShareClick()
         {

+ 52 - 0
GameClient/Assets/ResIn/Prefab/ScenePhotograph.prefab

@@ -331,6 +331,7 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 2394733109435034269}
+  - component: {fileID: 3751790836481841671}
   m_Layer: 0
   m_Name: BorderRes
   m_TagString: Untagged
@@ -352,6 +353,57 @@ Transform:
   m_Father: {fileID: 7620177300938337219}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &3751790836481841671
+SpriteRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 9004247584929300591}
+  m_Enabled: 1
+  m_CastShadows: 0
+  m_ReceiveShadows: 0
+  m_DynamicOccludee: 1
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 0
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  m_StaticBatchInfo:
+    firstSubMesh: 0
+    subMeshCount: 0
+  m_StaticBatchRoot: {fileID: 0}
+  m_ProbeAnchor: {fileID: 0}
+  m_LightProbeVolumeOverride: {fileID: 0}
+  m_ScaleInLightmap: 1
+  m_ReceiveGI: 1
+  m_PreserveUVs: 0
+  m_IgnoreNormalsForChartDetection: 0
+  m_ImportantGI: 0
+  m_StitchLightmapSeams: 1
+  m_SelectedEditorRenderState: 0
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 0
+  m_Sprite: {fileID: 0}
+  m_Color: {r: 1, g: 1, b: 1, a: 1}
+  m_FlipX: 0
+  m_FlipY: 0
+  m_DrawMode: 0
+  m_Size: {x: 1, y: 1}
+  m_AdaptiveModeThreshold: 0.5
+  m_SpriteTileMode: 0
+  m_WasSpriteAssigned: 0
+  m_MaskInteraction: 0
+  m_SpriteSortPoint: 0
 --- !u!1001 &906528762196001978
 PrefabInstance:
   m_ObjectHideFlags: 0