forked from team-sg/hero-mark-2
starting work on final boss fight
This commit is contained in:
parent
34a466ae71
commit
6888928fbb
8 changed files with 222 additions and 96 deletions
84
objects/enemy/boss/famira.gd
Normal file
84
objects/enemy/boss/famira.gd
Normal file
|
@ -0,0 +1,84 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
export var decisions: Dictionary = {
|
||||
"wait": 2,
|
||||
"chase": 3,
|
||||
"punch": 3,
|
||||
"beam": 1,
|
||||
}
|
||||
export var wait_time: float = 1.0
|
||||
export var chase_speed: float = 50.0
|
||||
|
||||
|
||||
var rng := RandomNumberGenerator.new()
|
||||
var current_action: String = "wait"
|
||||
|
||||
|
||||
onready var punch_cast: RayCast2D = $PunchCast
|
||||
onready var chase_cast: RayCast2D = $ChaseCast
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
rng.seed = "HEROMARK2".hash()
|
||||
_decide_action()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
match current_action:
|
||||
"chase":
|
||||
if chase_cast.is_colliding():
|
||||
print("huh")
|
||||
_decide_action()
|
||||
else:
|
||||
print("hehe")
|
||||
position.x -= chase_speed * delta
|
||||
|
||||
|
||||
func _decide_action() -> void:
|
||||
# fill array based on weights
|
||||
var weighted_decisions := []
|
||||
for k in decisions.keys():
|
||||
for i in decisions[k]:
|
||||
weighted_decisions.append(k)
|
||||
# choose an action
|
||||
current_action = weighted_decisions[rng.randi() % weighted_decisions.size()]
|
||||
# act based on new action
|
||||
match current_action:
|
||||
"wait":
|
||||
wait()
|
||||
"chase":
|
||||
chase()
|
||||
"punch":
|
||||
if punch_cast.is_colliding():
|
||||
punch()
|
||||
else:
|
||||
current_action = "chase"
|
||||
chase()
|
||||
"beam":
|
||||
beam()
|
||||
|
||||
|
||||
func wait() -> void:
|
||||
print("waiting")
|
||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
||||
_decide_action()
|
||||
|
||||
|
||||
func chase() -> void:
|
||||
# TODO: play animation
|
||||
print("chasing")
|
||||
|
||||
|
||||
func punch() -> void:
|
||||
# TODO: play animation
|
||||
print("PUNCH")
|
||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
||||
_decide_action()
|
||||
|
||||
|
||||
func beam() -> void:
|
||||
# TODO: play animation and stuff
|
||||
print("BEAM")
|
||||
yield(get_tree().create_timer(wait_time, false), "timeout")
|
||||
_decide_action()
|
36
objects/enemy/boss/famira.tscn
Normal file
36
objects/enemy/boss/famira.tscn
Normal file
|
@ -0,0 +1,36 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://objects/enemy/boss/famira.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/enemy/boss/famira-wip.png" type="Texture" id=2]
|
||||
[ext_resource path="res://shaders/beam_cycle.gdshader" type="Shader" id=3]
|
||||
[ext_resource path="res://graphics/enemy/boss/stg_2600/beam_gradient.png" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=10]
|
||||
shader = ExtResource( 3 )
|
||||
shader_param/cycle_speed = 1.0
|
||||
shader_param/gradient = ExtResource( 4 )
|
||||
|
||||
[node name="Famira" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 10 )
|
||||
position = Vector2( 23, -83 )
|
||||
texture = ExtResource( 2 )
|
||||
flip_h = true
|
||||
|
||||
[node name="PunchCast" type="RayCast2D" parent="."]
|
||||
position = Vector2( 0, -32 )
|
||||
enabled = true
|
||||
cast_to = Vector2( -120, 0 )
|
||||
collision_mask = 4
|
||||
collide_with_areas = true
|
||||
collide_with_bodies = false
|
||||
|
||||
[node name="ChaseCast" type="RayCast2D" parent="."]
|
||||
position = Vector2( 0, -16 )
|
||||
enabled = true
|
||||
cast_to = Vector2( -80, 0 )
|
||||
collision_mask = 4
|
||||
collide_with_areas = true
|
||||
collide_with_bodies = false
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=37 format=2]
|
||||
[gd_scene load_steps=38 format=2]
|
||||
|
||||
[ext_resource path="res://shaders/color_noise.gdshader" type="Shader" id=1]
|
||||
[ext_resource path="res://graphics/enemy/boss/stg_2600/tailpipes.png" type="Texture" id=2]
|
||||
|
@ -1018,10 +1018,10 @@ tracks/6/keys = {
|
|||
"times": PoolRealArray( 0, 0.25, 0.5, 0.75, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 51.0254, 203.4, 223.8, -3444.5, 51.0254 ]
|
||||
"values": [ 51.0254, 23.4, 43.8, 55.0, 51.0254 ]
|
||||
}
|
||||
tracks/7/type = "value"
|
||||
tracks/7/path = NodePath("Axle/JointBack/LegBack/KneeBack:rotation_degrees")
|
||||
tracks/7/path = NodePath("Axle/JointBack/LegBack:rotation_degrees")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/imported = false
|
||||
|
@ -1030,18 +1030,6 @@ tracks/7/keys = {
|
|||
"times": PoolRealArray( 0, 0.25, 0.5, 0.75, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0.0, -180.0, -180.0, 3510.0, 0.0 ]
|
||||
}
|
||||
tracks/8/type = "value"
|
||||
tracks/8/path = NodePath("Axle/JointBack/LegBack:rotation_degrees")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/imported = false
|
||||
tracks/8/enabled = true
|
||||
tracks/8/keys = {
|
||||
"times": PoolRealArray( 0, 0.25, 0.5, 0.75, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ -26.8344, -19.6257, -38.4223, -35.1608, -26.8344 ]
|
||||
}
|
||||
|
||||
|
@ -1303,7 +1291,10 @@ tracks/1/keys = {
|
|||
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0.833333 ), Color( 1, 1, 1, 0.666667 ), Color( 1, 1, 1, 0.5 ), Color( 1, 1, 1, 0.333333 ), Color( 1, 1, 1, 0.166667 ), Color( 1, 1, 1, 0 ) ]
|
||||
}
|
||||
|
||||
[node name="2600" type="Node2D"]
|
||||
[sub_resource type="RectangleShape2D" id=26]
|
||||
extents = Vector2( 33.5, 76 )
|
||||
|
||||
[node name="2083" type="Node2D"]
|
||||
script = ExtResource( 19 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ 168.0, 128.0, 157.0 ],
|
||||
|
@ -1326,7 +1317,7 @@ position = Vector2( 42, 78 )
|
|||
scale = Vector2( -1, 1 )
|
||||
|
||||
[node name="JointBack" type="Sprite" parent="Axle"]
|
||||
modulate = Color( 0.75, 0.75, 0.75, 1 )
|
||||
modulate = Color( 0.74902, 0.74902, 0.74902, 1 )
|
||||
position = Vector2( -10, -4 )
|
||||
z_index = -1
|
||||
texture = ExtResource( 7 )
|
||||
|
@ -1380,12 +1371,10 @@ __meta__ = {
|
|||
"_gizmo_extents_": 4.0
|
||||
}
|
||||
|
||||
[node name="KneeBack" type="Sprite" parent="Axle/JointBack/LegBack/KneeBack"]
|
||||
texture = ExtResource( 8 )
|
||||
hframes = 8
|
||||
script = ExtResource( 10 )
|
||||
fps = 4.0
|
||||
rotation_lock = 0.0
|
||||
[node name="KneeGraphic" type="RemoteTransform2D" parent="Axle/JointBack/LegBack/KneeBack"]
|
||||
remote_path = NodePath("../../../../KneeBack")
|
||||
update_rotation = false
|
||||
update_scale = false
|
||||
|
||||
[node name="Head" type="Sprite" parent="Axle"]
|
||||
unique_name_in_owner = true
|
||||
|
@ -1545,15 +1534,15 @@ scale = Vector2( 1, -1 )
|
|||
|
||||
[node name="Position1" type="Position2D" parent="Axle/Head/BulletPositions"]
|
||||
position = Vector2( 6.08833, 2.28882e-05 )
|
||||
rotation = 3.14159
|
||||
rotation = 2.87979
|
||||
|
||||
[node name="Position2" type="Position2D" parent="Axle/Head/BulletPositions"]
|
||||
position = Vector2( 6.08832, 8.00003 )
|
||||
rotation = 3.57792
|
||||
rotation = 3.14159
|
||||
|
||||
[node name="Position3" type="Position2D" parent="Axle/Head/BulletPositions"]
|
||||
position = Vector2( 6.08832, 16 )
|
||||
rotation = 4.01426
|
||||
rotation = 3.40339
|
||||
|
||||
[node name="JointFront" type="Sprite" parent="Axle"]
|
||||
position = Vector2( 11, -4 )
|
||||
|
@ -1605,8 +1594,26 @@ __meta__ = {
|
|||
"_gizmo_extents_": 4.0
|
||||
}
|
||||
|
||||
[node name="KneeFront" type="Sprite" parent="Axle/JointFront/LegFront"]
|
||||
position = Vector2( 3.8147e-06, 36 )
|
||||
[node name="KneeGraphic" type="RemoteTransform2D" parent="Axle/JointFront/LegFront"]
|
||||
position = Vector2( 7.62939e-06, 36 )
|
||||
remote_path = NodePath("../../../KneeFront")
|
||||
update_rotation = false
|
||||
update_scale = false
|
||||
|
||||
[node name="KneeBack" type="Sprite" parent="Axle"]
|
||||
modulate = Color( 0.74902, 0.74902, 0.74902, 1 )
|
||||
position = Vector2( 6.25089, 28.1233 )
|
||||
scale = Vector2( 1, -1 )
|
||||
z_index = -1
|
||||
texture = ExtResource( 8 )
|
||||
hframes = 8
|
||||
script = ExtResource( 10 )
|
||||
fps = 4.0
|
||||
ping_pong = true
|
||||
rotation_lock = 0.0
|
||||
|
||||
[node name="KneeFront" type="Sprite" parent="Axle"]
|
||||
position = Vector2( 27.2509, 28.1233 )
|
||||
texture = ExtResource( 8 )
|
||||
hframes = 8
|
||||
script = ExtResource( 10 )
|
||||
|
@ -1630,5 +1637,14 @@ __meta__ = {
|
|||
anims/RESET = SubResource( 17 )
|
||||
anims/explode = SubResource( 18 )
|
||||
|
||||
[node name="DetectionBox" type="Area2D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DetectionBox"]
|
||||
position = Vector2( 53.5, 92 )
|
||||
shape = SubResource( 26 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_finished"]
|
||||
[connection signal="area_entered" from="Axle/Head/Beam/Hitbox" to="." method="_on_Hitbox_area_entered"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue