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.

69 lines
1.7 KiB

  1. extends "res://scripts/placeable.gd"
  2. var portal_charge = -5
  3. var other
  4. var index
  5. var enemy_colors = [
  6. Color("#d14013"),
  7. Color("#ecb521"),
  8. ]
  9. var friend_colors = [
  10. Color("#1209c4"),
  11. Color("#2066e7"),
  12. ]
  13. func _ready():
  14. for player in get_node("/root/Level/Players").get_children():
  15. player.connect("body_entered", self, "player_collided", [player])
  16. func _exit_tree():
  17. # We delete in pairs
  18. if other:
  19. maker_node.placement.placed.remove(index - 1)
  20. other.queue_free()
  21. func init(maker):
  22. index = maker.placement.placed.size()
  23. # If index is odd, we're the second (1, 3...), if even, first (0, 4...)
  24. var second = index % 2 != 0
  25. var is_friend = util.is_friendly(maker)
  26. var color_set = friend_colors if is_friend else enemy_colors
  27. var color = color_set[int(second)]
  28. var mat = SpatialMaterial.new()
  29. # color.a = 0.5
  30. # mat.flags_transparent = true
  31. mat.albedo_color = color
  32. get_node("MeshInstance").set_surface_material(0, mat)
  33. .init(maker)
  34. func place():
  35. .place()
  36. var second = index % 2 != 0
  37. if second:
  38. # Our responsibility to complete the pairing
  39. other = maker_node.placement.placed[index - 1]
  40. other.other = self
  41. func player_collided(with, player):
  42. if with == self:
  43. portal(player)
  44. func portal(player):
  45. if player.player_info.is_right_team == maker_node.player_info.is_right_team:
  46. if other:
  47. if maker_node.switch_charge > -portal_charge:
  48. var spawn_distance = 1.75
  49. # Find a sane place to spawn
  50. # -Z is in the direction of the portal
  51. # X is enough away from the portal to avoid infinite loop
  52. # With both axes, gravity could never bring us to hit the portal
  53. var to = other.to_global(Vector3(spawn_distance,0,-spawn_distance))
  54. player.set_translation(to)
  55. maker_node.build_charge(portal_charge)