From 1299860e1fcc90ef2bb130deb329c65a9d5e56ba Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Mon, 20 Apr 2020 22:26:45 +0200 Subject: [PATCH] Mostly fixed --- src/Autoloads/Globals.gd | 3 +++ src/Boss/SlimeBoss/SlimeBoss.tscn | 25 ++++++++++----------- src/Boss/SlimeBoss/SlimeBossStateMachine.gd | 8 +++---- src/Boss/SlimeBoss/States/Charge/Sprint.gd | 3 ++- src/Overlap/AI/AI_Hero.gd | 2 +- src/Player/Player.gd | 1 + src/Player/Player.tscn | 3 --- src/World.gd | 1 + src/World.tscn | 12 +++++----- src/project.godot | 1 + 10 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 src/Autoloads/Globals.gd diff --git a/src/Autoloads/Globals.gd b/src/Autoloads/Globals.gd new file mode 100644 index 0000000..6d51fad --- /dev/null +++ b/src/Autoloads/Globals.gd @@ -0,0 +1,3 @@ +extends Node + +var player_node = null diff --git a/src/Boss/SlimeBoss/SlimeBoss.tscn b/src/Boss/SlimeBoss/SlimeBoss.tscn index dec440c..08412c1 100644 --- a/src/Boss/SlimeBoss/SlimeBoss.tscn +++ b/src/Boss/SlimeBoss/SlimeBoss.tscn @@ -31,7 +31,6 @@ height = 50.0 radius = 13.0 height = 30.0 - [sub_resource type="CapsuleShape2D" id=3] radius = 20.0 height = 30.0 @@ -420,7 +419,7 @@ tracks/5/keys = { "values": [ 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ] } -[sub_resource type="Animation" id=15] +[sub_resource type="Animation" id=10] resource_name = "Die" length = 0.6 step = 0.025 @@ -509,7 +508,7 @@ tracks/6/keys = { "values": [ Vector2( 1, 1 ), Vector2( 1e-05, 1e-05 ) ] } -[sub_resource type="Animation" id=10] +[sub_resource type="Animation" id=11] length = 1.9 step = 0.025 tracks/0/type = "value" @@ -585,7 +584,7 @@ tracks/5/keys = { "values": [ 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ] } -[sub_resource type="Animation" id=11] +[sub_resource type="Animation" id=12] length = 2.66666 step = 0.0111111 tracks/0/type = "value" @@ -661,7 +660,7 @@ tracks/5/keys = { "values": [ false ] } -[sub_resource type="Animation" id=12] +[sub_resource type="Animation" id=13] length = 1.28333 step = 0.0166667 tracks/0/type = "value" @@ -737,7 +736,7 @@ tracks/5/keys = { "values": [ true ] } -[sub_resource type="Animation" id=13] +[sub_resource type="Animation" id=14] length = 1.28333 step = 0.0166667 tracks/0/type = "value" @@ -813,7 +812,7 @@ tracks/5/keys = { "values": [ false ] } -[sub_resource type="Animation" id=14] +[sub_resource type="Animation" id=15] length = 1.28333 step = 0.0166667 tracks/0/type = "value" @@ -1047,12 +1046,12 @@ anims/ChargeLeft = SubResource( 6 ) anims/ChargeRight = SubResource( 7 ) anims/ChargeUp = SubResource( 8 ) anims/Charging = SubResource( 9 ) -anims/Die = SubResource( 15 ) -anims/FightStart = SubResource( 10 ) -anims/MoveDown = SubResource( 11 ) -anims/MoveLeft = SubResource( 12 ) -anims/MoveRight = SubResource( 13 ) -anims/MoveUp = SubResource( 14 ) +anims/Die = SubResource( 10 ) +anims/FightStart = SubResource( 11 ) +anims/MoveDown = SubResource( 12 ) +anims/MoveLeft = SubResource( 13 ) +anims/MoveRight = SubResource( 14 ) +anims/MoveUp = SubResource( 15 ) anims/__INIT__ = SubResource( 16 ) [connection signal="animation_finished" from="Effects/StompEffect" to="States/Stomp" method="_on_StompEffect_animation_finished"] [connection signal="health_changed" from="Stats" to="." method="_on_Stats_health_changed"] diff --git a/src/Boss/SlimeBoss/SlimeBossStateMachine.gd b/src/Boss/SlimeBoss/SlimeBossStateMachine.gd index f2adad6..a1b77ee 100644 --- a/src/Boss/SlimeBoss/SlimeBossStateMachine.gd +++ b/src/Boss/SlimeBoss/SlimeBossStateMachine.gd @@ -66,10 +66,10 @@ func go_to_next_state(state_override=null): state_active = state_override else: state_active = _decide_on_next_state() + if state_active != null: + emit_signal("state_changed", state_active.name) - emit_signal("state_changed", state_active.name) - - state_active.enter() + state_active.enter() func _change_phase(new_phase): set_invincible(true) @@ -101,7 +101,7 @@ func _decide_on_next_state(): # Death if state_active == $States/Die: queue_free() - # return $States/Dead + return $States/Dead if _phase == PHASES.PHASE_ONE: if angry_phases_done < 1: diff --git a/src/Boss/SlimeBoss/States/Charge/Sprint.gd b/src/Boss/SlimeBoss/States/Charge/Sprint.gd index befd4eb..cdf46dd 100644 --- a/src/Boss/SlimeBoss/States/Charge/Sprint.gd +++ b/src/Boss/SlimeBoss/States/Charge/Sprint.gd @@ -1,11 +1,12 @@ extends "res://Boss/SlimeBoss/States/BossState.gd" + export(float) var SPEED = 300.0 var direction = Vector2() func enter(): - var player_pos = owner.get_parent().get_node("Player").global_position + var player_pos = Globals.player_node.global_position direction = (player_pos - owner.global_position).normalized() func exit(): diff --git a/src/Overlap/AI/AI_Hero.gd b/src/Overlap/AI/AI_Hero.gd index 899b3a3..36670e4 100644 --- a/src/Overlap/AI/AI_Hero.gd +++ b/src/Overlap/AI/AI_Hero.gd @@ -150,7 +150,7 @@ func movement_decider_ai(target, kindOfStep, delta): var currentPixel = global_position var hitPixelTarget = is_hittable() - if hitPixelTarget!=null && randf()<0.5: + if hitPixelTarget!=null && randf()<1: hit_or_miss(hitPixelTarget, currentPixel, delta*4) else: if(kindOfStep==STEP): diff --git a/src/Player/Player.gd b/src/Player/Player.gd index 105a31e..3c0176d 100644 --- a/src/Player/Player.gd +++ b/src/Player/Player.gd @@ -46,6 +46,7 @@ func _debug_update(): func _ready(): grid = get_tree().current_scene.get_node("Grid") + Globals.player_node = self func _physics_process(delta): diff --git a/src/Player/Player.tscn b/src/Player/Player.tscn index f01ba52..d5c119f 100644 --- a/src/Player/Player.tscn +++ b/src/Player/Player.tscn @@ -632,11 +632,8 @@ font_data = ExtResource( 6 ) scale = Vector2( 2, 2 ) collision_mask = 14 script = ExtResource( 1 ) -debug = null ROLL_SPEED = 120 FRICTION = 270 -ACCELERATION = null -title_scene = null [node name="Kind" parent="." instance=ExtResource( 7 )] general = 4 diff --git a/src/World.gd b/src/World.gd index 79d34dd..d6eb45f 100644 --- a/src/World.gd +++ b/src/World.gd @@ -40,6 +40,7 @@ func hero_has_died(): func spawn_new_hero(x:float,y:float): var hero = HeroTemplate.instance() hero.position=Vector2(x,y) + hero.name = "Player" $YSort.add_child(hero) diff --git a/src/World.tscn b/src/World.tscn index ad2d176..355c217 100644 --- a/src/World.tscn +++ b/src/World.tscn @@ -3,11 +3,11 @@ [ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://World.gd" type="Script" id=2] [ext_resource path="res://Maps/Tilesets/Room/tileset_room.tres" type="TileSet" id=3] +[ext_resource path="res://Menus/SelectUpgradeUI/SelectUpgradeUI.tscn" type="PackedScene" id=4] [ext_resource path="res://Menus/DragNDrop/DragNDropUI.tscn" type="PackedScene" id=5] [ext_resource path="res://Menus/DialogueBox/DialogueBox.tscn" type="PackedScene" id=6] [ext_resource path="res://Maps/Background/Background.tscn" type="PackedScene" id=7] [ext_resource path="res://Boss/SlimeBoss/SlimeBoss.tscn" type="PackedScene" id=8] -[ext_resource path="res://Menus/SelectUpgradeUI/SelectUpgradeUI.tscn" type="PackedScene" id=19] [ext_resource path="res://Fonts/Harmonic/Harmonic12.tres" type="DynamicFont" id=9] [ext_resource path="res://Objects/Bonfire/Bonfire.tscn" type="PackedScene" id=10] [ext_resource path="res://Debug/BossStateDisplay.gd" type="Script" id=11] @@ -247,7 +247,6 @@ pause_mode = 1 frame = 20 playing = false - [node name="FloorTileMap" type="TileMap" parent="."] pause_mode = 1 position = Vector2( 16, 16 ) @@ -258,7 +257,6 @@ collision_mask = 0 format = 1 tile_data = PoolIntArray( -131074, 47, 0, -131073, 47, 1, -196608, 47, 1, -196607, 47, 1, -196606, 47, 1, -196605, 47, 1, -196604, 47, 1, -196603, 47, 1, -196602, 47, 1, -196601, 47, 1, -196600, 47, 1, -196599, 47, 1, -196598, 47, 1, -196597, 47, 1, -196596, 47, 1, -196595, 47, 1, -196594, 47, 1, -196593, 47, 1, -196592, 47, 2, -65538, 47, 65536, -65537, 47, 65537, -131072, 47, 65537, -131071, 47, 65537, -131070, 47, 65537, -131069, 47, 65537, -131068, 47, 65537, -131067, 47, 65537, -131066, 47, 65537, -131065, 47, 65537, -131064, 47, 65537, -131063, 47, 65537, -131062, 47, 65537, -131061, 47, 65537, -131060, 47, 65537, -131059, 47, 65537, -131058, 47, 65537, -131057, 47, 65537, -131056, 47, 65538, -2, 47, 65536, -1, 47, 65541, -65536, 47, 131073, -65535, 47, 131073, -65534, 47, 131073, -65533, 47, 131073, -65532, 47, 131073, -65531, 47, 131073, -65530, 47, 131073, -65529, 47, 131073, -65528, 47, 131073, -65527, 47, 131073, -65526, 47, 131073, -65525, 47, 131073, -65524, 47, 131073, -65523, 47, 131073, -65522, 47, 65542, -65521, 47, 65537, -65520, 47, 65538, 65534, 47, 65536, 65535, 47, 65538, 14, 47, 65536, 15, 47, 65537, 16, 47, 65538, 131070, 47, 65536, 131071, 47, 65538, 65550, 47, 65536, 65551, 47, 65537, 65552, 47, 65538, 196606, 47, 65536, 196607, 47, 65538, 131086, 47, 65536, 131087, 47, 65537, 131088, 47, 65538, 262142, 47, 65536, 262143, 47, 65538, 196622, 47, 65536, 196623, 47, 65537, 196624, 47, 65538, 327678, 47, 65536, 327679, 47, 65538, 262158, 47, 65536, 262159, 47, 65537, 262160, 47, 65538, 393214, 47, 65536, 393215, 47, 65538, 327694, 47, 65536, 327695, 47, 65537, 327696, 47, 65538, 458750, 47, 65536, 458751, 47, 131077, 393216, 47, 1, 393217, 47, 1, 393218, 47, 1, 393219, 47, 1, 393220, 47, 1, 393221, 47, 1, 393222, 47, 1, 393223, 47, 1, 393224, 47, 1, 393225, 47, 1, 393226, 47, 1, 393227, 47, 1, 393228, 47, 1, 393229, 47, 1, 393230, 47, 131078, 393231, 47, 65537, 393232, 47, 65538, 524286, 47, 65536, 524287, 47, 65537, 458752, 47, 65537, 458753, 47, 65537, 458754, 47, 65537, 458755, 47, 65537, 458756, 47, 65537, 458757, 47, 65537, 458758, 47, 65537, 458759, 47, 65537, 458760, 47, 65537, 458761, 47, 65537, 458762, 47, 65537, 458763, 47, 65537, 458764, 47, 65537, 458765, 47, 65537, 458766, 47, 65537, 458767, 47, 65537, 458768, 47, 65538, 589822, 47, 65536, 589823, 47, 65537, 524288, 47, 65537, 524289, 47, 65537, 524290, 47, 65537, 524291, 47, 65537, 524292, 47, 65537, 524293, 47, 65537, 524294, 47, 65537, 524295, 47, 65537, 524296, 47, 65537, 524297, 47, 65537, 524298, 47, 65537, 524299, 47, 65537, 524300, 47, 65537, 524301, 47, 65537, 524302, 47, 65537, 524303, 47, 65537, 524304, 47, 65538, 655358, 47, 131072, 655359, 47, 131073, 589824, 47, 131073, 589825, 47, 131073, 589826, 47, 131073, 589827, 47, 131073, 589828, 47, 131073, 589829, 47, 131073, 589830, 47, 131073, 589831, 47, 131073, 589832, 47, 131073, 589833, 47, 131073, 589834, 47, 131073, 589835, 47, 131073, 589836, 47, 131073, 589837, 47, 131073, 589838, 47, 131073, 589839, 47, 131073, 589840, 47, 131074 ) - [node name="Edge" type="TileMap" parent="."] position = Vector2( 16, 16 ) tile_set = SubResource( 9 ) @@ -337,7 +335,7 @@ margin_top = 0.463304 margin_right = 0.0 margin_bottom = 0.463318 -[node name="SelectUpgradeUI" parent="CanvasLayer" instance=ExtResource( 9 )] +[node name="SelectUpgradeUI" parent="CanvasLayer" instance=ExtResource( 4 )] visible = false [node name="Win" type="Button" parent="CanvasLayer"] @@ -347,8 +345,10 @@ anchor_right = 1.0 margin_left = -42.0 margin_bottom = 24.0 text = "Win" +[connection signal="phase_changed" from="YSort/SlimeBoss" to="CanvasLayer/DebugLabel/BossStateDisplay" method="_on_SlimeBoss_phase_changed"] +[connection signal="state_changed" from="YSort/SlimeBoss" to="CanvasLayer/DebugLabel/BossStateDisplay" method="_on_SlimeBoss_state_changed"] [connection signal="pressed" from="CanvasLayer/Win" to="." method="_on_Win_pressed"] -[editable path="CanvasLayer/DragNDropUI"] +[editable path="YSort/SlimeBoss"] -[editable path="CanvasLayer/SelectUpgradeUI"] +[editable path="CanvasLayer/DragNDropUI"] diff --git a/src/project.godot b/src/project.godot index 88cddfa..bac0780 100644 --- a/src/project.godot +++ b/src/project.godot @@ -64,6 +64,7 @@ config/icon="res://icon.png" SoundControler="*res://Autoloads/SoundControler.gd" Steering="*res://Autoloads/Steering.gd" +Globals="*res://Autoloads/Globals.gd" [display]