OperaComponent.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using ETModel;
  3. using UnityEngine;
  4. namespace ETHotfix
  5. {
  6. [ObjectSystem]
  7. public class OperaComponentAwakeSystem : AwakeSystem<OperaComponent>
  8. {
  9. public override void Awake(OperaComponent self)
  10. {
  11. self.Awake();
  12. }
  13. }
  14. [ObjectSystem]
  15. public class OperaComponentUpdateSystem : UpdateSystem<OperaComponent>
  16. {
  17. public override void Update(OperaComponent self)
  18. {
  19. self.Update();
  20. }
  21. }
  22. public class OperaComponent: Component
  23. {
  24. public Vector3 ClickPoint;
  25. public int mapMask;
  26. public void Awake()
  27. {
  28. this.mapMask = LayerMask.GetMask("Map");
  29. }
  30. private readonly Frame_ClickMap frameClickMap = new Frame_ClickMap();
  31. public void Update()
  32. {
  33. if (Input.GetMouseButtonDown(1))
  34. {
  35. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  36. RaycastHit hit;
  37. if (Physics.Raycast(ray, out hit, 1000, this.mapMask))
  38. {
  39. this.ClickPoint = hit.point;
  40. frameClickMap.X = this.ClickPoint.x;
  41. frameClickMap.Y = this.ClickPoint.y;
  42. frameClickMap.Z = this.ClickPoint.z;
  43. ETModel.SessionComponent.Instance.Session.Send(frameClickMap);
  44. // 测试actor rpc消息
  45. this.TestActor().Coroutine();
  46. }
  47. }
  48. }
  49. public async ETVoid TestActor()
  50. {
  51. try
  52. {
  53. M2C_TestActorResponse response = (M2C_TestActorResponse)await SessionComponent.Instance.Session.Call(
  54. new C2M_TestActorRequest() { Info = "actor rpc request" });
  55. Log.Info(response.Info);
  56. }
  57. catch (Exception e)
  58. {
  59. Log.Error(e);
  60. }
  61. }
  62. }
  63. }