From a0f826525cd6dfb77cde458ef5dd8272b3450dd3 Mon Sep 17 00:00:00 2001 From: tonydero Date: Thu, 17 Oct 2024 14:11:10 -0600 Subject: [PATCH] fix enum name formatting, add initial quest basics --- assets/expbar.tres | 20 +++++++++++ assets/healthbar.tres | 14 ++++++++ scenes/enemy.tscn | 25 ++++--------- scenes/quest.tscn | 24 +++++++++++++ scenes/testScrollScene.tscn | 66 ++++++++++++++++++++++++++++++---- scripts/AbilityBase.gd | 46 ++++++++++++++++++++---- scripts/NPC.gd | 24 ++++++------- scripts/NPCEnemy.gd | 6 ++-- scripts/Quest.gd | 20 +++++++++++ scripts/styling.gd | 16 ++++----- scripts/test_instance_scene.gd | 12 +++---- scripts/test_scene.gd | 8 ++--- 12 files changed, 217 insertions(+), 64 deletions(-) create mode 100644 assets/expbar.tres create mode 100644 assets/healthbar.tres create mode 100644 scenes/quest.tscn create mode 100644 scripts/Quest.gd diff --git a/assets/expbar.tres b/assets/expbar.tres new file mode 100644 index 0000000..75644b5 --- /dev/null +++ b/assets/expbar.tres @@ -0,0 +1,20 @@ +[gd_resource type="Theme" load_steps=4 format=3 uid="uid://cp82s71sduhcv"] + +[ext_resource type="FontFile" uid="uid://4q1f672e7ux2" path="res://addons/godot_vim/hack_regular.ttf" id="1_q1l18"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yg7tn"] +bg_color = Color(0.980392, 0.741176, 0.184314, 0.580392) +border_color = Color(0.491583, 0.491583, 0.491583, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_enag8"] +bg_color = Color(0.996078, 0.501961, 0.0980392, 1) +border_color = Color(0.491583, 0.491583, 0.491583, 1) + +[resource] +ProgressBar/colors/font_color = Color(0.113725, 0.12549, 0.129412, 1) +ProgressBar/colors/font_outline_color = Color(0, 0, 0, 0.580392) +ProgressBar/constants/outline_size = 1 +ProgressBar/font_sizes/font_size = 8 +ProgressBar/fonts/font = ExtResource("1_q1l18") +ProgressBar/styles/background = SubResource("StyleBoxFlat_yg7tn") +ProgressBar/styles/fill = SubResource("StyleBoxFlat_enag8") diff --git a/assets/healthbar.tres b/assets/healthbar.tres new file mode 100644 index 0000000..b07935b --- /dev/null +++ b/assets/healthbar.tres @@ -0,0 +1,14 @@ +[gd_resource type="Theme" load_steps=3 format=3 uid="uid://clhh3c3gxotjg"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yg7tn"] +bg_color = Color(0.623529, 0, 0, 1) +border_color = Color(0.491583, 0.491583, 0.491583, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_enag8"] +bg_color = Color(0.207843, 0, 0, 1) +border_color = Color(0.491583, 0.491583, 0.491583, 1) + +[resource] +default_font_size = 10 +ProgressBar/styles/background = SubResource("StyleBoxFlat_yg7tn") +ProgressBar/styles/fill = SubResource("StyleBoxFlat_enag8") diff --git a/scenes/enemy.tscn b/scenes/enemy.tscn index ca20120..4665be5 100644 --- a/scenes/enemy.tscn +++ b/scenes/enemy.tscn @@ -1,19 +1,8 @@ -[gd_scene load_steps=6 format=3 uid="uid://55qfhbliodhn"] +[gd_scene load_steps=4 format=3 uid="uid://55qfhbliodhn"] [ext_resource type="Script" path="res://scripts/NPCEnemy.gd" id="1_ec4cy"] [ext_resource type="Texture2D" uid="uid://b10c1776j6j60" path="res://assets/icon.svg" id="2_twdr5"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yg7tn"] -bg_color = Color(0.623529, 0, 0, 1) -border_color = Color(0.491583, 0.491583, 0.491583, 1) - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_enag8"] -bg_color = Color(0.207843, 0, 0, 1) -border_color = Color(0.491583, 0.491583, 0.491583, 1) - -[sub_resource type="Theme" id="Theme_fx206"] -ProgressBar/styles/background = SubResource("StyleBoxFlat_yg7tn") -ProgressBar/styles/fill = SubResource("StyleBoxFlat_enag8") +[ext_resource type="Theme" uid="uid://clhh3c3gxotjg" path="res://assets/healthbar.tres" id="3_tceil"] [node name="NPCEnemy" type="CharacterBody2D"] script = ExtResource("1_ec4cy") @@ -44,11 +33,10 @@ layout_mode = 2 unique_name_in_owner = true custom_minimum_size = Vector2(0, 16) layout_mode = 2 -theme = SubResource("Theme_fx206") +theme = ExtResource("3_tceil") max_value = 10.0 step = 1.0 value = 10.0 -show_percentage = false [node name="TitleBox" type="HBoxContainer" parent="Sprite2D/MarginContainer/Nameplate"] layout_mode = 2 @@ -57,12 +45,11 @@ layout_mode = 2 layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 0 -text = "Tier -" +text = "I" -[node name="NPCNameLabel" type="Label" parent="Sprite2D/MarginContainer/Nameplate/TitleBox"] +[node name="NameLabel" type="Label" parent="Sprite2D/MarginContainer/Nameplate/TitleBox"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 0 -text = "Name" +text = "Enemy" diff --git a/scenes/quest.tscn b/scenes/quest.tscn new file mode 100644 index 0000000..131edf2 --- /dev/null +++ b/scenes/quest.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=2 format=3 uid="uid://klcyjys703l5"] + +[ext_resource type="Script" path="res://scripts/Quest.gd" id="1_o0k38"] + +[node name="Quest" type="HBoxContainer"] +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("1_o0k38") + +[node name="ObjectiveLabel" type="Label" parent="."] +layout_mode = 2 +text = "Quest Objective: " + +[node name="CompletedLabel" type="Label" parent="."] +layout_mode = 2 +text = "0" + +[node name="Separator" type="Label" parent="."] +layout_mode = 2 +text = "/" + +[node name="GoalLabel" type="Label" parent="."] +layout_mode = 2 +text = "1" diff --git a/scenes/testScrollScene.tscn b/scenes/testScrollScene.tscn index bd3cbff..23a4615 100644 --- a/scenes/testScrollScene.tscn +++ b/scenes/testScrollScene.tscn @@ -1,7 +1,14 @@ -[gd_scene load_steps=3 format=3 uid="uid://0h3dpe6fuhe8"] +[gd_scene load_steps=8 format=3 uid="uid://0h3dpe6fuhe8"] [ext_resource type="Script" path="res://scripts/test_scroll_scene.gd" id="1_gc1kb"] +[ext_resource type="Theme" uid="uid://clhh3c3gxotjg" path="res://assets/healthbar.tres" id="2_2v2l0"] +[ext_resource type="PackedScene" uid="uid://klcyjys703l5" path="res://scenes/quest.tscn" id="2_dodxo"] [ext_resource type="PackedScene" uid="uid://dvwo26vsk46tl" path="res://scenes/ability_ph.tscn" id="2_heria"] +[ext_resource type="Theme" uid="uid://cp82s71sduhcv" path="res://assets/expbar.tres" id="3_n8q4b"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_imvmd"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6jnvr"] [node name="TestInstanceScene" type="Control"] layout_mode = 3 @@ -35,17 +42,56 @@ theme_override_constants/margin_top = 10 theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 10 +[node name="UITop" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +size_flags_vertical = 0 + +[node name="QuestsContainer" type="HBoxContainer" parent="MarginContainer/UITop"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 4 + +[node name="PHQuest" parent="MarginContainer/UITop/QuestsContainer" instance=ExtResource("2_dodxo")] +layout_mode = 2 + [node name="UIBottom" type="HBoxContainer" parent="MarginContainer"] layout_mode = 2 size_flags_vertical = 8 -[node name="PlayerInfo" type="VBoxContainer" parent="MarginContainer/UIBottom"] +[node name="PlayerContainer" type="PanelContainer" parent="MarginContainer/UIBottom"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_styles/panel = SubResource("StyleBoxEmpty_imvmd") + +[node name="PlayerInfo" type="VBoxContainer" parent="MarginContainer/UIBottom/PlayerContainer"] layout_mode = 2 size_flags_horizontal = 3 -[node name="PlayerHealthbar" type="ProgressBar" parent="MarginContainer/UIBottom/PlayerInfo"] +[node name="PlayerLabel" type="HBoxContainer" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo"] +layout_mode = 2 + +[node name="PlayerLevel" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerLabel"] +layout_mode = 2 +text = "1" + +[node name="PlayerName" type="Label" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo/PlayerLabel"] +layout_mode = 2 +text = "Player" + +[node name="PlayerHealthBar" type="ProgressBar" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo"] +custom_minimum_size = Vector2(0, 32) layout_mode = 2 size_flags_vertical = 2 +theme = ExtResource("2_2v2l0") +step = 1.0 +value = 100.0 + +[node name="PlayerExpBar" type="ProgressBar" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo"] +layout_mode = 2 +size_flags_vertical = 10 +theme = ExtResource("3_n8q4b") +step = 1.0 +value = 43.0 [node name="UIBottomCenter" type="VBoxContainer" parent="MarginContainer/UIBottom"] custom_minimum_size = Vector2(384, 0) @@ -65,9 +111,11 @@ custom_minimum_size = Vector2(64, 64) layout_mode = 2 [node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("2_heria")] +visible = false custom_minimum_size = Vector2(64, 64) layout_mode = 2 size_flags_horizontal = 6 +attack_type = 3 attack_damage = 500 attack_speed = 3.5 @@ -145,13 +193,19 @@ text = "Exit" [node name="TouchScreenButton" type="TouchScreenButton" parent="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonExit"] -[node name="Player2FollowerInfo" type="VBoxContainer" parent="MarginContainer/UIBottom"] +[node name="MPlayerFollowerContainer" type="PanelContainer" parent="MarginContainer/UIBottom"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_styles/panel = SubResource("StyleBoxEmpty_6jnvr") + +[node name="MPlayerFollowerInfo" type="VBoxContainer" parent="MarginContainer/UIBottom/MPlayerFollowerContainer"] +visible = false layout_mode = 2 size_flags_horizontal = 3 -[node name="P2FHealthbar" type="ProgressBar" parent="MarginContainer/UIBottom/Player2FollowerInfo"] -visible = false +[node name="MPlayerFollowerHealthBar" type="ProgressBar" parent="MarginContainer/UIBottom/MPlayerFollowerContainer/MPlayerFollowerInfo"] layout_mode = 2 +theme = ExtResource("2_2v2l0") [connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"] [connection signal="pressed" from="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonTest" to="." method="_on_button_test_pressed"] diff --git a/scripts/AbilityBase.gd b/scripts/AbilityBase.gd index a8854cd..1c294d1 100644 --- a/scripts/AbilityBase.gd +++ b/scripts/AbilityBase.gd @@ -1,13 +1,47 @@ +# base ability class containing the main definitions class_name AbilityBase extends TextureRect -enum TARGTYPES { SINGLE, CLEAVE, CHAIN, SWIPE, WAVE, AREA, RAY } -enum PDMGTYPES { SLICE, PUNCTURE, BASH, HACK, SHRED } -enum MDMGTYPES { BURN, FREEZE, SHOCK, POISON, LIFE, RADIANT, ARCANE, FORCE } -enum SMODTYPES { STUN, SLOW, ABSORB, SHIELD, DOTB, DOTE } +enum TargTypes { + SINGLE, + CLEAVE, + CHAIN, + SWIPE, + WAVE, + AREA, + RAY, +} +enum PDmgTypes { + SLICE, + PUNCTURE, + BASH, + HACK, + SHRED, +} +enum MDmgTypes { + BURN, + FREEZE, + SHOCK, + POISON, + LIFE, + MENTAL, + RADIANT, + ARCANE, + FORCE +} +enum SModTypes { + STUN, + SLOW, + ABSORB, + SHIELD, + DOTB, + DOTE +} + @export var attack_range := 0 -@export var attack_type := TARGTYPES.SINGLE +@export var attack_type := TargTypes.SINGLE @export var attack_damage := 200 -@export var attack_speed := 1.0 \ No newline at end of file +@export var attack_speed := 1.0 +@export var base_cooldown := 0.0 diff --git a/scripts/NPC.gd b/scripts/NPC.gd index b5bbd9c..3cc9d3c 100644 --- a/scripts/NPC.gd +++ b/scripts/NPC.gd @@ -3,16 +3,16 @@ class_name NPC extends CharacterBody2D -enum npcDifficulties { MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG } -enum npcTiers { I, II, III, IV, V, VI, VII, VIII, IX, X } +enum NPCDifficulties {MINION, NORMAL, ELITE, BOSS, ELITEBOSS, BBEG} +enum NPCTiers {I, II, III, IV, V, VI, VII, VIII, IX, X} -signal npc_died(npcTier: npcTiers) +signal npc_died(npcTier: NPCTiers) @export var charName := "Character" @export var maxHealth := 10 @export var damageTaken := 0 -@export var npcDifficulty: npcDifficulties -@export var npcTier: npcTiers +@export var npcDifficulty: NPCDifficulties +@export var npcTier: NPCTiers func _random_mod_health() -> void: randomize() @@ -21,15 +21,15 @@ func _random_mod_health() -> void: self.maxHealth *= noise_factor # difficulty factor match self.npcDifficulty: - npcDifficulties.MINION: + NPCDifficulties.MINION: self.maxHealth /= 2 - npcDifficulties.ELITE: + NPCDifficulties.ELITE: self.maxHealth *= 2 - npcDifficulties.BOSS: + NPCDifficulties.BOSS: self.maxHealth *= 4 - npcDifficulties.ELITEBOSS: + NPCDifficulties.ELITEBOSS: self.maxHealth *= 8 - npcDifficulties.BBEG: + NPCDifficulties.BBEG: self.maxHealth *= 16 # npcTier factor self.maxHealth *= exp(self.npcTier) @@ -38,8 +38,8 @@ func _random_mod_health() -> void: func _init() -> void: - self.npcDifficulty = npcDifficulties.NORMAL - self.npcTier = npcTiers.I + self.npcDifficulty = NPCDifficulties.NORMAL + self.npcTier = NPCTiers.I func _ready() -> void: diff --git a/scripts/NPCEnemy.gd b/scripts/NPCEnemy.gd index 238aeca..c09a709 100644 --- a/scripts/NPCEnemy.gd +++ b/scripts/NPCEnemy.gd @@ -5,7 +5,7 @@ extends NPC enum questTypes {NONE, FEW_KILL, MANY_KILL, ONE_KILL} -signal enemy_died(npcDifficulty: npcDifficulties, questType: questTypes) +signal enemy_died(npcDifficulty: NPCDifficulties, questType: questTypes) @export var questType: questTypes = questTypes.NONE @@ -15,8 +15,8 @@ var prevCollisions := 0 func _init() -> void: - self.npcDifficulty = npcDifficulties.NORMAL - self.npcTier = npcTiers.I + self.npcDifficulty = NPCDifficulties.NORMAL + self.npcTier = NPCTiers.I func _ready() -> void: diff --git a/scripts/Quest.gd b/scripts/Quest.gd new file mode 100644 index 0000000..38476c7 --- /dev/null +++ b/scripts/Quest.gd @@ -0,0 +1,20 @@ +class_name Quest +extends HBoxContainer + +enum GoalTypes { KILLMANY, KILLFEW, KILLONE, GETMANY, GETFEW, GETONE } +enum KillTypes { NATURAL, VOID } + +@export var goalType := GoalTypes.KILLMANY +@export var killType := KillTypes.NATURAL + +func _ready() -> void: + pass + # goalType = GoalTypes. + # match goalType: + # GoalTypes.KILLMANY: + # killType = KillTypes.NATURAL + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(_delta: float) -> void: + pass diff --git a/scripts/styling.gd b/scripts/styling.gd index 154aa1d..d1a77a9 100644 --- a/scripts/styling.gd +++ b/scripts/styling.gd @@ -1,25 +1,25 @@ -extends Node +extends NPC -func format_label_difficulty(label: Node, difficulty: NPC.npcDifficulties) -> void: +func format_label_difficulty(label: Node, difficulty: NPC.NPCDifficulties) -> void: label.label_settings.outline_size = 4 match difficulty: - NPC.npcDifficulties.MINION: + NPCDifficulties.MINION: label.label_settings.outline_color = Color.BLACK label.label_settings.font_color = Color.LIGHT_GRAY - NPC.npcDifficulties.NORMAL: + NPCDifficulties.NORMAL: label.label_settings.outline_color = Color.DARK_GREEN label.label_settings.font_color = Color.LIME_GREEN - NPC.npcDifficulties.ELITE: + NPCDifficulties.ELITE: label.label_settings.outline_color = Color.DARK_BLUE label.label_settings.font_color = Color.DARK_CYAN - NPC.npcDifficulties.BOSS: + NPCDifficulties.BOSS: label.label_settings.outline_color = Color.PURPLE label.label_settings.font_color = Color.MAGENTA - NPC.npcDifficulties.ELITEBOSS: + NPCDifficulties.ELITEBOSS: label.label_settings.outline_color = Color.ORANGE_RED label.label_settings.font_color = Color.ORANGE - NPC.npcDifficulties.BBEG: + NPCDifficulties.BBEG: label.label_settings.font_color = Color.GOLD label.label_settings.outline_size = 8 label.label_settings.outline_color = Color.DARK_RED diff --git a/scripts/test_instance_scene.gd b/scripts/test_instance_scene.gd index 370f6c3..4ac5b6d 100644 --- a/scripts/test_instance_scene.gd +++ b/scripts/test_instance_scene.gd @@ -6,9 +6,9 @@ var enemies = Array() func _on_button_instantiate_pressed() -> void: - var middleX := get_viewport_rect().size.x/2 - var upperY := get_viewport_rect().size.y/4 - var middleY := get_viewport_rect().size.y/2 + var middleX := get_viewport_rect().size.x / 2 + var upperY := get_viewport_rect().size.y / 4 + var middleY := get_viewport_rect().size.y / 2 for enemy in enemies: remove_child(enemy) @@ -17,15 +17,15 @@ func _on_button_instantiate_pressed() -> void: for i in range(numEnemies): enemies.append(load("res://scenes/npc.tscn").instantiate()) add_child(enemies[i]) - var posX := int(round((i + 1)*get_viewport_rect().size.x/(numEnemies + 1))) + var posX := int(round((i + 1) * get_viewport_rect().size.x / (numEnemies + 1))) enemies[i].position = Vector2(posX, middleY) enemies[0].get_node("%NPCNameLabel").text = "Test" var bossEnemy = load("res://scenes/npc.tscn").instantiate() - bossEnemy.npcDifficulty = NPC.npcDifficulties.BOSS + bossEnemy.npcDifficulty = NPC.NPCDifficulties.BOSS add_child(bossEnemy) bossEnemy.position = Vector2(middleX, upperY) #print(bossEnemy.npcDifficulty) - bossEnemy.scale = Vector2.ONE*1.6 + bossEnemy.scale = Vector2.ONE * 1.6 func _on_button_exit_pressed() -> void: diff --git a/scripts/test_scene.gd b/scripts/test_scene.gd index c56726d..3b1ef3b 100644 --- a/scripts/test_scene.gd +++ b/scripts/test_scene.gd @@ -9,13 +9,13 @@ func _on_exit_button_pressed() -> void: func _on_test_button_pressed() -> void: - var rand_difficulty = NPC.npcDifficulties.values().pick_random() - var rand_tier = NPC.npcTiers.values().pick_random() + var rand_difficulty = NPC.NPCDifficulties.values().pick_random() + var rand_tier = NPC.NPCTiers.values().pick_random() var anNPC = NPC.new() %TestNMEMaxHealthVal.text = str(anNPC.maxHealth) #TestEMaxHealthVal.label_settings = LabelSettings.new() - %TestNMEName.text = str(NPC.npcDifficulties.find_key(anNPC.npcDifficulty)) - %TestNMETierVal.text = str(NPC.npcTiers.find_key(anNPC.npcTier)) + %TestNMEName.text = str(NPC.NPCDifficulties.find_key(anNPC.npcDifficulty)) + %TestNMETierVal.text = str(NPC.NPCTiers.find_key(anNPC.npcTier)) # style the name label based on the difficulty styling.format_label_difficulty(%TestNMEName, anNPC.npcDifficulty) #anNPC.position = Vector2(64, 64)