Prueba de boss final
This commit is contained in:
1 parent
ac1d386143
commit
f414d43a37
6 files changed
+577
No files matched your search
@@ -0,0 +1,216 @@
|
||||
extends Node2D
|
||||
## Boss de prueba: tres fases y secuencias deterministas. Sin dependencias del arte final.
|
||||
signal died
|
||||
|
||||
const PHASE_HEALTH: int = 40
|
||||
const ARENA_LEFT: float = 3250.0
|
||||
const ARENA_RIGHT: float = 4200.0
|
||||
const FLOOR_Y: float = 1270.0
|
||||
const PATTERNS: Array = [
|
||||
["sweep", "scythe", "rest"],
|
||||
["sweep", "scythe", "runes", "rest"],
|
||||
["double_sweep", "scythe", "runes", "dash", "rest"],
|
||||
]
|
||||
|
||||
var is_dead: bool = false
|
||||
var phase: int = 0
|
||||
var current_health: int = PHASE_HEALTH
|
||||
var _started: bool = false
|
||||
var _step: int = 0
|
||||
var _state: String = "waiting"
|
||||
var _timer: float = 0.0
|
||||
var _elapsed: float = 0.0
|
||||
var _attack: String = ""
|
||||
var _target: Node2D
|
||||
var _facing: float = -1.0
|
||||
var _projectile_start: Vector2
|
||||
var _projectile_end: Vector2
|
||||
var _projectile_pos: Vector2
|
||||
var _runes: Array[float] = []
|
||||
var _hit_this_attack: bool = false
|
||||
var _next_sweep: int = 0
|
||||
var _dash_start: float = 0.0
|
||||
var _dash_end: float = 0.0
|
||||
|
||||
@onready var hurtbox: Area2D = $Hurtbox
|
||||
@onready var status: Label = $BossHUD/Panel/Rows/Status
|
||||
@onready var bars: HBoxContainer = $BossHUD/Panel/Rows/Bars
|
||||
|
||||
func _ready() -> void:
|
||||
visible = true
|
||||
_update_hud()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_elapsed += delta
|
||||
queue_redraw()
|
||||
if is_dead:
|
||||
return
|
||||
if not is_instance_valid(_target):
|
||||
_target = get_tree().get_first_node_in_group("player") as Node2D
|
||||
if not is_instance_valid(_target):
|
||||
return
|
||||
if not _started:
|
||||
if _target.global_position.x >= ARENA_LEFT and _target.global_position.y >= FLOOR_Y - 240.0:
|
||||
_started = true
|
||||
_state = "rest"
|
||||
_timer = 1.5
|
||||
$BossHUD.visible = true
|
||||
return
|
||||
if _state != "dash_active":
|
||||
_facing = 1.0 if _target.global_position.x > global_position.x else -1.0
|
||||
_timer -= delta
|
||||
match _state:
|
||||
"rest", "transition":
|
||||
if _timer <= 0.0:
|
||||
_begin_next_attack()
|
||||
"windup":
|
||||
if _timer <= 0.0:
|
||||
_begin_active()
|
||||
"active":
|
||||
_update_active(delta)
|
||||
if _timer <= 0.0:
|
||||
_end_attack()
|
||||
"dash_active":
|
||||
var t: float = clampf(1.0 - _timer / 0.45, 0.0, 1.0)
|
||||
global_position.x = lerpf(_dash_start, _dash_end, t)
|
||||
_damage_near(global_position + Vector2(0, 45), 92.0)
|
||||
if _timer <= 0.0:
|
||||
_end_attack()
|
||||
|
||||
func _begin_next_attack() -> void:
|
||||
var sequence: Array = PATTERNS[phase]
|
||||
_attack = sequence[_step % sequence.size()]
|
||||
_step += 1
|
||||
_hit_this_attack = false
|
||||
_next_sweep = 0
|
||||
if _attack == "rest":
|
||||
_state = "rest"
|
||||
_timer = maxf(0.65, 1.35 - phase * 0.23)
|
||||
return
|
||||
_facing = 1.0 if _target.global_position.x > global_position.x else -1.0
|
||||
if _attack == "runes":
|
||||
# Se anuncian antes de explotar; siempre dejan espacio seguro.
|
||||
_runes = [clampf(_target.global_position.x, ARENA_LEFT + 75, ARENA_RIGHT - 75)]
|
||||
_runes.append(clampf(_runes[0] + (210 if _runes[0] < 3750 else -210), ARENA_LEFT + 75, ARENA_RIGHT - 75))
|
||||
if _attack == "scythe":
|
||||
_projectile_start = Vector2(global_position.x, FLOOR_Y - 85)
|
||||
_projectile_end = Vector2(clampf(_target.global_position.x, ARENA_LEFT + 40, ARENA_RIGHT - 40), FLOOR_Y - 85)
|
||||
_projectile_pos = _projectile_start
|
||||
if _attack == "dash":
|
||||
_dash_start = global_position.x
|
||||
_dash_end = clampf(_target.global_position.x + _facing * 95.0, ARENA_LEFT + 90, ARENA_RIGHT - 90)
|
||||
_state = "windup"
|
||||
_timer = maxf(0.65, 0.95 - phase * 0.08)
|
||||
|
||||
func _begin_active() -> void:
|
||||
_state = "dash_active" if _attack == "dash" else "active"
|
||||
match _attack:
|
||||
"sweep": _timer = 0.38
|
||||
"double_sweep": _timer = 0.85
|
||||
"scythe": _timer = 1.25
|
||||
"runes": _timer = 0.38
|
||||
"dash": _timer = 0.45
|
||||
|
||||
func _update_active(_delta: float) -> void:
|
||||
match _attack:
|
||||
"sweep":
|
||||
_damage_near(global_position + Vector2(_facing * 95, 30), 115.0)
|
||||
"double_sweep":
|
||||
var second: bool = _timer < 0.42
|
||||
if second and _next_sweep == 0:
|
||||
_next_sweep = 1
|
||||
_hit_this_attack = false
|
||||
_damage_near(global_position + Vector2(_facing * (95 if not second else -95), 30), 110.0)
|
||||
"scythe":
|
||||
var t: float = 1.0 - _timer / 1.25
|
||||
_projectile_pos = _projectile_start.lerp(_projectile_end, 2.0 * t if t < 0.5 else 2.0 * (1.0 - t))
|
||||
# El retorno de la guadana tambien es peligroso.
|
||||
if _target.global_position.distance_to(_projectile_pos) < 62.0:
|
||||
_hurt_player()
|
||||
"runes":
|
||||
for x: float in _runes:
|
||||
if absf(_target.global_position.x - x) < 65.0 and _target.global_position.y > FLOOR_Y - 160.0:
|
||||
_hurt_player()
|
||||
|
||||
func _end_attack() -> void:
|
||||
_state = "rest"
|
||||
_timer = maxf(0.55, 0.92 - phase * 0.12)
|
||||
_runes.clear()
|
||||
|
||||
func _damage_near(center: Vector2, radius: float) -> void:
|
||||
if _target.global_position.distance_to(center) <= radius:
|
||||
_hurt_player()
|
||||
|
||||
func _hurt_player() -> void:
|
||||
if not _hit_this_attack and _target.has_method("take_damage") and not bool(_target.get("is_dead")):
|
||||
_hit_this_attack = true
|
||||
_target.call("take_damage", [6, 8, 10][phase], global_position, 0.85)
|
||||
|
||||
func take_damage(amount: int, _source_position: Vector2) -> void:
|
||||
if is_dead or not _started or _state == "transition" or amount <= 0:
|
||||
return
|
||||
current_health = maxi(0, current_health - amount)
|
||||
if current_health == 0:
|
||||
if phase == 2:
|
||||
is_dead = true
|
||||
_state = "dead"
|
||||
$Hurtbox.set_deferred("monitorable", false)
|
||||
$BossHUD.visible = false
|
||||
died.emit()
|
||||
else:
|
||||
phase += 1
|
||||
current_health = PHASE_HEALTH
|
||||
_step = 0
|
||||
_state = "transition"
|
||||
_timer = 2.0
|
||||
_runes.clear()
|
||||
_update_hud()
|
||||
|
||||
func _update_hud() -> void:
|
||||
if not is_node_ready():
|
||||
return
|
||||
status.text = "LA MUERTE ESPECTRAL - FASE %d / 3" % (phase + 1)
|
||||
for i: int in range(3):
|
||||
var bar: ProgressBar = bars.get_child(i) as ProgressBar
|
||||
bar.value = 0 if i < phase else (current_health if i == phase else PHASE_HEALTH)
|
||||
|
||||
func _draw() -> void:
|
||||
if is_dead:
|
||||
# Disolucion del manto tras la derrota.
|
||||
var a: float = 0.4 + 0.2 * sin(_elapsed * 9.0)
|
||||
draw_circle(Vector2.ZERO, 52.0, Color(0.5, 0.15, 0.7, a))
|
||||
return
|
||||
var bob: float = sin(_elapsed * 2.6) * 8.0
|
||||
var robe: Color = Color(0.14, 0.10, 0.25)
|
||||
var glow: Color = Color(0.66, 0.32, 0.95) if phase == 0 else (Color(1, 0.45, 0.2) if phase == 1 else Color(1, 0.12, 0.25))
|
||||
# Aura, capa, capucha, craneo, ojos y guadana: arte vectorial provisional animado.
|
||||
draw_circle(Vector2(0, bob), 94, Color(glow.r, glow.g, glow.b, 0.10 + 0.04 * sin(_elapsed * 5)))
|
||||
draw_colored_polygon(PackedVector2Array([Vector2(-50, -45 + bob), Vector2(43, -46 + bob), Vector2(80, 110 + bob), Vector2(-80, 110 + bob)]), robe)
|
||||
draw_colored_polygon(PackedVector2Array([Vector2(-50, -42 + bob), Vector2(0, -109 + bob), Vector2(50, -42 + bob), Vector2(43, 18 + bob), Vector2(-45, 18 + bob)]), Color(0.08, 0.065, 0.13))
|
||||
draw_circle(Vector2(0, -48 + bob), 30, Color(0.72, 0.73, 0.69))
|
||||
draw_colored_polygon(PackedVector2Array([Vector2(-22, -37 + bob), Vector2(21, -37 + bob), Vector2(14, -14 + bob), Vector2(-12, -14 + bob)]), Color(0.72, 0.73, 0.69))
|
||||
draw_circle(Vector2(-12, -50 + bob), 7, glow)
|
||||
draw_circle(Vector2(12, -50 + bob), 7, glow)
|
||||
draw_line(Vector2(47, -64 + bob), Vector2(86, 95 + bob), Color(0.64, 0.67, 0.72), 7)
|
||||
draw_arc(Vector2(78, -68 + bob), 53, -2.4, 0.5, 22, Color(0.82, 0.9, 0.93), 10)
|
||||
if _state == "transition":
|
||||
draw_arc(Vector2(0, bob), 112, 0, TAU, 48, glow, 6)
|
||||
if _state == "windup":
|
||||
match _attack:
|
||||
"sweep", "double_sweep":
|
||||
draw_rect(Rect2(Vector2(_facing * 35 if _facing > 0 else -245, 0), Vector2(210, 100)), Color(1, 0.25, 0.22, 0.28))
|
||||
"scythe":
|
||||
draw_line(to_local(_projectile_start), to_local(_projectile_end), Color(0.95, 0.35, 0.95, 0.8), 5)
|
||||
"runes":
|
||||
for x: float in _runes:
|
||||
draw_rect(Rect2(to_local(Vector2(x - 65, FLOOR_Y - 17)), Vector2(130, 17)), Color(1, 0.2, 0.2, 0.65))
|
||||
"dash":
|
||||
draw_line(Vector2.ZERO, Vector2(_dash_end - global_position.x, 0), glow, 7)
|
||||
if _state == "active":
|
||||
if _attack == "scythe":
|
||||
draw_arc(to_local(_projectile_pos), 34, _elapsed * 12, _elapsed * 12 + 4.7, 18, Color(0.8, 0.9, 1), 9)
|
||||
elif _attack == "runes":
|
||||
for x: float in _runes:
|
||||
draw_rect(Rect2(to_local(Vector2(x - 65, FLOOR_Y - 170)), Vector2(130, 170)), Color(1, 0.2, 0.2, 0.45))
|
||||
elif _attack == "sweep" or _attack == "double_sweep":
|
||||
draw_arc(Vector2(_facing * 55, bob), 118, -1.1, 1.1, 22, glow, 13)
|
||||
@@ -0,0 +1,58 @@
|
||||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://bosses/spectral_death/spectral_death.gd" id="boss"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="hurt_shape"]
|
||||
size = Vector2(118, 204)
|
||||
|
||||
[node name="SpectralDeath" type="Node2D" groups=["enemy"]]
|
||||
script = ExtResource("boss")
|
||||
z_index = 5
|
||||
|
||||
[node name="Hurtbox" type="Area2D" parent="."]
|
||||
collision_layer = 16
|
||||
collision_mask = 0
|
||||
monitoring = false
|
||||
monitorable = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox"]
|
||||
shape = SubResource("hurt_shape")
|
||||
|
||||
[node name="BossHUD" type="CanvasLayer" parent="."]
|
||||
visible = false
|
||||
layer = 3
|
||||
|
||||
[node name="Panel" type="PanelContainer" parent="BossHUD"]
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_left = 64.0
|
||||
offset_top = 22.0
|
||||
offset_right = -64.0
|
||||
offset_bottom = 82.0
|
||||
|
||||
[node name="Rows" type="VBoxContainer" parent="BossHUD/Panel"]
|
||||
|
||||
[node name="Status" type="Label" parent="BossHUD/Panel/Rows"]
|
||||
text = "LA MUERTE ESPECTRAL"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Bars" type="HBoxContainer" parent="BossHUD/Panel/Rows"]
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="Life1" type="ProgressBar" parent="BossHUD/Panel/Rows/Bars"]
|
||||
size_flags_horizontal = 3
|
||||
max_value = 40.0
|
||||
value = 40.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="Life2" type="ProgressBar" parent="BossHUD/Panel/Rows/Bars"]
|
||||
size_flags_horizontal = 3
|
||||
max_value = 40.0
|
||||
value = 40.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="Life3" type="ProgressBar" parent="BossHUD/Panel/Rows/Bars"]
|
||||
size_flags_horizontal = 3
|
||||
max_value = 40.0
|
||||
value = 40.0
|
||||
show_percentage = false
|
||||
Reference in new issue
Block a user