OperaComponent.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. 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. ETModel.SessionComponent.Instance.Session.Send(new Frame_ClickMap() { X = (int)(this.ClickPoint.x * 1000), Z = (int)(this.ClickPoint.z * 1000) });
  40. // 测试actor rpc消息
  41. this.TestActor();
  42. }
  43. }
  44. }
  45. public async void TestActor()
  46. {
  47. try
  48. {
  49. M2C_TestActorResponse response = (M2C_TestActorResponse)await SessionComponent.Instance.Session.Call(
  50. new C2M_TestActorRequest() { Info = "actor rpc request" });
  51. //Log.Info(response.Info);
  52. }
  53. catch (Exception e)
  54. {
  55. Log.Error(e);
  56. }
  57. }
  58. }
  59. }