HouseRaycastReceiver.re.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import * as RE from 'rogue-engine';
  2. import RaycastReceiver from './RaycastReceiver.re';
  3. export default class HouseRaycastReceiver extends RaycastReceiver {
  4. isHovered = false
  5. elapsed = 0
  6. clearHoverId = 0
  7. awake() {
  8. }
  9. start() {
  10. this.elapsed = 0
  11. }
  12. update() {
  13. if (this.isHovered) {
  14. this.elapsed += RE.Runtime.deltaTime
  15. this.object3d.position.y = 0.5 * Math.sin(4 * this.elapsed) + 1
  16. if (RE.Input.mouse.getButtonUp(0) || RE.Input.touch.endTouches.length > 0) {
  17. RE.Runtime.rogueDOMContainer.style.cursor = "default"
  18. RE.App.loadScene("World Map")
  19. }
  20. } else {
  21. if (this.object3d.position.y != 0) {
  22. this.object3d.position.y = 0
  23. }
  24. }
  25. }
  26. onMouseOver(intersect) {
  27. if (!this.isHovered) {
  28. this.isHovered = true
  29. }
  30. RE.Runtime.rogueDOMContainer.style.cursor = "pointer"
  31. return false
  32. }
  33. onMouseOut() {
  34. if (!this.isHovered) {
  35. return
  36. }
  37. this.isHovered = false
  38. // this.object3d.position.y = 0
  39. RE.Runtime.rogueDOMContainer.style.cursor = "default"
  40. }
  41. }
  42. RE.registerComponent(HouseRaycastReceiver);