| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.IO;
 
- using ET;
 
- using FairyGUI;
 
- using UI.DressUp;
 
- using UnityEngine;
 
- namespace GFGGame
 
- {
 
-     public enum EnumPhotographType
 
-     {
 
-         BG,
 
-         NPC,
 
-         SCENE,
 
-         BORDER,
 
-         EFFECT
 
-     }
 
-     public class PhotographDataManager : SingletonBase<PhotographDataManager>
 
-     {
 
-         public List<GameObject> itemGameObjs = new List<GameObject>();
 
-         public List<int> _equipRoleData = new List<int>();//当前穿戴的角色数据
 
-         public Dictionary<int, List<int>> _equipSceneData = new Dictionary<int, List<int>>();//当前穿戴的场景数据
 
-         public List<int> listBgData = new List<int>();
 
-         public List<int> listNpcData = new List<int>();
 
-         public List<int> listSceneData = new List<int>();
 
-         public List<int> listBorderData = new List<int>();
 
-         public List<int> listEffectData = new List<int>();
 
-         public void Clear()
 
-         {
 
-             listBgData.Clear();
 
-             listNpcData.Clear();
 
-             listSceneData.Clear();
 
-             listBorderData.Clear();
 
-             listEffectData.Clear();
 
-         }
 
-         public void Add(int itemID)
 
-         {
 
-             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
 
-             if (itemCfg.itemType == ConstItemType.DRESS_UP)
 
-             {
 
-                 if (itemCfg.subType == ConstDressUpItemType.BEI_JING)
 
-                 {
 
-                     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)
 
-                 {
 
-                     if (listSceneData.IndexOf(itemID) < 0) listSceneData.Add(itemID);
 
-                 }
 
-             }
 
-             else if (itemCfg.itemType == ConstItemType.PHOTOGRAPH)
 
-             {
 
-                 if (itemCfg.subType == ConstItemSubType.NPC)
 
-                 {
 
-                     if (listNpcData.IndexOf(itemID) < 0) listNpcData.Add(itemID);
 
-                 }
 
-                 else if (itemCfg.subType == ConstItemSubType.BOREDR)
 
-                 {
 
-                     if (listBorderData.IndexOf(itemID) < 0) listBorderData.Add(itemID);
 
-                 }
 
-                 else if (itemCfg.subType == ConstItemSubType.EFFECT)
 
-                 {
 
-                     if (listEffectData.IndexOf(itemID) < 0) listEffectData.Add(itemID);
 
-                 }
 
-             }
 
-         }
 
-         //将穿戴数据分类
 
-         public void ClassifyEquipData()
 
-         {
 
-             _equipRoleData.Clear();
 
-             _equipSceneData.Clear();
 
-             for (int i = 0; i < EquipDataCache.cacher.equipDatas.Count; i++)
 
-             {
 
-                 ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(EquipDataCache.cacher.equipDatas[i]);
 
-                 if (itemCfg.subType == ConstDressUpItemType.QIAN_JING || itemCfg.subType == ConstDressUpItemType.BEI_SHI || itemCfg.subType == ConstDressUpItemType.HUAN_JING || itemCfg.subType == ConstDressUpItemType.FEN_WEI)
 
-                 {
 
-                     PhotographDataManager.Instance.AddEquipItem(_equipSceneData, itemCfg.id, out _equipSceneData);
 
-                 }
 
-                 else
 
-                 {
 
-                     _equipRoleData.Add(EquipDataCache.cacher.equipDatas[i]);
 
-                 }
 
-             }
 
-         }
 
-         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)
 
-         {
 
-             List<int> _listData = null;
 
-             switch (index)
 
-             {
 
-                 case EnumPhotographType.BG:
 
-                     _listData = PhotographDataManager.Instance.listBgData;
 
-                     break;
 
-                 case EnumPhotographType.NPC:
 
-                     _listData = PhotographDataManager.Instance.listNpcData;
 
-                     break;
 
-                 case EnumPhotographType.SCENE:
 
-                     _listData = PhotographDataManager.Instance.listSceneData;
 
-                     break;
 
-                 case EnumPhotographType.BORDER:
 
-                     _listData = PhotographDataManager.Instance.listBorderData;
 
-                     if (_listData.IndexOf(ConstItemID.BORDERID) < 0)
 
-                     {
 
-                         _listData.Insert(0, ConstItemID.BORDERID);
 
-                     }
 
-                     break;
 
-                 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;
 
-         }
 
-         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;
 
-         }
 
-         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
 
-         }
 
-     }
 
- }
 
 
  |