-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Define the XP_manager * Change StressComponent to properly award XP * Add the status from the XP to the player at combat start * Add variables for previous and next XP levels, rewrite increase function * Add new signals in XP Manager * Make default status * Use the default for the XP_manager, add infinite duration to status * Create an insta-win deck to clear combat faster (use only for testing) * Create an XP bar that shows previous / next buff and current XP * Add some tests * Add one more xp test * Rename XP_manager to XpManager to follow correct file nomenclature
- Loading branch information
Showing
30 changed files
with
551 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://ruwidm3egyrx"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://bal0bt1kvkyfb" path="res://Art/Menus/xp_bar-1.png" id="1_3gny4"] | ||
[ext_resource type="Texture2D" uid="uid://b8o5iklqwlg8t" path="res://Art/Menus/xp_bar_over-1.png" id="2_tcjnv"] | ||
[ext_resource type="Script" path="res://#Scenes/xp_progress.gd" id="3_5qwyb"] | ||
|
||
[node name="XP progress" type="Control"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_top = 199.0 | ||
offset_right = -1845.0 | ||
offset_bottom = -98.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
|
||
[node name="TextureProgressBar" type="TextureProgressBar" parent="."] | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
step = 0.1 | ||
value = 90.0 | ||
fill_mode = 3 | ||
nine_patch_stretch = true | ||
stretch_margin_left = 4 | ||
stretch_margin_top = 4 | ||
stretch_margin_right = 4 | ||
stretch_margin_bottom = 4 | ||
texture_under = ExtResource("1_3gny4") | ||
texture_over = ExtResource("2_tcjnv") | ||
texture_progress = ExtResource("1_3gny4") | ||
tint_under = Color(0, 0, 0, 1) | ||
tint_progress = Color(0.839216, 0.784314, 0.305882, 1) | ||
script = ExtResource("3_5qwyb") | ||
|
||
[node name="Previous buff" type="Label" parent="TextureProgressBar"] | ||
layout_mode = 1 | ||
anchors_preset = -1 | ||
anchor_left = 0.5 | ||
anchor_top = 0.895 | ||
anchor_right = 0.5 | ||
anchor_bottom = 0.897 | ||
offset_left = -579.5 | ||
offset_top = -47.785 | ||
offset_right = -59.5 | ||
offset_bottom = 91.353 | ||
grow_horizontal = 2 | ||
grow_vertical = 0 | ||
theme_override_font_sizes/font_size = 30 | ||
text = "Previous buff | ||
5 XP" | ||
horizontal_alignment = 2 | ||
|
||
[node name="Next buff" type="Label" parent="TextureProgressBar"] | ||
layout_mode = 1 | ||
anchors_preset = -1 | ||
anchor_left = 0.5 | ||
anchor_top = 0.097 | ||
anchor_right = 0.5 | ||
anchor_bottom = 0.097 | ||
offset_left = -577.5 | ||
offset_top = -43.951 | ||
offset_right = -57.5 | ||
offset_bottom = 97.049 | ||
theme_override_font_sizes/font_size = 30 | ||
text = "Next buff | ||
10 XP" | ||
horizontal_alignment = 2 | ||
|
||
[node name="Current XP" type="Label" parent="TextureProgressBar"] | ||
layout_mode = 1 | ||
anchors_preset = 4 | ||
anchor_top = 0.5 | ||
anchor_bottom = 0.5 | ||
offset_left = -540.0 | ||
offset_top = -39.5 | ||
offset_right = -20.0 | ||
offset_bottom = 45.5 | ||
grow_vertical = 2 | ||
theme_override_font_sizes/font_size = 30 | ||
text = " 7 XP" | ||
horizontal_alignment = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
extends TextureProgressBar | ||
|
||
@onready var previous_buff_label: Label = $"Previous buff" | ||
@onready var next_buff_label: Label = $"Next buff" | ||
@onready var current_xp_label: Label = $"Current XP" | ||
|
||
## The filling of the bar will not go above 90% | ||
const MAX_BAR_VALUE_VISUAL: float = 90 | ||
|
||
## The filling of the bar will not go below 10% | ||
const MIN_BAR_VALUE_VISUAL: float = 10 | ||
|
||
## The text to display for the previously reached buff | ||
var previous_buff_string: String = "" | ||
|
||
## The text to display for the next buff | ||
var next_buff_string: String = "" | ||
|
||
## The amount by which the progress bar fills every time we win an XP point | ||
var xp_delta: float = 0. | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready() -> void: | ||
self.max_value = 100 | ||
self.min_value = 0 | ||
self.value = 10 | ||
_update_progress_bar_text_on_new_level(XpManager.current_xp, XpManager.previous_xp_level, XpManager.next_xp_level, false) | ||
XpManager.xp_changed.connect(_choose_update_method) | ||
|
||
## Choose between the methods to update the bar (since the visual change is different) | ||
func _choose_update_method(current_xp: int, previous_xp: int, next_xp: int, level_up: bool) -> void: | ||
if level_up: | ||
_update_progress_bar_text_on_new_level(current_xp, previous_xp, next_xp, level_up) | ||
else: | ||
var bar_transition_duration: float = 1 | ||
_change_progress_bar_value(current_xp, bar_transition_duration, previous_xp, level_up) | ||
|
||
## Update the value of the progress bar to fill it | ||
func _change_progress_bar_value(new_xp: int, max_duration: float, previous_xp: int, level_up: bool) -> void: | ||
# first 10% are always filled | ||
current_xp_label.text = "%s XP" % new_xp | ||
var tween: Tween = create_tween() | ||
var final_value: float = MAX_BAR_VALUE_VISUAL | ||
if not level_up: | ||
final_value = MIN_BAR_VALUE_VISUAL + (new_xp - previous_xp) * xp_delta | ||
var duration: float = max_duration | ||
if not level_up: | ||
duration = max_duration * abs(final_value - self.value)/(MAX_BAR_VALUE_VISUAL - MIN_BAR_VALUE_VISUAL) | ||
else: | ||
duration = max_duration * (90 - self.value)/80 | ||
tween.tween_property(self, "value", final_value, duration) | ||
await tween.finished | ||
|
||
## When a new level of XP is reached, update the progress bar to display the information about the next level | ||
func _update_progress_bar_text_on_new_level(current_xp: int, previous_xp: int, next_xp: int, level_up: bool) -> void: | ||
# Calculate the amount by which the progress bar fills every time we win an XP point | ||
# Make it so that the bar uses only 80% of the total filling | ||
# which allows us to leave the first as always used and the last 10% as always empty | ||
var bar_transition_max_duration: float = 1 | ||
if not level_up: | ||
bar_transition_max_duration = 0 | ||
await _change_progress_bar_value(previous_xp, bar_transition_max_duration, previous_xp, level_up) | ||
xp_delta = 80 / (next_xp - previous_xp) | ||
# change opacity to transparent over 1s | ||
if level_up: | ||
await _tween_label_opacity([previous_buff_label, next_buff_label], 0, 0.5) | ||
# change strings to "Buff name \n xp_amount XP" | ||
if current_xp >= 1: | ||
previous_buff_string = "%s\n%s XP" % [XpManager.xp_levels[previous_xp][0], previous_xp] | ||
next_buff_string = "%s\n%s XP" % [XpManager.xp_levels[next_xp][0], next_xp] | ||
previous_buff_label.text = previous_buff_string | ||
next_buff_label.text = next_buff_string | ||
|
||
_change_progress_bar_value(current_xp, bar_transition_max_duration, previous_xp, false) | ||
|
||
# change opacity back to fully opaque | ||
if level_up: | ||
_tween_label_opacity([previous_buff_label, next_buff_label], 1, 0.5) | ||
|
||
|
||
func _tween_label_opacity(labels_to_change: Array[Label], end_opacity: float, duration : float) -> void: | ||
var tween: Tween = create_tween().set_parallel(true) | ||
for label in labels_to_change: | ||
tween.tween_property(label, "modulate:a", end_opacity, duration) | ||
await tween.finished | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://bal0bt1kvkyfb" | ||
path="res://.godot/imported/xp_bar-1.png-8221bf33ef42c0a77d89fd564f22b457.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://Art/Menus/xp_bar-1.png" | ||
dest_files=["res://.godot/imported/xp_bar-1.png-8221bf33ef42c0a77d89fd564f22b457.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://dphbk6q82ak6y" | ||
path="res://.godot/imported/xp_bar_bg-1.png-62f908043ede9a71e3bd6082cf0d1437.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://Art/Menus/xp_bar_bg-1.png" | ||
dest_files=["res://.godot/imported/xp_bar_bg-1.png-62f908043ede9a71e3bd6082cf0d1437.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://b8o5iklqwlg8t" | ||
path="res://.godot/imported/xp_bar_over-1.png-dbdd89ca510c3e160dd46c7f4f132e57.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://Art/Menus/xp_bar_over-1.png" | ||
dest_files=["res://.godot/imported/xp_bar_over-1.png-dbdd89ca510c3e160dd46c7f4f132e57.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gd_resource type="Resource" script_class="CardSetBase" load_steps=7 format=3 uid="uid://pot7cg3o6qy3"] | ||
|
||
[ext_resource type="Resource" uid="uid://dliguwgspqyx0" path="res://Cards/Resource/DO_NOT_USE_IN_DECKS/DO_NOT_USE_IN_DECK_insta_kill.tres" id="1_6mukv"] | ||
[ext_resource type="Resource" uid="uid://6thyux8u44dk" path="res://Cards/Resource/DO_NOT_USE_IN_DECKS/DO_NOT_USE_IN_DECK_insta_sooth.tres" id="2_jr0a6"] | ||
[ext_resource type="Resource" uid="uid://c4nm7mbdlsf6r" path="res://Cards/Resource/Card_Banana.tres" id="3_ptv1b"] | ||
[ext_resource type="Resource" uid="uid://d12g33rc6c3u5" path="res://Cards/Resource/Card_Heal.tres" id="4_jfguc"] | ||
[ext_resource type="Resource" uid="uid://btj36bhn3n2tr" path="res://Cards/Resource/Card_Strength.tres" id="5_g72ks"] | ||
[ext_resource type="Script" path="res://Cards/CardSetBase.gd" id="21_rmslx"] | ||
|
||
[resource] | ||
script = ExtResource("21_rmslx") | ||
card_set = Array[Resource("res://Cards/CardBase.gd")]([ExtResource("1_6mukv"), ExtResource("2_jr0a6"), ExtResource("3_ptv1b"), ExtResource("4_jfguc"), ExtResource("5_g72ks")]) |
25 changes: 25 additions & 0 deletions
25
Cards/Resource/DO_NOT_USE_IN_DECKS/DO_NOT_USE_IN_DECK_insta_kill.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[gd_resource type="Resource" script_class="CardBase" load_steps=8 format=3 uid="uid://dliguwgspqyx0"] | ||
|
||
[ext_resource type="Script" path="res://Cards/Effects/EffectDamage.gd" id="1_x1diw"] | ||
[ext_resource type="Script" path="res://Cards/Effects/EffectData.gd" id="2_ovjct"] | ||
[ext_resource type="Script" path="res://Cards/Targeting/TargetAllEnemies.gd" id="3_je37t"] | ||
[ext_resource type="Script" path="res://Cards/CardBase.gd" id="4_arvwe"] | ||
|
||
[sub_resource type="Resource" id="Resource_byd8o"] | ||
script = ExtResource("1_x1diw") | ||
|
||
[sub_resource type="Resource" id="Resource_5gkxu"] | ||
script = ExtResource("3_je37t") | ||
|
||
[sub_resource type="Resource" id="Resource_dii3b"] | ||
script = ExtResource("2_ovjct") | ||
effect = SubResource("Resource_byd8o") | ||
value = 1000 | ||
targeting_function = SubResource("Resource_5gkxu") | ||
|
||
[resource] | ||
script = ExtResource("4_arvwe") | ||
application_type = 1 | ||
card_title = "Insta Kill" | ||
card_description = "Does 1000 damage to all enemies" | ||
card_effects_data = Array[ExtResource("2_ovjct")]([SubResource("Resource_dii3b")]) |
25 changes: 25 additions & 0 deletions
25
Cards/Resource/DO_NOT_USE_IN_DECKS/DO_NOT_USE_IN_DECK_insta_sooth.tres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[gd_resource type="Resource" script_class="CardBase" load_steps=8 format=3 uid="uid://6thyux8u44dk"] | ||
|
||
[ext_resource type="Script" path="res://Cards/Effects/EffectSooth.gd" id="1_40224"] | ||
[ext_resource type="Script" path="res://Cards/Effects/EffectData.gd" id="2_rs3h8"] | ||
[ext_resource type="Script" path="res://Cards/Targeting/TargetAllEnemies.gd" id="3_fedpo"] | ||
[ext_resource type="Script" path="res://Cards/CardBase.gd" id="4_aws21"] | ||
|
||
[sub_resource type="Resource" id="Resource_4m74w"] | ||
script = ExtResource("1_40224") | ||
|
||
[sub_resource type="Resource" id="Resource_o7c6r"] | ||
script = ExtResource("3_fedpo") | ||
|
||
[sub_resource type="Resource" id="Resource_ucbco"] | ||
script = ExtResource("2_rs3h8") | ||
effect = SubResource("Resource_4m74w") | ||
value = 1000 | ||
targeting_function = SubResource("Resource_o7c6r") | ||
|
||
[resource] | ||
script = ExtResource("4_aws21") | ||
application_type = 1 | ||
card_title = "Insta Sooth" | ||
card_description = "Applies 1000 sooth to all enemies" | ||
card_effects_data = Array[ExtResource("2_rs3h8")]([SubResource("Resource_ucbco")]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.