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.

51 lines
1.3 KiB

  1. extends Control
  2. onready var hero = get_node("../..")
  3. onready var bar = get_node("Bar")
  4. onready var available = get_node("Available")
  5. export var cost = 1
  6. export var ability_name = "Ability"
  7. export var display_progress = true
  8. export var action = ""
  9. # This is intended to be public
  10. var disabled = false
  11. func _ready():
  12. get_node("Name").text = ability_name
  13. var description
  14. if action:
  15. var primary = InputMap.get_action_list(action)[0]
  16. if primary is InputEventMouseButton:
  17. if primary.button_index == BUTTON_LEFT:
  18. description = "Click"
  19. elif primary.button_index == BUTTON_RIGHT:
  20. description = "Right Click"
  21. else:
  22. description = "Scroll Click"
  23. else:
  24. description = primary.as_text()
  25. else:
  26. description = ""
  27. get_node("Button").text = description
  28. func is_pressed():
  29. return Input.is_action_pressed(action)
  30. func _process(delta):
  31. if action and Input.is_action_pressed(action):
  32. available.rect_position = Vector2(-25, -25) # Centered / not offset
  33. else:
  34. available.rect_position = Vector2(-30, -30)
  35. if disabled:
  36. available.hide()
  37. bar.value = 0
  38. else:
  39. if display_progress:
  40. if cost == 0:
  41. bar.value = 100 if hero.charge > 0 else 0
  42. else:
  43. bar.value = 100 * hero.charge / cost
  44. if hero.charge > cost:
  45. available.show()
  46. else:
  47. available.hide()