GirlMob.gd 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. class_name GirlMob
  2. extends BaseMob
  3. const DEBUG = false
  4. onready var jump_grace_timer = $"JumpGraceTimer"
  5. onready var boots = $"Boots"
  6. onready var hair = $"Hair"
  7. onready var body = $"Body"
  8. onready var just_fallen_timer = $"JustFallenTimer"
  9. onready var just_jumped_timer = $"JustJumpedTimer"
  10. var lightning
  11. var sprite_direction: bool = true
  12. var timer_stair = 0.0
  13. var walking_up = false
  14. var walking_down = false
  15. export var start_flipped = false
  16. var jumping_p1 = false
  17. var jumping_p2 = false
  18. var outside_the_building = false
  19. var navmap
  20. onready var stair_collider_down = $"StairColliderL"
  21. onready var stair_collider_up = $"StairColliderR"
  22. onready var walker = $Walker
  23. func _ready():
  24. flip(start_flipped)
  25. func flip(toggle: bool):
  26. boots.set_flip_h(toggle)
  27. hair.set_flip_h(toggle)
  28. body.set_flip_h(toggle)
  29. if toggle:
  30. stair_collider_down.set_position(Vector2(3, 27))
  31. stair_collider_up.set_position(Vector2(10, 14))
  32. else:
  33. stair_collider_down.set_position(Vector2(-3, 27))
  34. stair_collider_up.set_position(Vector2(-10, 14))
  35. sprite_direction = toggle
  36. func animate(_delta):
  37. if abs(real_velocity.y) < 0.0001:
  38. if previous_real_velocity.y > 0.0:
  39. just_fallen_timer.start()
  40. if (abs(real_velocity.x) > 0.01 and abs(real_velocity.y) < 0.01) or walking_up or walking_down:
  41. boots.play()
  42. else:
  43. boots.stop()
  44. hair.speed_scale = 0.2 + (abs(real_velocity.x) + abs(real_velocity.y)) / 80.0
  45. if !just_fallen_timer.is_stopped():
  46. hair.speed_scale += just_fallen_timer.time_left * 10.0
  47. if outside_the_building:
  48. hair.speed_scale += 4
  49. func strike():
  50. .strike()
  51. lives -= 1
  52. boots.stop()
  53. #hair.stop()
  54. #body.stop()
  55. walker.stop_all()
  56. func post_movement(_delta):
  57. if frozen:
  58. return
  59. if real_velocity.y > 0:
  60. if jumping_p1:
  61. jumping_p1 = false
  62. jumping_p2 = true
  63. if abs(real_velocity.y) < 0.0001:
  64. if jump_grace_timer.is_stopped():
  65. velocity.y = 0
  66. jumping_p1 = false
  67. jumping_p2 = false
  68. else:
  69. if !jumping_p1 and !jumping_p2:
  70. velocity.y = -jump_burst
  71. jump_grace_timer.stop()
  72. just_jumped_timer.start()
  73. if !outside_the_building:
  74. walker.hop()
  75. jumping_p1 = true
  76. func stairs(delta):
  77. walking_up = false
  78. max_velocity = base_max_velocity
  79. gravity = 300.0
  80. walking_down = false
  81. if abs(velocity.x) > 0 and !jumping_p1 and !jumping_p2 and jump_grace_timer.is_stopped():
  82. if stair_collider_up.get_overlapping_areas().size() > 0:
  83. timer_stair += delta / 2.0
  84. walking_up = true
  85. if timer_stair > 0.1:
  86. timer_stair = 0.0
  87. move_local_y(-8.0)
  88. else:
  89. walking_up = false
  90. if just_jumped_timer.is_stopped() and stair_collider_down.get_overlapping_areas().size() > 0 and not stair_collider_up.get_overlapping_areas().size() > 0:
  91. max_velocity = base_max_velocity / 2.0
  92. gravity = 9600.0
  93. walking_down = true
  94. else:
  95. max_velocity = base_max_velocity
  96. gravity = 300.0
  97. walking_down = false
  98. if walking_up or walking_down:
  99. boots.budge = false
  100. else:
  101. boots.budge = true
  102. func _unfreeze(_body):
  103. frozen = false
  104. func _unflip(_body):
  105. flip(false)