OperaComponent.cs 1.6 KB

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