PoemPhotoDataManager.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using ET;
  5. using FairyGUI;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class PoemPhotoDataManager : SingletonBase<PoemPhotoDataManager>
  10. {
  11. /// <summary>
  12. /// 个人相册
  13. /// </summary>
  14. /// <typeparam name="PoemPhotoData"></typeparam>
  15. /// <returns></returns>
  16. public List<PoemPhotoData> PersonalPhotoInfos = new List<PoemPhotoData>();
  17. /// <summary>
  18. /// 万水千山相册
  19. /// </summary>
  20. /// <typeparam name="PoemPhotoData"></typeparam>
  21. /// <returns></returns>
  22. public List<PoemPhotoData> WsqsPhotoInfos = new List<PoemPhotoData>();
  23. public void Clear()
  24. {
  25. PersonalPhotoInfos.Clear();
  26. WsqsPhotoInfos.Clear();
  27. }
  28. public void Add(PoemPhotoData photoData, int sourceType)
  29. {
  30. List<PoemPhotoData> poemPhotoDatas = null;
  31. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  32. {
  33. poemPhotoDatas = PersonalPhotoInfos;
  34. }
  35. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  36. {
  37. poemPhotoDatas = WsqsPhotoInfos;
  38. }
  39. else if (sourceType == 2)
  40. {
  41. poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos;
  42. }
  43. poemPhotoDatas.Add(photoData);
  44. poemPhotoDatas.SortInfos();
  45. }
  46. public void Remove(List<long> pictureIds, int sourceType)
  47. {
  48. List<PoemPhotoData> poemPhotoDatas = null;
  49. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  50. {
  51. poemPhotoDatas = PersonalPhotoInfos;
  52. }
  53. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  54. {
  55. poemPhotoDatas = WsqsPhotoInfos;
  56. }
  57. else if (sourceType == 2)
  58. {
  59. poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos;
  60. }
  61. for (int i = 0; i < pictureIds.Count; i++)
  62. {
  63. for (int j = 0; j < poemPhotoDatas.Count; j++)
  64. {
  65. if (pictureIds[i] == poemPhotoDatas[j].PictureId)
  66. {
  67. poemPhotoDatas.RemoveAt(j);
  68. break;
  69. }
  70. }
  71. }
  72. poemPhotoDatas.SortInfos();
  73. }
  74. public void ChangeLockingState(long pictureId, bool state, int sourceType)
  75. {
  76. List<PoemPhotoData> poemPhotoDatas = null;
  77. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  78. {
  79. poemPhotoDatas = PersonalPhotoInfos;
  80. }
  81. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  82. {
  83. poemPhotoDatas = WsqsPhotoInfos;
  84. }
  85. else if(sourceType == 2)
  86. {
  87. poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos;
  88. }
  89. for (int i = 0; i < poemPhotoDatas.Count; i++)
  90. {
  91. if (poemPhotoDatas[i].PictureId == pictureId)
  92. {
  93. poemPhotoDatas[i].LockingStatus = state;
  94. break;
  95. }
  96. }
  97. poemPhotoDatas.SortInfos();
  98. }
  99. public void ChangeToppingState(long pictureId, bool state, int sourceType)
  100. {
  101. List<PoemPhotoData> poemPhotoDatas = null;
  102. if (sourceType == (int)PictureSourceType.PersonalAlbum)
  103. {
  104. poemPhotoDatas = PersonalPhotoInfos;
  105. }
  106. else if (sourceType == (int)PictureSourceType.WanShuiQianShan)
  107. {
  108. poemPhotoDatas = WsqsPhotoInfos;
  109. }
  110. else if (sourceType == 2)
  111. {
  112. poemPhotoDatas = MatchingCompetitionDataManager.Instance.MatchingPhotoInfos;
  113. }
  114. for (int i = 0; i < poemPhotoDatas.Count; i++)
  115. {
  116. if (poemPhotoDatas[i].PictureId == pictureId)
  117. {
  118. poemPhotoDatas[i].ToppingStatus = state;
  119. break;
  120. }
  121. }
  122. poemPhotoDatas.SortInfos();
  123. }
  124. public PoemPhotoData GetPersonalPhotoDataById(long pictureId)
  125. {
  126. for (int i = 0; i < PersonalPhotoInfos.Count; i++)
  127. {
  128. if (pictureId == PersonalPhotoInfos[i].PictureId)
  129. {
  130. return PersonalPhotoInfos[i];
  131. }
  132. }
  133. return null;
  134. }
  135. public NTexture BytesToTexture2D(byte[] bytes)
  136. {
  137. Texture2D texture2D = new Texture2D(UnityEngine.Screen.width, UnityEngine.Screen.height);
  138. texture2D.LoadImage(bytes);
  139. return new NTexture(texture2D);
  140. }
  141. }
  142. }