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.

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