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
1.8 KiB

  1. extends "res://scripts/placeable.gd"
  2. var portal_charge = 15
  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. var maker_portals = maker.placement.placed
  23. index = maker_portals.size() # No -1, because we haven't actually been added to the array yet
  24. # If index is odd, we're the second (1, 3...), if even, first (0, 4...)
  25. var second = index % 2 != 0
  26. var is_friend = util.is_friendly(maker)
  27. var color_set = friend_colors if is_friend else enemy_colors
  28. var color = color_set[int(second)]
  29. var mat = SpatialMaterial.new()
  30. # color.a = 0.5
  31. # mat.flags_transparent = true
  32. mat.albedo_color = color
  33. get_node("MeshInstance").set_surface_material(0, mat)
  34. .init(maker)
  35. func place():
  36. .place()
  37. var second = index % 2 != 0
  38. if second:
  39. # Our responsibility to complete the pairing
  40. other = maker_node.placement.placed[index - 1]
  41. other.other = self
  42. func player_collided(with, player):
  43. if with == self:
  44. portal(player)
  45. func portal(player):
  46. if player.player_info.is_right_team == maker_node.player_info.is_right_team:
  47. if other:
  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.switch_charge += portal_charge