A team game with an emphasis on movement (with no shooting), inspired by Overwatch and Zineth
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.3 KiB

  1. extends "res://scripts/player.gd"
  2. onready var placement = preload("res://scripts/placement.gd").new(self, "res://scenes/heroes/5_portal.tscn")
  3. onready var teleport_ability = get_node("MasterOnly/Teleport")
  4. var radius = 15
  5. # The spaces make the bracket centered, rather than on of the dots
  6. var first_crosshair = " [..."
  7. var second_crosshair = "...] "
  8. var no_portal_crosshair = "+"
  9. var portal_cost = 20
  10. var flicking = null
  11. var flick_charge = 3
  12. var flick_strength = 4
  13. # --- Godot overrides ---
  14. func _ready():
  15. placement.start_action = "hero_5_place_portal"
  16. placement.confirm_action = "hero_5_confirm_portal"
  17. placement.delete_action = "hero_5_remove_portal"
  18. placement.max_placed = 100
  19. func _process(delta):
  20. if is_network_master():
  21. var is_second = placement.placed.size() % 2 != 0
  22. var portal_crosshair = second_crosshair if is_second else first_crosshair
  23. var crosshair = no_portal_crosshair if switch_charge < portal_cost else portal_crosshair
  24. get_node("MasterOnly/Crosshair").set_text(crosshair)
  25. if switch_charge > portal_cost or is_second:
  26. if placement.place_input(radius, true) and is_second:
  27. switch_charge -= portal_cost
  28. if Input.is_action_just_pressed("primary_mouse"):
  29. var pick = pick_by_friendly(false)
  30. if pick:
  31. flicking = pick
  32. if flicking and Input.is_action_just_released("primary_mouse"):
  33. var aim = get_node("Yaw/Pitch").get_global_transform().basis
  34. var forwards = -aim[2]
  35. var distance = (flicking.translation - translation).length()
  36. forwards *= distance
  37. var towards = translation + forwards
  38. var gravity = PhysicsServer.area_get_param(get_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY_VECTOR)
  39. # Automatically account for gravity, so as to make UI more intuitive
  40. towards -= gravity
  41. rpc("flick", flicking.get_name(), towards)
  42. flicking = null
  43. switch_charge += flick_charge
  44. teleport_ability.disabled = placement.placed.size() <= 1
  45. func _exit_tree():
  46. ._exit_tree()
  47. if placement:
  48. placement.clear()
  49. # --- Player overrides ---
  50. # --- Own ---
  51. sync func flick(player_id, towards):
  52. var who = $"/root/Level/Players".get_node(player_id)
  53. if who.is_network_master():
  54. var direction = towards - who.translation
  55. var impulse = direction.normalized() * flick_strength * who.get_mass()
  56. who.apply_impulse(Vector3(), impulse)