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.

55 lines
1.6 KiB

  1. extends "res://scripts/placeable.gd"
  2. var portal_charge = 15
  3. var other
  4. var index
  5. var first_color = Color("#d14013")
  6. var second_color = Color("#ecb521")
  7. func _ready():
  8. for player in get_node("/root/Level/Players").get_children():
  9. player.connect("body_entered", self, "player_collided", [player])
  10. func init(maker):
  11. var maker_portals = maker.placement.placed
  12. index = maker_portals.size() # No -1, because we haven't actually been added to the array yet
  13. # If index is odd, we're the second (1, 3...), if even, first (0, 4...)
  14. var second = index % 2 != 0
  15. var color = second_color if second else first_color
  16. var mat = SpatialMaterial.new()
  17. color.a = 0.5
  18. mat.flags_transparent = true
  19. mat.albedo_color = color
  20. get_node("MeshInstance").set_surface_material(0, mat)
  21. .init(maker)
  22. func player_collided(with, player):
  23. if with == self:
  24. portal(player)
  25. func find_other():
  26. var maker_portals = maker_node.placement.placed
  27. var count = maker_portals.size()
  28. # If index is odd, we're the second (1, 3...), if even, first (0, 4...)
  29. var second = index % 2 != 0
  30. var delta = -1 if second else 1
  31. if index + delta < count:
  32. other = maker_portals[index + delta] # Second-to-last: we're already included
  33. return other
  34. else:
  35. return null
  36. func portal(player):
  37. if find_other():
  38. var spawn_distance = 2
  39. # Find a sane place to spawn
  40. # -Z is in the direction of the portal
  41. # X is enough away from the portal to avoid infinite loop
  42. # With both axes, gravity could never bring us to hit the portal
  43. var to = other.to_global(Vector3(spawn_distance,0,-spawn_distance))
  44. player.set_translation(to)