diff --git a/components/UI/DamageLabel.tscn b/components/UI/DamageLabel.tscn index 5904458..3f90db9 100644 --- a/components/UI/DamageLabel.tscn +++ b/components/UI/DamageLabel.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://ccuucmpdsjgb3"] +[gd_scene load_steps=7 format=3 uid="uid://ccuucmpdsjgb3"] [ext_resource type="Script" path="res://scripts/Statemachine/DamageLabel.gd" id="1_0q15u"] +[ext_resource type="FontFile" uid="uid://v3frxpuvtj5o" path="res://resources/fonts/syht-bold.ttf" id="2_p1o7i"] [sub_resource type="LabelSettings" id="LabelSettings_valp2"] +font = ExtResource("2_p1o7i") font_size = 25 outline_size = 6 outline_color = Color(0, 0, 0, 1) diff --git a/components/UI/ItemShow.tscn b/components/UI/ItemShow.tscn index 29f22cb..6f8472e 100644 --- a/components/UI/ItemShow.tscn +++ b/components/UI/ItemShow.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=7 format=3 uid="uid://bbm8l3hr4ihar"] +[gd_scene load_steps=8 format=3 uid="uid://bbm8l3hr4ihar"] [ext_resource type="Script" path="res://scripts/Statemachine/ItemShow.gd" id="1_2dhsb"] [ext_resource type="Texture2D" uid="uid://bks8jmctleina" path="res://resources/items/baseball.svg" id="1_hyowb"] +[sub_resource type="LabelSettings" id="LabelSettings_3yjwr"] + [sub_resource type="Animation" id="Animation_6sxrr"] length = 0.001 tracks/0/type = "bezier" @@ -110,6 +112,7 @@ layout_mode = 2 size_flags_horizontal = 0 size_flags_vertical = 8 text = "0" +label_settings = SubResource("LabelSettings_3yjwr") [node name="animator" type="AnimationPlayer" parent="."] unique_name_in_owner = true diff --git a/project.godot b/project.godot index 4dd694e..0b4e3f1 100644 --- a/project.godot +++ b/project.godot @@ -28,7 +28,7 @@ project/assembly_name="ChickenVSBear" [gui] theme/custom="res://themes/main.tres" -theme/custom_font="res://resources/fonts/syht.ttf" +theme/custom_font="res://resources/fonts/syht.otf" [input] diff --git a/resources/fonts/syht.ttf b/resources/fonts/syht-bold.ttf similarity index 100% rename from resources/fonts/syht.ttf rename to resources/fonts/syht-bold.ttf diff --git a/resources/fonts/syht.ttf.import b/resources/fonts/syht-bold.ttf.import similarity index 67% rename from resources/fonts/syht.ttf.import rename to resources/fonts/syht-bold.ttf.import index f78f354..cee5197 100644 --- a/resources/fonts/syht.ttf.import +++ b/resources/fonts/syht-bold.ttf.import @@ -3,12 +3,12 @@ importer="font_data_dynamic" type="FontFile" uid="uid://v3frxpuvtj5o" -path="res://.godot/imported/syht.ttf-4e5237bd9d733edbe0924500cb0652ef.fontdata" +path="res://.godot/imported/syht-bold.ttf-d2f3da15c712d5ae8c3980a92666acf1.fontdata" [deps] -source_file="res://resources/fonts/syht.ttf" -dest_files=["res://.godot/imported/syht.ttf-4e5237bd9d733edbe0924500cb0652ef.fontdata"] +source_file="res://resources/fonts/syht-bold.ttf" +dest_files=["res://.godot/imported/syht-bold.ttf-d2f3da15c712d5ae8c3980a92666acf1.fontdata"] [params] diff --git a/resources/fonts/syht.otf b/resources/fonts/syht.otf new file mode 100644 index 0000000..73fcdaf Binary files /dev/null and b/resources/fonts/syht.otf differ diff --git a/resources/fonts/syht.otf.import b/resources/fonts/syht.otf.import new file mode 100644 index 0000000..7b18701 --- /dev/null +++ b/resources/fonts/syht.otf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://cidql48uspujd" +path="res://.godot/imported/syht.otf-6c719d9824cc1519958ce5c1d54778a5.fontdata" + +[deps] + +source_file="res://resources/fonts/syht.otf" +dest_files=["res://.godot/imported/syht.otf-6c719d9824cc1519958ce5c1d54778a5.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/scripts/Statemachine/ItemShow.gd b/scripts/Statemachine/ItemShow.gd index 7e75a7b..4c5a087 100644 --- a/scripts/Statemachine/ItemShow.gd +++ b/scripts/Statemachine/ItemShow.gd @@ -5,12 +5,14 @@ class_name ItemShow @export var type: ItemStore.ItemType = ItemStore.ItemType.BASEBALL @export var count: int = 0 @export var autoFree: bool = false +@export var enough: bool = true @onready var avatarTexture: TextureRect = $"%avatar" @onready var countLabel: Label = $"%count" @onready var animator: AnimationPlayer = $"%animator" func _ready(): + countLabel.label_settings = countLabel.label_settings.duplicate() if autoFree: animator.play("show") await animator.animation_finished @@ -21,6 +23,10 @@ func _ready(): func _physics_process(_delta): avatarTexture.texture = ItemStore.getTexture(type) countLabel.text = str(count) + if enough: + countLabel.label_settings.font_color = Color.WHITE + else: + countLabel.label_settings.font_color = Color.RED static func generate(itemType: ItemStore.ItemType, itemCount: int = 1, isAutoFree: bool = false): var item = ComponentManager.getUIComponent("ItemShow").instantiate() diff --git a/scripts/Structs/Feed.gd b/scripts/Structs/Feed.gd index d8330b7..e5195d2 100644 --- a/scripts/Structs/Feed.gd +++ b/scripts/Structs/Feed.gd @@ -29,20 +29,18 @@ func _ready(): rebuildInfo() func allHad(entity: EntityBase) -> bool: - var allHave = true for i in range(min(costs.size(), costCounts.size())): var item = costs[i] - var count = costCounts[i] * multipiler() + var count = countOf(i) if entity.inventory[item] < count: - allHave = false - break - return allHave + return false + return true func apply(entity: EntityBase): var allHave = allHad(entity) if allHave: for i in range(min(costs.size(), costCounts.size())): var item = costs[i] - var count = costCounts[i] * multipiler() + var count = countOf(i) entity.inventory[item] -= count for i in range(min(fields.size(), fieldValues.size())): var field = fields[i] @@ -66,6 +64,8 @@ func apply(entity: EntityBase): hide() selected.emit(allHave) return allHave +func countOf(index: int) -> int: + return ceil(costCounts[index] * multipiler()) func multipiler() -> float: if is_instance_valid(UIState.player): return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION) @@ -106,6 +106,7 @@ func rebuildInfo(): var cost = costs[i] var count = costCounts[i] var costShow: ItemShow = ComponentManager.getUIComponent("ItemShow").instantiate() + costShow.enough = is_instance_valid(UIState.player) and UIState.player.inventory[cost] >= countOf(i) costShow.type = cost costShow.count = int(count * multipiler()) costsBox.add_child(costShow)