UserComp.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. /* Socket组件-用户 */
  3. public class UserComp : JCUnityLib.Singleton<UserComp>
  4. {
  5. public void getUserInfo(System.Action<UserInfo> cb) {
  6. UserPlayer.ins.call("userComp.getUserInfo", null, cb);
  7. }
  8. public void saveUserInfo(UserInfo userInfo) {
  9. UserPlayer.ins.call("userComp.saveUserInfo", userInfo);
  10. }
  11. public void saveMac()
  12. {
  13. string mac = LoginMgr.myUserInfo.mac;
  14. if (string.IsNullOrEmpty(mac)) return;
  15. int type = AimHandler.ins.DeviceType;
  16. if (type > 0) {
  17. UserPlayer.ins.call("userComp.saveMac2", mac, type);
  18. } else {
  19. Action<Newtonsoft.Json.Linq.JToken> cb = (Newtonsoft.Json.Linq.JToken o) => {
  20. string gyrStr = o.Value<string>("gyr");
  21. string magStr = o.Value<string>("mag");
  22. AimHandler.ins.InitGyr(gyrStr);
  23. AimHandler.ins.InitMag(magStr);
  24. };
  25. UserPlayer.ins.call("userComp.saveMac", new object[]{mac}, cb);
  26. }
  27. }
  28. public void saveCalibrateRecord(string record) {
  29. string mac = BluetoothAim.ins.curMac;
  30. if (string.IsNullOrEmpty(mac)) {
  31. SideTipView.ShowTip("没有Mac无法上传九轴数据", UnityEngine.Color.yellow);
  32. throw new Exception("没有Mac无法上传九轴数据");
  33. }
  34. int type = AimHandler.ins.DeviceType;
  35. if (type > 0) {
  36. UserPlayer.ins.call("userComp.saveCalibrateRecord", type, record, mac);
  37. }
  38. }
  39. #region 被服务端调用的函数
  40. public void onResumeCalibrateRecord(string record) {
  41. AimHandler.ins.ResumeCalibrateRecord(record);
  42. }
  43. #endregion
  44. }