OperaComponent.cs 1.6 KB

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