OperaComponent.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using ETModel;
  2. using UnityEngine;
  3. namespace ETHotfix
  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: Component
  22. {
  23. public Vector3 ClickPoint;
  24. public int mapMask;
  25. public void Awake()
  26. {
  27. this.mapMask = LayerMask.GetMask("Map");
  28. }
  29. public void Update()
  30. {
  31. if (Input.GetMouseButtonDown(1))
  32. {
  33. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  34. RaycastHit hit;
  35. if (Physics.Raycast(ray, out hit, 1000, this.mapMask))
  36. {
  37. this.ClickPoint = hit.point;
  38. SessionComponent.Instance.Session.Send(new Frame_ClickMap() { X = (int)(this.ClickPoint.x * 1000), Z = (int)(this.ClickPoint.z * 1000) });
  39. // 测试actor rpc消息
  40. this.TestActor();
  41. }
  42. }
  43. }
  44. public async void TestActor()
  45. {
  46. M2C_TestActorResponse response = (M2C_TestActorResponse)await SessionWrapComponent.Instance.Session.Call(
  47. new C2M_TestActorRequest() {Info = "actor rpc request"});
  48. Log.Info(response.Info);
  49. }
  50. }
  51. }