OperaComponent.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Model;
  2. using UnityEngine;
  3. namespace Hotfix
  4. {
  5. [ObjectSystem]
  6. public class OperaComponentSystem : ObjectSystem<OperaComponent>, IUpdate, IAwake
  7. {
  8. public void Update()
  9. {
  10. this.Get().Update();
  11. }
  12. public void Awake()
  13. {
  14. this.Get().Awake();
  15. }
  16. }
  17. public class OperaComponent: Component
  18. {
  19. public Vector3 ClickPoint;
  20. public int mapMask;
  21. public void Awake()
  22. {
  23. this.mapMask = LayerMask.GetMask("Map");
  24. }
  25. public void Update()
  26. {
  27. if (Input.GetMouseButtonDown(1))
  28. {
  29. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  30. RaycastHit hit;
  31. if (Physics.Raycast(ray, out hit, 1000, this.mapMask))
  32. {
  33. this.ClickPoint = hit.point;
  34. SessionComponent.Instance.Session.SendModel(new Frame_ClickMap() { X = (int)(this.ClickPoint.x * 1000), Z = (int)(this.ClickPoint.z * 1000) });
  35. // 测试actor rpc消息
  36. this.TestActor();
  37. }
  38. }
  39. }
  40. public async void TestActor()
  41. {
  42. M2C_TestActorResponse response = (M2C_TestActorResponse)await SessionComponent.Instance.Session.Call(
  43. new C2M_TestActorRequest() {Info = "actor rpc request"});
  44. Log.Info(response.Info);
  45. }
  46. }
  47. }