CollegeProxy.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using Newtonsoft.Json.Linq;
  2. using CSharpUtil;
  3. using System;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. public class CollegeProxy :ProxyBase<CollegeProxy>
  8. {
  9. public CollegeProxy() => this.opeCode = OpeCode.ope_college;
  10. /// <summary>
  11. /// 获取学院信息--old
  12. /// </summary>
  13. /// <returns></returns>
  14. //public CollegeVo GetCollegeInfo()
  15. //{
  16. // CollegeVo vo = new CollegeVo();
  17. // return vo;
  18. //}
  19. /// <summary>
  20. /// [7301] 激活
  21. /// </summary>
  22. /// <param name="taskCardId"></param>
  23. /// <param name="callback"></param>
  24. /// <param name="faild"></param>
  25. public void ActiveTaskCard(int taskCardId, Action<CollegeVo> callback, Action faild)
  26. {
  27. Post(CmdCode.cmd_college_ActiveTaskCard, new object[] { taskCardId },
  28. resp =>
  29. {
  30. var p = UserProxy.Instance.player;
  31. //p.InitFromStore((JObject)resp.result["store"]);
  32. p.collegeInfo.Initlize(resp.result["college"]);
  33. CollegeVo vo = new CollegeVo(taskCardId);
  34. if (callback != null)
  35. {
  36. callback.Invoke(vo);
  37. }
  38. });
  39. }
  40. /// <summary>
  41. /// [7302] 领取年级奖励
  42. /// </summary>
  43. /// <param name="callback"></param>
  44. /// <param name="faild"></param>
  45. //public void ReceiveCollegeReward(Action<CollegeVo> callback, Action faild)
  46. //{
  47. // Post(CmdCode.cmd_college_ReceiveCollegeReward, new object[] { },
  48. // resp =>
  49. // {
  50. // var p = UserProxy.Instance.player;
  51. // //p.InitFromStore((JObject)resp.result["store"]); // 更新任务卡
  52. // p.collegeInfo.Initlize(resp.result["college"]);
  53. // p.baseInfo.gold = Convert.ToInt32(resp.result["gold"].ToString());
  54. // p.baseInfo.cash = Convert.ToInt32(resp.result["cash"].ToString());
  55. // p.baseInfo.level = Convert.ToInt32(resp.result["lvl"].ToString());
  56. // CollegeVo vo = new CollegeVo();
  57. // if (callback != null)
  58. // {
  59. // callback.Invoke(vo);
  60. // }
  61. // });
  62. //}
  63. /// <summary>
  64. /// [7303] 领取课程奖励
  65. /// </summary>
  66. /// <param name="callback"></param>
  67. /// <param name="faild"></param>
  68. //public void ReceiveCourseReward(Action<CollegeVo> callback, Action faild)
  69. //{
  70. // Post(CmdCode.cmd_college_ReceiveCourseReward, new object[] { },
  71. // resp =>
  72. // {
  73. // var p = UserProxy.Instance.player;
  74. // //p.InitFromStore((JObject)resp.result["store"]); // 更新任务卡
  75. // p.collegeInfo.Initlize(resp.result["college"]);
  76. // p.baseInfo.gold = Convert.ToInt32(resp.result["gold"].ToString());
  77. // p.baseInfo.cash = Convert.ToInt32(resp.result["cash"].ToString());
  78. // p.baseInfo.level = Convert.ToInt32(resp.result["lvl"].ToString());
  79. // CollegeVo vo = new CollegeVo();
  80. // if (callback != null)
  81. // {
  82. // callback.Invoke(vo);
  83. // }
  84. // });
  85. //}
  86. //----------------------------new
  87. /// <summary>
  88. /// 新的
  89. /// </summary>
  90. /// <returns></returns>
  91. public void GetCollegeInfo(int type,Action<CollegeVo> callback)
  92. {
  93. Post(CmdCode.cmd_college_GetCollegeData, new object[] { },
  94. resp =>
  95. {
  96. var p = UserProxy.Instance.player;
  97. p.InitFromStore((JObject)resp.result["store"]); // 更新任务卡
  98. p.collegeInfo.Initlize(resp.result["college"]);
  99. if (callback != null)
  100. {
  101. callback.Invoke(new CollegeVo (type));
  102. }
  103. });
  104. //
  105. //List<CollegeNewVo> collegelist = new List<CollegeNewVo>();
  106. //CollegeNewVo collegeVo = null;
  107. //foreach (KeyValuePair<int, Dictionary<int, Dictionary<string, missCourseItem>>> kv in ingTaskCardDic)
  108. //{
  109. // if (kv.Key == type)
  110. // {
  111. // collegeVo = new CollegeNewVo(kv.Key);
  112. // //Dictionary<int, Dictionary<string, missCourseItem>> courseDic = kv.Value;
  113. // //List<CourseNewVo> clist = new List<CourseNewVo>();
  114. // //foreach (KeyValuePair<int, Dictionary<string, missCourseItem>> kt in courseDic)
  115. // //{
  116. // // CourseNewVo courseVo = new CourseNewVo(kv.Key, kt.Key);
  117. // // Dictionary<string, missCourseItem> cardDic = kt.Value;
  118. // // List<TaskCardDataNewVo> taskCardList = new List<TaskCardDataNewVo>();
  119. // // foreach (KeyValuePair<string, missCourseItem> kn in cardDic)
  120. // // {
  121. // // TaskCardDataNewVo cardVo = new TaskCardDataNewVo(kv.Key, kt.Key, kn.Key);
  122. // // taskCardList.Add(cardVo);
  123. // // }
  124. // // courseVo.taskCardList = taskCardList;
  125. // // clist.Add(courseVo);
  126. // //}
  127. // //collegeVo.courseList = clist;
  128. // break;
  129. // }
  130. //}
  131. //return collegeVo;
  132. }
  133. /// <summary>
  134. /// [7302] 领取年级奖励
  135. /// </summary>
  136. /// <param name="callback"></param>
  137. /// <param name="faild"></param>
  138. public void ReceiveCollegeReward(int collegeId,Action<CollegeVo> callback, Action faild)
  139. {
  140. Post(CmdCode.cmd_college_ReceiveCollegeReward, new object[] { collegeId },
  141. resp =>
  142. {
  143. var p = UserProxy.Instance.player;
  144. p.InitFromStore((JObject)resp.result["store"]); // 更新任务卡
  145. p.collegeInfo.Initlize(resp.result["college"]);
  146. p.baseInfo.gold = Convert.ToInt32(resp.result["gold"].ToString());
  147. p.baseInfo.cash = Convert.ToInt32(resp.result["cash"].ToString());
  148. p.baseInfo.level = Convert.ToInt32(resp.result["lvl"].ToString());
  149. CollegeVo vo = new CollegeVo(collegeId);
  150. if (callback != null)
  151. {
  152. callback.Invoke(vo);
  153. }
  154. });
  155. }
  156. /// <summary>
  157. /// [7303] 领取课程奖励
  158. /// </summary>
  159. /// <param name="callback"></param>
  160. /// <param name="faild"></param>
  161. public void ReceiveCourseReward(int collegeId,int courseId,Action<CollegeVo> callback, Action faild)
  162. {
  163. Post(CmdCode.cmd_college_ReceiveCourseReward, new object[] { collegeId,courseId },
  164. resp =>
  165. {
  166. var p = UserProxy.Instance.player;
  167. p.InitFromStore((JObject)resp.result["store"]); // 更新任务卡
  168. p.collegeInfo.Initlize(resp.result["college"]);
  169. p.baseInfo.gold = Convert.ToInt32(resp.result["gold"].ToString());
  170. p.baseInfo.cash = Convert.ToInt32(resp.result["cash"].ToString());
  171. p.baseInfo.level = Convert.ToInt32(resp.result["lvl"].ToString());
  172. CollegeVo vo = new CollegeVo(collegeId);
  173. if (callback != null)
  174. {
  175. callback.Invoke(vo);
  176. }
  177. });
  178. }
  179. /// <summary>
  180. /// 积分兑换
  181. /// </summary>
  182. /// <param name="id"></param>
  183. /// <param name="callback"></param>
  184. /// <param name="faild"></param>
  185. public void ScoreExchangeItem(int id, Action<List<CollegeScoreVo>> callback, Action faild)
  186. {
  187. Post(CmdCode.cmd_college_ScoreExchangeItem, new object[] { id },
  188. resp =>
  189. {
  190. var p = UserProxy.Instance.player;
  191. p.InitFromStore((JObject)resp.result["store"]); // 更新任务卡
  192. p.collegeInfo.Initlize(resp.result["college"]);
  193. Dictionary<Int32, sm_score> score = GameConfigData.Ins.score;
  194. List<CollegeScoreVo> list = new List<CollegeScoreVo>();
  195. foreach (KeyValuePair<int,sm_score>kv in score)
  196. {
  197. CollegeScoreVo vo = new CollegeScoreVo(kv.Key);
  198. list.Add(vo);
  199. }
  200. if (callback != null)
  201. {
  202. callback.Invoke(list);
  203. }
  204. });
  205. }
  206. }