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.

74 lines
2.4 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  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 portal_ability = get_node("MasterOnly/Portal")
  4. onready var teleport_ability = get_node("MasterOnly/Teleport")
  5. var radius = 15
  6. # The spaces make the bracket centered, rather than on of the dots
  7. var first_crosshair = " [..."
  8. var second_crosshair = "...] "
  9. var no_portal_crosshair = "+"
  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. set_process_input(true)
  20. func _process(delta):
  21. if is_network_master():
  22. var is_second = placement.placed.size() % 2 != 0
  23. var portal_crosshair = second_crosshair if is_second else first_crosshair
  24. var crosshair = no_portal_crosshair if switch_charge < portal_ability.cost else portal_crosshair
  25. get_node("MasterOnly/Crosshair").set_text(crosshair)
  26. var can_build = switch_charge > portal_ability.cost
  27. if placement.place_input(radius, can_build, true) and is_second:
  28. switch_charge -= portal_ability.cost
  29. teleport_ability.disabled = placement.placed.size() <= 1
  30. func _input(event):
  31. flick_input()
  32. func _exit_tree():
  33. ._exit_tree()
  34. if placement:
  35. placement.clear()
  36. # --- Player overrides ---
  37. # --- Own ---
  38. func flick_input():
  39. if Input.is_action_just_pressed("primary_mouse"):
  40. var pick = pick_by_friendly(false)
  41. if pick:
  42. flicking = pick
  43. if flicking and Input.is_action_just_released("primary_mouse"):
  44. var aim = get_node("Yaw/Pitch").get_global_transform().basis
  45. var forwards = -aim[2]
  46. var distance = (flicking.translation - translation).length()
  47. forwards *= distance
  48. var towards = translation + forwards
  49. var gravity = PhysicsServer.area_get_param(get_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY_VECTOR)
  50. # Automatically account for gravity, so as to make UI more intuitive
  51. towards -= gravity
  52. rpc("flick", flicking.get_name(), towards)
  53. flicking = null
  54. build_charge(flick_charge)
  55. sync func flick(player_id, towards):
  56. var who = $"/root/Level/Players".get_node(player_id)
  57. if who.is_network_master():
  58. var direction = towards - who.translation
  59. var impulse = direction.normalized() * flick_strength * who.get_mass()
  60. who.apply_impulse(Vector3(), impulse)