abilities first draft
This commit is contained in:
@@ -7,19 +7,42 @@ const _BG := Color(0.06, 0.04, 0.02, 0.78)
|
||||
const _BADGE := Color(0.16, 0.10, 0.03, 0.90)
|
||||
const _BORDER := Color(0.65, 0.48, 0.15, 0.55)
|
||||
|
||||
const _ABILITY_ICONS: Array[String] = [
|
||||
"res://HUD/HUD_0000_ability_JALG.png",
|
||||
"res://HUD/HUD_0001_ability_SLAM.png",
|
||||
"res://HUD/HUD_0002_ability_DASH.png",
|
||||
]
|
||||
const _ABILITY_KEYS: Array[String] = ["F", "G", "H"]
|
||||
|
||||
var _controls_visible: bool = true
|
||||
var _controls_panel: PanelContainer
|
||||
var _toggle_btn: Button
|
||||
var _spawner: Node
|
||||
var _player: Node = null
|
||||
var _cd_overlays: Array[ColorRect] = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
layer = 11
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
_build_controls_panel()
|
||||
_build_ability_bar()
|
||||
_find_spawner.call_deferred()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if _player == null:
|
||||
var players := get_tree().get_nodes_in_group(&"player")
|
||||
if not players.is_empty():
|
||||
_player = players[0]
|
||||
return
|
||||
for i: int in _cd_overlays.size():
|
||||
var fraction: float = _player.call(&"ability_cooldown_fraction", i)
|
||||
var ov := _cd_overlays[i]
|
||||
ov.anchor_top = 1.0 - fraction
|
||||
ov.anchor_bottom = 1.0
|
||||
|
||||
|
||||
func _find_spawner() -> void:
|
||||
var spawners := get_tree().get_nodes_in_group(&"matador_spawn")
|
||||
if not spawners.is_empty():
|
||||
@@ -28,7 +51,7 @@ func _find_spawner() -> void:
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
if event.physical_keycode == KEY_H:
|
||||
if event.physical_keycode == KEY_TAB:
|
||||
_toggle_controls()
|
||||
|
||||
|
||||
@@ -45,6 +68,78 @@ func _on_reset_pressed() -> void:
|
||||
_spawner.reset_spawn()
|
||||
|
||||
|
||||
func _build_ability_bar() -> void:
|
||||
var bar := HBoxContainer.new()
|
||||
bar.add_theme_constant_override("separation", 10)
|
||||
bar.anchor_left = 0.5
|
||||
bar.anchor_right = 0.5
|
||||
bar.anchor_top = 1.0
|
||||
bar.anchor_bottom = 1.0
|
||||
bar.grow_horizontal = Control.GROW_DIRECTION_BOTH
|
||||
bar.grow_vertical = Control.GROW_DIRECTION_BEGIN
|
||||
bar.offset_left = -120.0
|
||||
bar.offset_bottom = -20.0
|
||||
add_child(bar)
|
||||
for i: int in 3:
|
||||
bar.add_child(_build_ability_slot(i))
|
||||
|
||||
|
||||
func _build_ability_slot(idx: int) -> Control:
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 4)
|
||||
|
||||
var bg_style := StyleBoxFlat.new()
|
||||
bg_style.bg_color = _BG
|
||||
bg_style.corner_radius_top_left = 6
|
||||
bg_style.corner_radius_top_right = 6
|
||||
bg_style.corner_radius_bottom_left = 6
|
||||
bg_style.corner_radius_bottom_right = 6
|
||||
bg_style.border_width_left = 1
|
||||
bg_style.border_width_right = 1
|
||||
bg_style.border_width_top = 1
|
||||
bg_style.border_width_bottom = 1
|
||||
bg_style.border_color = _BORDER
|
||||
bg_style.content_margin_left = 4.0
|
||||
bg_style.content_margin_right = 4.0
|
||||
bg_style.content_margin_top = 4.0
|
||||
bg_style.content_margin_bottom = 4.0
|
||||
|
||||
var panel := PanelContainer.new()
|
||||
panel.custom_minimum_size = Vector2(72.0, 72.0)
|
||||
panel.add_theme_stylebox_override("panel", bg_style)
|
||||
vbox.add_child(panel)
|
||||
|
||||
var stack := Control.new()
|
||||
stack.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
panel.add_child(stack)
|
||||
|
||||
if ResourceLoader.exists(_ABILITY_ICONS[idx]):
|
||||
var icon := TextureRect.new()
|
||||
icon.texture = load(_ABILITY_ICONS[idx])
|
||||
icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
icon.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
stack.add_child(icon)
|
||||
|
||||
var cd_overlay := ColorRect.new()
|
||||
cd_overlay.color = Color(0.0, 0.0, 0.0, 0.70)
|
||||
cd_overlay.anchor_left = 0.0
|
||||
cd_overlay.anchor_right = 1.0
|
||||
cd_overlay.anchor_top = 1.0
|
||||
cd_overlay.anchor_bottom = 1.0
|
||||
cd_overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
stack.add_child(cd_overlay)
|
||||
_cd_overlays.append(cd_overlay)
|
||||
|
||||
var key_lbl := Label.new()
|
||||
key_lbl.text = _ABILITY_KEYS[idx]
|
||||
key_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
key_lbl.add_theme_color_override("font_color", _GOLD)
|
||||
key_lbl.add_theme_font_size_override("font_size", 12)
|
||||
vbox.add_child(key_lbl)
|
||||
|
||||
return vbox
|
||||
|
||||
|
||||
func _build_controls_panel() -> void:
|
||||
_controls_panel = PanelContainer.new()
|
||||
|
||||
@@ -81,10 +176,12 @@ func _build_controls_panel() -> void:
|
||||
_row(vbox, "WASD / Arrows", "Move (not intended)", _MUTED)
|
||||
_row(vbox, "LMB (hold)", "Right horn", _CREAM)
|
||||
_row(vbox, "RMB (hold)", "Left horn", _CREAM)
|
||||
_row(vbox, "LMB + RMB", "Bull charge", _CREAM)
|
||||
_row(vbox, "F", "Kick", _CREAM)
|
||||
_row(vbox, "G", "Slam", _CREAM)
|
||||
_row(vbox, "H", "Dash", _CREAM)
|
||||
_row(vbox, "Scroll", "Zoom", _CREAM)
|
||||
_row(vbox, "R", "Respawn matadors (cooldown)", _MUTED)
|
||||
_row(vbox, "H", "Toggle controls", _MUTED)
|
||||
_row(vbox, "Tab", "Toggle controls", _MUTED)
|
||||
|
||||
var sep := HSeparator.new()
|
||||
var sep_style := StyleBoxFlat.new()
|
||||
|
||||
Reference in New Issue
Block a user