GamePlayerData.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class GamePlayerData {
  5. private static GamePlayerData _instance;
  6. private bool isNeedNet;//是否是联网模式 如果是的话需要接收消息再做出响应
  7. public int user_id = -1;
  8. public int school_id;
  9. public string school_name;
  10. public string user_name;
  11. public int user_type;//0 老师 1学生 2 ipad端 3 可以创建公开课也可以创建本地课的 4后台管理员
  12. public bool is_create;
  13. public int max_ct;//默认的房间最大人数
  14. public ExperimentData eData;
  15. public string url_image_str = "http://bi.bellcat.cn";
  16. public bool isDebugAccount;//是超级账号 可以开启DebugLog
  17. public bool isOpenAudio = false;//语音模块是否可以启用
  18. public RoomData room_data;//房间信息
  19. public TeacherOperateData teacher_operate_data;//老师的操作信息
  20. public SocketRoomItemData CreateRoomdata;//创建的房间信息 每次创建的时候需要重新设置
  21. public static GamePlayerData Instance
  22. {
  23. get
  24. {
  25. if (_instance == null)
  26. {
  27. _instance = new GamePlayerData();
  28. }
  29. return _instance;
  30. }
  31. }
  32. private GamePlayerData()
  33. {
  34. Engine.Net.NetMsgLog.IsDebugMsg = true;
  35. room_data = new RoomData();
  36. teacher_operate_data = new TeacherOperateData();
  37. teacher_operate_data.Init();
  38. CDebug.Log("GamePlayerData Init");
  39. }
  40. public void Dispose()
  41. {
  42. teacher_operate_data.Dispose();
  43. }
  44. public bool IsMaster {
  45. get {
  46. return user_type == 0 || user_type == 3;
  47. }
  48. }
  49. public bool IsStudent
  50. {
  51. get
  52. {
  53. return user_type == GameEnum.STUDENT_TYPE;
  54. }
  55. }
  56. public bool IsNeedNet { get { return isNeedNet; } }
  57. public bool RootCreatePublic
  58. {
  59. get { return user_type == 3; }//止呕管理员才能创建
  60. }
  61. public bool IsInRoom
  62. {
  63. get { return room_data.CurRoomId != -1; }
  64. }
  65. //是否需要发送操作信息给学生
  66. public bool NeedSendLineMsg()
  67. {
  68. //在房间里 而且是房主 房间里还有别人的时候
  69. return IsInRoom && room_data.IsReconnectOwner() && !room_data.IsEmptyUser;
  70. }
  71. //是否开启语音
  72. public bool IsNeedAudio()
  73. {
  74. return int.Parse(GameConfigData.Instance.course_data.GetCourseConfigById(room_data.CurOnlineData.course_id).open_audio) == 1;
  75. }
  76. public bool IsFangzhu()
  77. {
  78. if(room_data == null || room_data.CurOnlineData == null)
  79. {
  80. return false;
  81. }
  82. if(user_id == room_data.CurOnlineData.owner_id)
  83. {
  84. return true;
  85. }
  86. return false;
  87. }
  88. public string AudioRoomName()
  89. {
  90. if (room_data == null || room_data.CurOnlineData == null)
  91. {
  92. return user_name;
  93. }
  94. return room_data.CurOnlineData.AudioRoomName;
  95. }
  96. }