OperaComponentSystem.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.mapMask = LayerMask.GetMask("Map");
  10. }
  11. }
  12. public class OperaComponentUpdateSystem : UpdateSystem<OperaComponent>
  13. {
  14. public override void Update(OperaComponent self)
  15. {
  16. self.Update();
  17. }
  18. }
  19. public static class OperaComponentSystem
  20. {
  21. public static void Update(this OperaComponent self)
  22. {
  23. if (Input.GetMouseButtonDown(1))
  24. {
  25. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  26. RaycastHit hit;
  27. if (Physics.Raycast(ray, out hit, 1000, self.mapMask))
  28. {
  29. self.ClickPoint = hit.point;
  30. self.frameClickMap.X = self.ClickPoint.x;
  31. self.frameClickMap.Y = self.ClickPoint.y;
  32. self.frameClickMap.Z = self.ClickPoint.z;
  33. self.DomainScene().GetComponent<SessionComponent>().Session.Send(self.frameClickMap);
  34. // 测试actor rpc消息
  35. self.TestActor().Coroutine();
  36. }
  37. }
  38. }
  39. public static async ETVoid TestActor(this OperaComponent self)
  40. {
  41. try
  42. {
  43. M2C_TestActorResponse response = (M2C_TestActorResponse)await self.Domain.GetComponent<SessionComponent>().Session.Call(
  44. new C2M_TestActorRequest() { Info = "actor rpc request" });
  45. Log.Info(response.Info);
  46. }
  47. catch (Exception e)
  48. {
  49. Log.Error(e);
  50. }
  51. }
  52. }
  53. }