OperaComponent.cs 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using UnityEngine;
  2. namespace Model
  3. {
  4. [ObjectEvent]
  5. public class OperaComponentEvent : ObjectEvent<OperaComponent>, IUpdate, IAwake
  6. {
  7. public void Update()
  8. {
  9. this.Get().Update();
  10. }
  11. public void Awake()
  12. {
  13. this.Get().Awake();
  14. }
  15. }
  16. public class OperaComponent: Component
  17. {
  18. public Vector3 ClickPoint;
  19. public int mapMask;
  20. public void Awake()
  21. {
  22. this.mapMask = LayerMask.GetMask("Map");
  23. }
  24. public void Update()
  25. {
  26. if (Input.GetMouseButtonDown(1))
  27. {
  28. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  29. RaycastHit hit;
  30. if (Physics.Raycast(ray, out hit, 1000, this.mapMask))
  31. {
  32. this.ClickPoint = hit.point;
  33. SessionComponent.Instance.Session.Send(new Frame_ClickMap() { X = (int)(this.ClickPoint.x * 1000), Z = (int)(this.ClickPoint.z * 1000) });
  34. }
  35. }
  36. }
  37. }
  38. }