From 1297c1e76aa7a3fbb81ecf46828f8d4f15a97ef4 Mon Sep 17 00:00:00 2001 From: Victor Turgeon Date: Wed, 11 Oct 2023 04:32:53 -0400 Subject: [PATCH 1/3] Blud gen --- Assets/Sprite-0001.png | Bin 0 -> 512 bytes Assets/Sprite-0001.png.import | 34 ++++++++++++ Scenes/Player/UI/cursor_state.gd | 3 + Scenes/Player/UI/player_ui.gd | 13 ++++- Scenes/Player/UI/player_ui.tscn | 70 ++++++++++++++++++++++-- Scenes/Player/UI/spawnable_button.gd | 10 ++++ Scenes/Player/player.gd | 41 +++++++++++--- Scenes/Spawnables/template_spawnable.gd | 2 +- Themes/base_theme.tres | 1 - 9 files changed, 159 insertions(+), 15 deletions(-) create mode 100644 Assets/Sprite-0001.png create mode 100644 Assets/Sprite-0001.png.import diff --git a/Assets/Sprite-0001.png b/Assets/Sprite-0001.png new file mode 100644 index 0000000000000000000000000000000000000000..c13a14273569f0dd741f25efa085fd6ba9de56be GIT binary patch literal 512 zcmV+b0{{JqP)Px$x=BPqRCt{2nn7;DFc3vQ^{NX?>~o78fP3_Wy+;nfE!ZP@(N&ag63emT5{PGp z%Ku4~Km~jJ{bw?900<$35JGI2=07t&EGK^lPKI+&U*|Ib;QM|zi=}x7PynNOr_QzyWjk`oC0bbtyt?x*>K-2*> zc2L>{%{M|4)%B&yUqbqd(7Xdg1gN$9=@?SAfDWiU-s-@!7Lo_2bbxgL)=&VcftTy| zyN#7oTY%HttN^GJcsjZJd(F)q^|N@njZV Date: Wed, 11 Oct 2023 04:37:40 -0400 Subject: [PATCH 2/3] enemy occlusion --- Scenes/Levels/level_1.tscn | 4 ++-- Scenes/Spawnables/bat_spawnable.tscn | 2 +- Scenes/enemy.tscn | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Scenes/Levels/level_1.tscn b/Scenes/Levels/level_1.tscn index 075e004..d01a215 100644 --- a/Scenes/Levels/level_1.tscn +++ b/Scenes/Levels/level_1.tscn @@ -2,8 +2,8 @@ [ext_resource type="Script" path="res://Scripts/level.gd" id="1_0nmok"] [ext_resource type="PackedScene" uid="uid://b8s2seg2lf7wo" path="res://Scenes/Tilemaps/tileset_1.tscn" id="1_4n82n"] -[ext_resource type="PackedScene" uid="uid://dgtscjxcqoxls" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"] -[ext_resource type="PackedScene" uid="uid://cf7al5uln33rn" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"] +[ext_resource type="PackedScene" uid="uid://cl7w6ndvons1a" path="res://Scenes/Props/candle_1.tscn" id="2_5hdq4"] +[ext_resource type="PackedScene" uid="uid://by2xmwcng01uy" path="res://Scenes/Props/candle_2.tscn" id="2_o33c4"] [ext_resource type="PackedScene" uid="uid://b5lnjonlf4i1b" path="res://Scenes/enemy.tscn" id="4_g0oey"] [ext_resource type="PackedScene" uid="uid://0onqgygm832d" path="res://Scenes/Player/player.tscn" id="5_ik47y"] [ext_resource type="AudioStream" uid="uid://c3dy35dv368ft" path="res://Assets/Music/SisNeufPiDoozHuit.mp3" id="7_but47"] diff --git a/Scenes/Spawnables/bat_spawnable.tscn b/Scenes/Spawnables/bat_spawnable.tscn index 3678f16..5088354 100644 --- a/Scenes/Spawnables/bat_spawnable.tscn +++ b/Scenes/Spawnables/bat_spawnable.tscn @@ -10,7 +10,7 @@ region = Rect2(0, 0, 64, 64) [node name="BatSpawnable" instance=ExtResource("1_verf7")] maxHp = 10 -attackSpeed = 50.0 +attackSpeed = 20.0 speed = 4000.0 damage = 1 priority = 1 diff --git a/Scenes/enemy.tscn b/Scenes/enemy.tscn index 081b990..a93455f 100644 --- a/Scenes/enemy.tscn +++ b/Scenes/enemy.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=61 format=3 uid="uid://b5lnjonlf4i1b"] +[gd_scene load_steps=62 format=3 uid="uid://b5lnjonlf4i1b"] [ext_resource type="Script" path="res://Scripts/Enemy.gd" id="1_xj62t"] [ext_resource type="Texture2D" uid="uid://xn7yb3f5w17m" path="res://Assets/Knight/noBKG_KnightAttack_strip.png" id="2_dclcl"] @@ -11,6 +11,9 @@ [ext_resource type="AudioStream" uid="uid://dj7884l6tki3g" path="res://Assets/Audio/whoosh.ogg" id="8_ygdkj"] [ext_resource type="AudioStream" uid="uid://bmu622w5ea05y" path="res://Assets/Audio/mixkit-weak-fast-blow-2145.wav" id="9_myh6x"] +[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_xq5nx"] +polygon = PackedVector2Array(-2, 11, 2, 2, 2, -7, 0, -18, -5, -18, -6, -7, -6, 1) + [sub_resource type="AtlasTexture" id="AtlasTexture_6gjg8"] atlas = ExtResource("2_dclcl") region = Rect2(1296, 0, 144, 64) @@ -380,6 +383,9 @@ collision_layer = 5 collision_mask = 5 script = ExtResource("1_xj62t") +[node name="LightOccluder2D" type="LightOccluder2D" parent="."] +occluder = SubResource("OccluderPolygon2D_xq5nx") + [node name="Sprite" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_dqf8u") animation = &"Idle" @@ -449,6 +455,7 @@ position = Vector2(0, -3) shape = SubResource("CapsuleShape2D_p2hkm") [node name="AttackArea" type="Area2D" parent="."] +visible = false collision_layer = 2 collision_mask = 2 From 5e85af9d006b908dfe8c1a4d080a987969f3aca6 Mon Sep 17 00:00:00 2001 From: Victor Turgeon Date: Wed, 11 Oct 2023 05:23:48 -0400 Subject: [PATCH 3/3] some exp balancing --- Scenes/Player/UI/player_ui.gd | 17 ++++ Scenes/Player/UI/player_ui.tscn | 119 ++++++++++++++++++++++++++- Scenes/Player/player.gd | 5 +- Scenes/Spawnables/bat_spawnable.tscn | 6 +- Scenes/enemy.tscn | 1 + Scripts/Enemy.gd | 14 +++- 6 files changed, 156 insertions(+), 6 deletions(-) diff --git a/Scenes/Player/UI/player_ui.gd b/Scenes/Player/UI/player_ui.gd index d0cf549..a3c3797 100644 --- a/Scenes/Player/UI/player_ui.gd +++ b/Scenes/Player/UI/player_ui.gd @@ -1,8 +1,14 @@ +class_name PlayerUI extends Control @export var buttonGroup : ButtonGroup @onready var bludGen : Label = $UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer/BludGenContainer/BludGen @onready var bludTotal : Label = $UIRoot/ControlPanel/StatPanel/Blud/HBoxContainer/VBoxContainer/BludTotalContainer/BludTotal +@onready var enemyXPBar : ProgressBar = $UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyXPBar +@onready var enemyXPLabel : Label = $UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyXPBar/EnemyXPLabel +@onready var enemyHPBar : ProgressBar = $UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyHPBar +@onready var enemyHPLabel : Label = $UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyHPBar/EnemyHPLabel + signal button_changed(currentButton : Button) @@ -22,3 +28,14 @@ func set_blud_gen(gen): func set_blud_total(total): bludTotal.text = str(floor(total)) + +func set_hp(current, total): + enemyHPBar.max_value = total + enemyHPBar.value = current + enemyHPLabel.text = str(current) + "/" + str(total) + " HP" + +func set_xp(current, min, max, level): + enemyXPBar.max_value = max + enemyXPBar.min_value = min + enemyXPBar.value = current + enemyXPLabel.text = "Lvl " + str(level) + " (" + str(current) + "/" + str(max) + "xp)" diff --git a/Scenes/Player/UI/player_ui.tscn b/Scenes/Player/UI/player_ui.tscn index 92e8c2f..105194a 100644 --- a/Scenes/Player/UI/player_ui.tscn +++ b/Scenes/Player/UI/player_ui.tscn @@ -1,10 +1,27 @@ -[gd_scene load_steps=6 format=3 uid="uid://dmvukn3rl6gbx"] +[gd_scene load_steps=12 format=3 uid="uid://dmvukn3rl6gbx"] [ext_resource type="Script" path="res://Scenes/Player/UI/player_ui.gd" id="1_4nwdk"] [ext_resource type="PackedScene" uid="uid://dl0d1m1gfcd4o" path="res://Scenes/Player/UI/bat_button.tscn" id="1_tnnk6"] [ext_resource type="Theme" uid="uid://dr1h7to56a2pv" path="res://Themes/base_theme.tres" id="3_4fgkw"] [ext_resource type="ButtonGroup" uid="uid://gjbbywsr8n8b" path="res://Scenes/Player/UI/spawnables_button_group.tres" id="3_7a133"] [ext_resource type="Texture2D" uid="uid://kbd5cnmgbqso" path="res://Assets/Sprite-0001.png" id="4_s5lk5"] +[ext_resource type="Texture2D" uid="uid://bof6qeuo2rnso" path="res://Assets/Knight/noBKG_KnightRun_strip.png" id="5_7a8uf"] +[ext_resource type="Texture2D" uid="uid://djjqhipuo3byw" path="res://Assets/Knight/noBKG_KnightShield_strip.png" id="5_t0ay2"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_v6oad"] +bg_color = Color(0.243137, 0.713726, 0.0627451, 0.301961) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b74dp"] +bg_color = Color(0.333333, 0.721569, 0.270588, 0.886275) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5ptrg"] +atlas = ExtResource("5_7a8uf") +region = Rect2(132.276, 0.393494, 39.1181, 55.8829) + +[sub_resource type="AtlasTexture" id="AtlasTexture_57m6r"] +resource_local_to_scene = true +atlas = ExtResource("5_t0ay2") +region = Rect2(32, 0, 64, 64) [node name="PlayerUI" type="Control"] layout_mode = 3 @@ -118,6 +135,106 @@ theme = ExtResource("3_4fgkw") text = "100" vertical_alignment = 2 +[node name="Other" type="Control" parent="UIRoot/ControlPanel/StatPanel"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="MarginContainer" type="MarginContainer" parent="UIRoot/ControlPanel/StatPanel/Other"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 0 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_bottom = 5 + +[node name="GridContainer" type="GridContainer" parent="UIRoot/ControlPanel/StatPanel/Other/MarginContainer"] +layout_mode = 2 + +[node name="EnemyXPBar" type="ProgressBar" parent="UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +theme = ExtResource("3_4fgkw") +theme_override_styles/background = SubResource("StyleBoxFlat_v6oad") +theme_override_styles/fill = SubResource("StyleBoxFlat_b74dp") +max_value = 300.0 +step = 1.0 +value = 100.0 +show_percentage = false + +[node name="EnemyTexture" type="TextureRect" parent="UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyXPBar"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_top = -16.5 +offset_right = 24.0 +offset_bottom = 16.5 +grow_vertical = 2 +texture = SubResource("AtlasTexture_5ptrg") +expand_mode = 3 +stretch_mode = 5 + +[node name="EnemyXPLabel" type="Label" parent="UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyXPBar"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -0.5 +offset_top = -11.5 +offset_right = 0.5 +offset_bottom = 11.5 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 6 +text = "Lvl 1 (100/300xp)" +vertical_alignment = 1 + +[node name="EnemyHPBar" type="ProgressBar" parent="UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +theme = ExtResource("3_4fgkw") +step = 1.0 +value = 99.0 +show_percentage = false + +[node name="EnemyTexture" type="TextureRect" parent="UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyHPBar"] +layout_mode = 1 +anchors_preset = 9 +anchor_bottom = 1.0 +offset_top = -8.0 +offset_right = 33.0 +offset_bottom = 8.0 +grow_vertical = 2 +texture = SubResource("AtlasTexture_57m6r") +expand_mode = 4 +stretch_mode = 5 + +[node name="EnemyHPLabel" type="Label" parent="UIRoot/ControlPanel/StatPanel/Other/MarginContainer/GridContainer/EnemyHPBar"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -0.5 +offset_top = -11.5 +offset_right = 0.5 +offset_bottom = 11.5 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 3 +size_flags_vertical = 6 +text = "99/100 HP" +vertical_alignment = 1 + [node name="ButtonPanel" type="HBoxContainer" parent="UIRoot/ControlPanel"] layout_mode = 2 size_flags_horizontal = 3 diff --git a/Scenes/Player/player.gd b/Scenes/Player/player.gd index 9c4cadf..b6212b3 100644 --- a/Scenes/Player/player.gd +++ b/Scenes/Player/player.gd @@ -13,7 +13,7 @@ var allSpawnedMonsters : Dictionary = {} var currentSpawnedMonsters : Array = [] @onready var menuZone : Control = $Camera2D/CanvasLayer/PlayerUI/MenuZone @onready var playerUI : Control = $Camera2D/CanvasLayer/PlayerUI -@onready var enemy : CharacterBody2D = $"../Enemy" +@onready var enemy : Fabio = $"../Enemy" @onready var playableArea : Area2D = $"../PlayableArea" @onready var cursorState : Node2D = $CursorState @@ -23,6 +23,9 @@ func _ready(): currentBludAmount = STARTING_Blud_AMOUNT currentBludGen = BASE_Blud_GEN + enemy.exp_gained.connect(playerUI.set_xp) + enemy.hp_changed.connect(playerUI.set_hp) + playerUI.set_blud(currentBludGen, currentBludAmount) playableArea.mouse_entered.connect(entered_playable_area) diff --git a/Scenes/Spawnables/bat_spawnable.tscn b/Scenes/Spawnables/bat_spawnable.tscn index 5088354..9e71722 100644 --- a/Scenes/Spawnables/bat_spawnable.tscn +++ b/Scenes/Spawnables/bat_spawnable.tscn @@ -10,12 +10,12 @@ region = Rect2(0, 0, 64, 64) [node name="BatSpawnable" instance=ExtResource("1_verf7")] maxHp = 10 -attackSpeed = 20.0 +attackSpeed = 50.0 speed = 4000.0 damage = 1 priority = 1 -expReward = 50 -cost = 50 +expReward = 25 +cost = 20 minSpawnRange = 10.0 monsterName = "Bat" monsterIcon = SubResource("AtlasTexture_bnd0j") diff --git a/Scenes/enemy.tscn b/Scenes/enemy.tscn index a93455f..97ff30e 100644 --- a/Scenes/enemy.tscn +++ b/Scenes/enemy.tscn @@ -382,6 +382,7 @@ position = Vector2(10, 10) collision_layer = 5 collision_mask = 5 script = ExtResource("1_xj62t") +maxhp = 50 [node name="LightOccluder2D" type="LightOccluder2D" parent="."] occluder = SubResource("OccluderPolygon2D_xq5nx") diff --git a/Scripts/Enemy.gd b/Scripts/Enemy.gd index 38130b9..5d96b42 100644 --- a/Scripts/Enemy.gd +++ b/Scripts/Enemy.gd @@ -1,3 +1,4 @@ +class_name Fabio extends CharacterBody2D @onready var levelup = [300, 900, 2700, 6500, 14000, 23000, 34000, 48000, 64000] @@ -36,6 +37,9 @@ extends CharacterBody2D @onready var list: Array = [] +signal exp_gained(current, min, max, level) +signal hp_changed(current, max) + func add_foe(foe): list.append(foe) @@ -51,6 +55,8 @@ func _ready(): atk1r.set_disabled(true) atk2l.set_disabled(true) atk2r.set_disabled(true) + hp_changed.emit(hp, maxhp) + exp_gained.emit(experience, 0 if level == 1 else levelup[level - 2] ,levelup[level - 1], level) # Called every frame. 'delta' is the elapsed time since the previous frame. @@ -153,12 +159,16 @@ func receive_damage(dmg): hitanim.restart() anim.modulate.a = 0.5 + hp_changed.emit(hp, maxhp) + func receive_exp(x): experience += x if experience > levelup[level - 1] && level <= 8: setLevel(level + 1) + exp_gained.emit(experience, 0 if level == 1 else levelup[level - 2] ,levelup[level - 1], level) + func setLevel(lvl): level = lvl @@ -182,11 +192,13 @@ func setLevel(lvl): maxAtks = 2 maxhp += 5 - hp += maxhp / 2 + hp += 10 if hp > maxhp: hp = maxhp + hp_changed.emit(hp, maxhp) + func _on_atk_cooldown_timeout(): currAtks = maxAtks