PhotographView.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. using ET;
  2. using FairyGUI;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Drawing;
  7. using UI.DressUp;
  8. using UnityEditor;
  9. using UnityEngine;
  10. using UnityEngine.EventSystems;
  11. namespace GFGGame
  12. {
  13. public class PhotographView : BaseView
  14. {
  15. private UI_PhotographUI _ui;
  16. private GameObject _scenePrefab;
  17. private GameObject _sceneObject;
  18. private const int MAX_COUNT = 8;
  19. private const float MaxScale = 2;
  20. private const float MinScale = 0.1f;
  21. private const string BgResPath = "Bg/BgRes";
  22. private const string BorderResPath = "Border/BorderRes";
  23. private const string NpcResPath = "Scene/Npc/NpcRes";
  24. private const string RolePath = "Scene/Role";
  25. private const string RoleName = "Role";
  26. private const string NpcPath = "Scene/Npc";
  27. private const string NpcName = "Npc";
  28. private const string BgResName = "BgRes";
  29. private List<int> _listData = null;//当前选择的资源数据
  30. private List<GameObject> _itemGameObjs;// = new List<GameObject>();
  31. public Dictionary<int, List<int>> _equipSceneData = new Dictionary<int, List<int>>();//当前穿戴的场景数据
  32. private Dictionary<GameObject, float> _equipDistance = new Dictionary<GameObject, float>();
  33. private GameObject hitGameObj;//当前选中的物体(单指拖动,双指缩放旋转)
  34. private GameObject memoryHitGameObj;//当前选中的物体(单指缩放旋转)
  35. private Vector3 distance = Vector3.zero;//点击位置和点击物体原点的距离,用于
  36. private Vector2 lastPos = Vector2.zero;//上一次移动后从物体中心到鼠标位置的方向
  37. private float lastDistance = 0;//上一次移动后从物体中心到鼠标位置的方向
  38. // private float _startDistance;//从物体中心到缩放按钮的距离
  39. private SwipeGesture swipeGesture;
  40. private PinchGesture pinchGesture;
  41. private RotationGesture rotationGesture;
  42. // private int maxLayer = int.MinValue;//最上层的层级数
  43. protected override void OnInit()
  44. {
  45. base.OnInit();
  46. packageName = UI_PhotographUI.PACKAGE_NAME;
  47. _ui = UI_PhotographUI.Create();
  48. viewCom = _ui.target;
  49. isfullScreen = true;
  50. _ui.m_btnBg.onClick.Add(OnClickBtnBg);
  51. _ui.m_loaGuide.onClick.Add(OnClickLoaGuide);
  52. _ui.m_loaGuide1.onClick.Add(OnClickLoaGuide1);
  53. _ui.m_btnChoose.onClick.Add(SetUIView);
  54. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  55. _ui.m_btnPhotograph.onClick.Add(OnClickBtnPhotograph);
  56. _ui.m_ComSelectRes.m_list.itemRenderer = RenderListItem;
  57. _ui.m_ComSelectRes.m_list.onClickItem.Add(OnListItemClick);
  58. _ui.m_ComSelectRes.m_comBtnTab.m_c1.onChanged.Add(OnContorllerChanged);
  59. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("ScenePhotograph"));
  60. _ui.target.onTouchBegin.Add(OnTouchUIBegin);
  61. _ui.target.onTouchMove.Add(OnTouchUIMove);
  62. _ui.target.onTouchEnd.Add(OnTouchUIEnd);
  63. _ui.m_comSelectBox.m_btnSize.onTouchBegin.Add(OnTouchBtnSizeBegin);
  64. _ui.m_comSelectBox.m_btnSize.onTouchMove.Add(OnTouchBtnSizeMove);
  65. _ui.m_comSelectBox.m_btnSize.onTouchEnd.Add(OnTouchBtnSizeEnd);
  66. _ui.m_comSelectBox.m_btnFlip.onTouchBegin.Add(OnTouchBtnFlipBegin);
  67. _ui.m_comSelectBox.m_btnFlip.onTouchEnd.Add(OnTouchBtnFlipEnd);
  68. _ui.m_comSelectBox.m_btnDelete.onTouchBegin.Add(OnTouchBtnDeleteBegin);
  69. _ui.m_btnUp.onClick.Add(OnClickBtnUp);
  70. _ui.m_btnDown.onClick.Add(OnClickBtnDown);
  71. }
  72. protected override void OnShown()
  73. {
  74. base.OnShown();
  75. Input.multiTouchEnabled = true;
  76. PhotographDataManager.Instance.ClassifyEquipData();
  77. _equipSceneData = PhotographDataManager.Instance._equipSceneData;
  78. PhotographDataManager.Instance.itemGameObjs.Clear();
  79. _itemGameObjs = PhotographDataManager.Instance.itemGameObjs;
  80. if (_sceneObject == null)
  81. {
  82. _sceneObject = GameObject.Instantiate(_scenePrefab);
  83. EquipDataCache.cacher.setSceneObj(_sceneObject);
  84. PhotographSceneManager.Instance.sceneObject = _sceneObject;
  85. }
  86. pinchGesture = new PinchGesture(_ui.target);
  87. pinchGesture.onAction.Add(OnPinch);
  88. rotationGesture = new RotationGesture(_ui.target);
  89. rotationGesture.onAction.Add(OnRotate);
  90. _ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex = 0;
  91. RefreshList(EnumPhotographType.BG);
  92. SetUIView();
  93. PhotographSceneManager.Instance.AddBgItem(ItemCfgArray.Instance.GetCfg(EquipDataCache.cacher.bgId));
  94. PhotographSceneManager.Instance.AddBodyItem();
  95. UpdateScene();
  96. PhotographDataManager.Instance.SetLayer(null, "refresh");
  97. if (GuideDataManager.IsGuideFinish(ConstGuideId.PHOTOGRAPH) > 0)
  98. {
  99. _ui.m_loaGuide.enabled = false;
  100. _ui.m_loaGuide1.enabled = false;
  101. }
  102. else
  103. {
  104. _ui.m_loaGuide.enabled = true;
  105. _ui.m_loaGuide1.enabled = false;
  106. }
  107. Timers.inst.AddUpdate(CheckGuide);
  108. }
  109. /************************************************************UI界面*********************************************************/
  110. private void OnContorllerChanged(EventContext context)
  111. {
  112. int index = _ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
  113. RefreshList((EnumPhotographType)index);
  114. }
  115. private void RefreshList(EnumPhotographType index)
  116. {
  117. _ui.m_ComSelectRes.m_list.numItems = 0;
  118. _listData = PhotographDataManager.Instance.GetListData(index);
  119. _ui.m_ComSelectRes.m_list.numItems = _listData.Count;
  120. if (index == EnumPhotographType.BORDER || index == EnumPhotographType.EFFECT)
  121. {
  122. _ui.m_ComSelectRes.m_list.selectedIndex = 0;
  123. }
  124. }
  125. private void RenderListItem(int index, GObject obj)
  126. {
  127. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_listData[index]);
  128. string resPath = ResPathUtil.GetIconPath(itemCfg);
  129. UI_ListItem item = UI_ListItem.Proxy(obj);
  130. item.target.data = _listData[index];
  131. item.m_loaIcon.url = resPath;
  132. item.m_txtName.text = itemCfg.name;
  133. UI_ListItem.ProxyEnd();
  134. }
  135. private void OnListItemClick(EventContext context)
  136. {
  137. if (_itemGameObjs.Count >= MAX_COUNT)
  138. {
  139. PromptController.Instance.ShowFloatTextPrompt("最多穿戴" + MAX_COUNT + "件物品");
  140. return;
  141. }
  142. int itemID = (int)((context.data as GObject).data);
  143. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
  144. EnumPhotographType type = (EnumPhotographType)_ui.m_ComSelectRes.m_comBtnTab.m_c1.selectedIndex;
  145. switch (type)
  146. {
  147. case EnumPhotographType.BG:
  148. PhotographSceneManager.Instance.AddBgItem(itemCfg);
  149. break;
  150. case EnumPhotographType.BORDER:
  151. PhotographSceneManager.Instance.AddBorderItem(itemCfg);
  152. break;
  153. case EnumPhotographType.NPC:
  154. PhotographSceneManager.Instance.AddNpcItem(itemCfg);
  155. break;
  156. case EnumPhotographType.SCENE:
  157. AddSceneItem(itemCfg, true);
  158. break;
  159. case EnumPhotographType.EFFECT:
  160. break;
  161. }
  162. }
  163. //添加初始场景道具
  164. private void UpdateScene()
  165. {
  166. ICollection keys = _equipSceneData.Keys;
  167. foreach (int key in keys)
  168. {
  169. for (int i = 0; i < _equipSceneData[key].Count; i++)
  170. {
  171. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
  172. AddSceneItem(itemCfg, false);
  173. }
  174. }
  175. }
  176. private void AddSceneItem(ItemCfg itemCfg, bool setLayer)
  177. {
  178. Vector3 pos = Vector3.zero;
  179. if (!string.IsNullOrEmpty(itemCfg.resLayer3))
  180. {
  181. GameObject parentGameObj3 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 3));
  182. PhotographSceneManager.Instance.AddSceneItem(parentGameObj3, itemCfg, 3, setLayer);
  183. if (setLayer)
  184. {
  185. parentGameObj3.transform.localPosition = -parentGameObj3.transform.GetChild(0).localPosition;
  186. pos = parentGameObj3.transform.localPosition;
  187. }
  188. }
  189. if (!string.IsNullOrEmpty(itemCfg.resLayer2))
  190. {
  191. GameObject parentGameObj2 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 2));
  192. PhotographSceneManager.Instance.AddSceneItem(parentGameObj2, itemCfg, 2, setLayer);
  193. if (setLayer)
  194. {
  195. parentGameObj2.transform.localPosition = pos == Vector3.zero ? -parentGameObj2.transform.GetChild(0).localPosition : pos;
  196. // parentGameObj2.transform.localPosition = -parentGameObj2.transform.GetChild(0).localPosition;
  197. pos = parentGameObj2.transform.localPosition;
  198. }
  199. }
  200. if (!string.IsNullOrEmpty(itemCfg.resLayer1))
  201. {
  202. GameObject parentGameObj1 = new GameObject(string.Format("{0}_{1}", itemCfg.id, 1));
  203. PhotographSceneManager.Instance.AddSceneItem(parentGameObj1, itemCfg, 1, setLayer);
  204. if (setLayer)
  205. {
  206. // if (!string.IsNullOrEmpty(itemCfg.resLayer2))
  207. // {
  208. // parentGameObj1.transform.localPosition = pos;
  209. // }
  210. // else
  211. // {
  212. parentGameObj1.transform.localPosition = pos == Vector3.zero ? -parentGameObj1.transform.GetChild(0).localPosition : pos;
  213. // }
  214. }
  215. }
  216. }
  217. /************************************************************场景*********************************************************/
  218. private void OnTouchUIBegin(EventContext context)
  219. {
  220. context.CaptureTouch();
  221. if (_ui.m_ComSelectRes.target.visible == true) return;//添加道具不监听场景点击
  222. if (Stage.inst.touchCount > 1 && hitGameObj != null || Stage.inst.touchCount == 1 && context.inputEvent.touchId != 0) return;//两根手指&&两指不是同时按下||一根手指但属于中途换指
  223. if (PhotographDataManager.Instance.IsTouchUI(this.viewCom)) return;
  224. RaycastHit2D[] hit2Ds = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
  225. if (hit2Ds.Length > 0)
  226. {
  227. lastPos = Vector2.zero;
  228. hitGameObj = SceneController.GetFirstHitObj(hit2Ds);
  229. _ui.m_comSelectBox.m_btnDelete.visible = true;
  230. if (hitGameObj.name == "Body")//主角不可删除
  231. {
  232. _ui.m_comSelectBox.m_btnDelete.visible = false;
  233. }
  234. _ui.m_comSelectBox.target.visible = false;
  235. if (hitGameObj.name != BgResName)//背景不可改动层级
  236. {
  237. hitGameObj = hitGameObj.transform.parent.gameObject;
  238. _ui.m_comSelectBox.target.visible = true;
  239. PhotographDataManager.Instance.SetLayer(hitGameObj, "top");
  240. if (!_equipDistance.ContainsKey(hitGameObj))
  241. {
  242. SceneController.SetGameObjectCenter(hitGameObj);
  243. }
  244. }
  245. memoryHitGameObj = hitGameObj;
  246. distance = Input.mousePosition - Camera.main.WorldToScreenPoint(hitGameObj.transform.position);
  247. Vector3 localEulerAngles = hitGameObj.transform.localEulerAngles;
  248. float rotation = 0;
  249. if (localEulerAngles.y == 0)
  250. {
  251. rotation = -hitGameObj.transform.localEulerAngles.z;
  252. }
  253. else
  254. {
  255. if (hitGameObj.transform.localEulerAngles.z > 180)
  256. {
  257. rotation = hitGameObj.transform.localEulerAngles.z - 360;
  258. }
  259. else
  260. {
  261. rotation = hitGameObj.transform.localEulerAngles.z;
  262. }
  263. }
  264. _ui.m_comSelectBox.target.rotation = rotation;
  265. Debug.Log("rotation:" + _ui.m_comSelectBox.target.rotation + " " + _ui.m_comSelectBox.target.rotationX + " " + _ui.m_comSelectBox.target.rotationY);
  266. _ui.m_comSelectBox.target.size = SceneController.GetGameObjectSize(hitGameObj);
  267. ControllerSelectBoxPos();
  268. }
  269. }
  270. private void OnTouchUIMove(EventContext context)
  271. {
  272. if (hitGameObj == null) return;//未选中任何物体
  273. if (Stage.inst.touchCount > 1) return; //只监听1根手指
  274. if (PhotographDataManager.Instance.IsTouchUI(this.viewCom)) return;
  275. Debug.Log("拖动");
  276. ControllerObjectPos();
  277. ControllerSelectBoxPos();
  278. }
  279. private void OnTouchUIEnd(EventContext context)
  280. {
  281. hitGameObj = null;
  282. }
  283. //选中物体的位置
  284. private void ControllerObjectPos()
  285. {
  286. hitGameObj.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition - distance);
  287. if (hitGameObj.name == BgResName)
  288. {
  289. PhotographDataManager.Instance.SetBgPos(hitGameObj, _ui.target.size);
  290. }
  291. }
  292. //选中框的位置
  293. private void ControllerSelectBoxPos()
  294. {
  295. Vector2 objScreenPos = Camera.main.WorldToScreenPoint(hitGameObj.transform.position);
  296. Vector2 localPos = this.viewCom.GlobalToLocal(new Vector2(objScreenPos.x, (Screen.height - objScreenPos.y)));
  297. _ui.m_comSelectBox.target.position = localPos;
  298. }
  299. private void OnTouchBtnSizeBegin(EventContext context)
  300. {
  301. InputEvent inputEvent = (InputEvent)context.data;
  302. Vector2 pt0 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
  303. Vector2 screenPos = this.viewCom.GlobalToLocal(_ui.m_comSelectBox.m_btnSize.LocalToGlobal(Vector2.zero));
  304. Vector2 pt1 = new Vector2(screenPos.x, screenPos.y);
  305. Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
  306. lastDistance = Vector2.Distance(pt0, pt2);
  307. if (!_equipDistance.ContainsKey(memoryHitGameObj))
  308. {
  309. float distance = Vector2.Distance(pt1, pt2) / memoryHitGameObj.transform.localScale.x;
  310. Debug.Log("distance:" + distance + " pt1:" + pt1 + " pt2:" + pt2);
  311. _equipDistance.Add(memoryHitGameObj, distance);
  312. }
  313. }
  314. private void OnTouchBtnSizeMove(EventContext context)
  315. {
  316. if (memoryHitGameObj == null) return;
  317. InputEvent inputEvent = (InputEvent)context.data;
  318. Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
  319. Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
  320. Vector2 curPos = pt1 - pt2;
  321. float angle = Vector3.Angle(lastPos, curPos); //求出两向量之间的夹角
  322. Vector3 normal = Vector3.Cross(lastPos, curPos);//叉乘求出法线向量
  323. angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.forward)); //Mathf.Sign()求符号,Vector3.Dot()求方向,求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向
  324. lastPos = curPos;
  325. ControllerRotate(angle, memoryHitGameObj);
  326. float dist = Vector2.Distance(pt1, pt2);
  327. float ss = dist / lastDistance;
  328. Debug.Log("dist:" + dist + " lastDistance:" + lastDistance + " ss:" + ss);
  329. float newValue = Mathf.Clamp(ss * memoryHitGameObj.transform.localScale.x, 0.1f, 2);
  330. ControllerScale(newValue, memoryHitGameObj);
  331. if (newValue <= 0.1f) return;
  332. Debug.Log("ss:" + ss + " newValue:" + newValue);
  333. lastDistance = dist;
  334. Debug.Log("newValue:" + newValue);
  335. }
  336. private void OnTouchBtnSizeEnd(EventContext context)
  337. {
  338. lastPos = Vector2.zero;
  339. }
  340. //双指缩放
  341. private void OnPinch(EventContext context)
  342. {
  343. if (hitGameObj == null) return;
  344. if (hitGameObj.name == BgResName) return;//背景不可以缩放、旋转
  345. GTween.Kill(hitGameObj);
  346. PinchGesture gesture = (PinchGesture)context.sender;
  347. float newValue = Mathf.Clamp(hitGameObj.transform.localScale.x + gesture.delta, 0.3f, 2);
  348. Debug.Log("双指缩放:" + newValue);
  349. ControllerScale(newValue, hitGameObj);
  350. }
  351. //双指旋转
  352. private void OnRotate(EventContext context)
  353. {
  354. Debug.Log("双指旋转hitGameObj:" + hitGameObj);
  355. if (hitGameObj == null) return;
  356. Debug.Log("双指旋转name:" + hitGameObj.name);
  357. if (hitGameObj.name == BgResName) return;//背景不可以缩放、旋转
  358. // isTwoTouchPoint = true;
  359. GTween.Kill(hitGameObj.transform);
  360. RotationGesture gesture = (RotationGesture)context.sender;
  361. Debug.Log("双指旋转:" + gesture.delta);
  362. ControllerRotate(gesture.delta, hitGameObj);
  363. }
  364. private void ControllerScale(float value, GameObject gameObject)
  365. {
  366. if (value > MaxScale || value < MinScale) return;
  367. gameObject.transform.localScale = new Vector3(value, value, 1);
  368. Vector2 size = SceneController.GetGameObjectSize(gameObject);
  369. _ui.m_comSelectBox.target.size = size;
  370. }
  371. private void ControllerRotate(float value, GameObject gameObject)
  372. {
  373. gameObject.transform.Rotate(Vector3.forward, -value, Space.World);
  374. _ui.m_comSelectBox.target.rotation += value;
  375. }
  376. private void OnClickBtnBg()
  377. {
  378. _ui.m_ComSelectRes.target.visible = false;
  379. }
  380. private void OnClickLoaGuide()
  381. {
  382. _ui.m_loaGuide1.enabled = true;
  383. _ui.m_loaGuide.enabled = false;
  384. _ui.m_ComSelectRes.target.visible = false;
  385. }
  386. private void OnClickLoaGuide1()
  387. {
  388. _ui.m_loaGuide1.enabled = false;
  389. _ui.m_ComSelectRes.target.visible = false;
  390. }
  391. private void OnTouchBtnFlipBegin()//翻转
  392. {
  393. Transform transform = memoryHitGameObj.transform;
  394. if (memoryHitGameObj.name == RoleName)
  395. {
  396. transform.Rotate(Vector3.up, 180, Space.Self);
  397. return;
  398. }
  399. for (int i = 0; i < transform.childCount; i++)
  400. {
  401. transform.GetChild(i).Rotate(Vector3.up, 180, Space.Self);
  402. }
  403. }
  404. private void OnTouchBtnFlipEnd()
  405. {
  406. }
  407. private void OnTouchBtnDeleteBegin()//删除
  408. {
  409. if (memoryHitGameObj.transform.name == RolePath)
  410. {
  411. return;
  412. }
  413. else if (memoryHitGameObj.transform.name == NpcName)
  414. {
  415. SpriteRenderer spriteRenderer = memoryHitGameObj.transform.GetChild(0).GetComponent<SpriteRenderer>();
  416. if (spriteRenderer != null)
  417. {
  418. GameObject.Destroy(spriteRenderer);
  419. }
  420. }
  421. else
  422. {
  423. GameObject.DestroyImmediate(memoryHitGameObj);
  424. }
  425. _itemGameObjs.Remove(memoryHitGameObj);
  426. _ui.m_comSelectBox.target.visible = false;
  427. }
  428. private void SetUIView()
  429. {
  430. _ui.m_ComSelectRes.target.visible = true;
  431. _ui.m_comSelectBox.target.visible = false;
  432. hitGameObj = null;
  433. memoryHitGameObj = null;
  434. }
  435. private void OnClickBtnUp()
  436. {
  437. PhotographDataManager.Instance.SetLayer(memoryHitGameObj, "up");
  438. }
  439. private void OnClickBtnDown()
  440. {
  441. PhotographDataManager.Instance.SetLayer(memoryHitGameObj, "down");
  442. }
  443. private void OnClickBtnPhotograph()
  444. {
  445. _ui.target.visible = false;
  446. Timers.inst.StartCoroutine(ScreenShotTex());// ();
  447. }
  448. private IEnumerator ScreenShotTex()
  449. {
  450. _ui.target.visible = false;
  451. yield return new WaitForEndOfFrame();
  452. Rect rect = new Rect(0, 0, UnityEngine.Screen.width, UnityEngine.Screen.height);
  453. Texture2D tex = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.ARGB32, false);//新建一个Texture2D对象
  454. tex.ReadPixels(rect, 0, 0);//读取像素,屏幕左下角为0点
  455. tex.Apply();//保存像素信息
  456. ViewManager.Show<PhotographSaveView>(tex);
  457. _ui.target.visible = true;
  458. LogServerHelper.SendNodeLog((int)PlayParticipationEnum.PAI_ZHAO, 2);
  459. }
  460. private void OnClickBtnBack()
  461. {
  462. this.Hide();
  463. // ViewManager.Show(ViewName.DRESS_UP_VIEW);
  464. EventAgent.DispatchEvent(ConstMessage.CLOSE_PHOTOGRAPHVIEW);
  465. }
  466. protected override void OnHide()
  467. {
  468. base.OnHide();
  469. if (_sceneObject != null)
  470. {
  471. GameObject.Destroy(_sceneObject);
  472. _sceneObject = null;
  473. }
  474. _equipSceneData.Clear();
  475. hitGameObj = null;
  476. memoryHitGameObj = null;
  477. pinchGesture.onAction.Remove(OnPinch);
  478. rotationGesture.onAction.Remove(OnRotate);
  479. pinchGesture = null;
  480. rotationGesture = null;
  481. Timers.inst.Remove(CheckGuide);
  482. }
  483. public override void Dispose()
  484. {
  485. if (_sceneObject != null)
  486. {
  487. GameObject.Destroy(_sceneObject);
  488. _sceneObject = null;
  489. }
  490. if (_scenePrefab != null)
  491. {
  492. GFGAsset.Release(ResPathUtil.GetPrefabPath("ScenePhotograph"));
  493. _scenePrefab = null;
  494. }
  495. base.Dispose();
  496. }
  497. private void CheckGuide(object param)
  498. {
  499. if (GuideDataManager.IsGuideFinish(ConstGuideId.PHOTOGRAPH) <= 0)
  500. {
  501. UpdateToCheckGuide(null);
  502. GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.PHOTOGRAPH);
  503. if (GuideDataManager.IsGuideIndexFinish(cfg.id, 3))
  504. {
  505. GuideController.TryCompleteGuide(ConstGuideId.PHOTOGRAPH, 3);
  506. }
  507. }
  508. else
  509. {
  510. Timers.inst.Remove(CheckGuide);
  511. }
  512. }
  513. protected override void UpdateToCheckGuide(object param)
  514. {
  515. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  516. GuideController.TryGuide(_ui.m_ComSelectRes.m_comBtnTab.m_btn0, ConstGuideId.PHOTOGRAPH, 2, "在这里可以选择已获得的背景、道具等,也可以放大缩小物品,增加画面丰富度");
  517. GuideController.TryGuide(_ui.m_btnPhotograph, ConstGuideId.PHOTOGRAPH, 3, "来记录下这一刻吧~~");
  518. GuideController.TryCompleteGuide(ConstGuideId.PHOTOGRAPH, 3);
  519. }
  520. }
  521. }