diff --git a/components/Abstracts/FeedCardBase.tscn b/components/Abstracts/FeedCardBase.tscn index 84e427e..38de57b 100644 --- a/components/Abstracts/FeedCardBase.tscn +++ b/components/Abstracts/FeedCardBase.tscn @@ -1,7 +1,7 @@ -[gd_scene load_steps=4 format=3 uid="uid://b4cwipt17nh7g"] +[gd_scene load_steps=4 format=3 uid="uid://bykwevnv7keeh"] [ext_resource type="Script" path="res://scripts/Structs/Feed.gd" id="1_2ea75"] -[ext_resource type="Texture2D" uid="uid://b7vxserbhskol" path="res://resources/feeds/banana.svg" id="1_jonms"] +[ext_resource type="Texture2D" uid="uid://dwwpkn4q07ja2" path="res://icon.svg" id="2_b6x2s"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2ewr"] content_margin_left = 30.0 @@ -39,13 +39,17 @@ custom_minimum_size = Vector2(75, 75) layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 0 -texture = ExtResource("1_jonms") +texture = ExtResource("2_b6x2s") +expand_mode = 1 -[node name="name" type="Label" parent="container/info"] +[node name="name" type="RichTextLabel" parent="container/info"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 4 -text = "未命名饲料" +bbcode_enabled = true +text = "[b]未命名饲料[/b]" +fit_content = true +autowrap_mode = 0 [node name="fields" type="VBoxContainer" parent="container"] unique_name_in_owner = true diff --git a/components/Feeds/Banana.tscn b/components/Feeds/Banana.tscn index 2c1344e..d1eceb7 100644 --- a/components/Feeds/Banana.tscn +++ b/components/Feeds/Banana.tscn @@ -1,15 +1,18 @@ [gd_scene load_steps=3 format=3 uid="uid://btisbc7ehj4fo"] -[ext_resource type="PackedScene" uid="uid://b4cwipt17nh7g" path="res://components/Abstracts/FeedCardBase.tscn" id="1_tdrm3"] +[ext_resource type="PackedScene" uid="uid://bykwevnv7keeh" path="res://components/Abstracts/FeedCardBase.tscn" id="1_vapev"] [ext_resource type="Texture2D" uid="uid://b7vxserbhskol" path="res://resources/feeds/banana.svg" id="2_2mlfi"] -[node name="Banana" instance=ExtResource("1_tdrm3")] +[node name="Banana" instance=ExtResource("1_vapev")] avatarTexture = ExtResource("2_2mlfi") displayName = "香蕉" -fields = Array[int]([0, 3, 7]) +fields = Array[int]([0, 3]) fieldValues = Array[float]([10.0, 0.1]) costs = Array[int]([0, 1]) -costCounts = Array[int]([5, 10]) +costCounts = Array[int]([10, 5]) + +[node name="avatar" parent="container/info" index="0"] +texture = ExtResource("2_2mlfi") [node name="name" parent="container/info" index="1"] -text = "香蕉" +text = "[b]香蕉[/b]" diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index 537e330..5c035e9 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -1,7 +1,22 @@ -[gd_scene load_steps=3 format=3 uid="uid://dfwg750a47ggx"] +[gd_scene load_steps=5 format=3 uid="uid://dfwg750a47ggx"] [ext_resource type="PackedScene" uid="uid://ofpg5s3j7esv" path="res://components/UI/BossBar.tscn" id="1_2pe58"] [ext_resource type="Script" path="res://scripts/Statemachine/UIState.gd" id="1_f00a6"] +[ext_resource type="PackedScene" uid="uid://bbm8l3hr4ihar" path="res://components/UI/ItemShow.tscn" id="3_o2oi4"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xmgs2"] +content_margin_left = 10.0 +content_margin_top = 10.0 +content_margin_right = 10.0 +content_margin_bottom = 10.0 +bg_color = Color(0, 0, 0, 0.5) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(0, 0, 0, 0.75) +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 [node name="UI" type="CanvasLayer"] script = ExtResource("1_f00a6") @@ -17,3 +32,26 @@ grow_vertical = 2 [node name="bossbar" parent="root" instance=ExtResource("1_2pe58")] unique_name_in_owner = true layout_mode = 1 + +[node name="items" type="PanelContainer" parent="root"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -46.0 +offset_top = -3.0 +offset_right = 46.0 +offset_bottom = 37.0 +grow_horizontal = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_xmgs2") + +[node name="container" type="HBoxContainer" parent="root/items"] +layout_mode = 2 +alignment = 1 + +[node name="ItemShow" parent="root/items/container" instance=ExtResource("3_o2oi4")] +layout_mode = 2 + +[node name="ItemShow2" parent="root/items/container" instance=ExtResource("3_o2oi4")] +layout_mode = 2 +type = 1 diff --git a/components/UI/FieldShow.tscn b/components/UI/FieldShow.tscn index 8f8c9d0..4b2d62f 100644 --- a/components/UI/FieldShow.tscn +++ b/components/UI/FieldShow.tscn @@ -1,18 +1,20 @@ -[gd_scene load_steps=2 format=3 uid="uid://cw5ip3rw4r3pp"] +[gd_scene load_steps=3 format=3 uid="uid://cw5ip3rw4r3pp"] [ext_resource type="Script" path="res://scripts/Statemachine/FieldShow.gd" id="1_gwocj"] +[ext_resource type="Theme" uid="uid://b6nox1qqh50ub" path="res://themes/smallText.tres" id="2_x62bb"] [node name="FieldShow" type="HBoxContainer"] script = ExtResource("1_gwocj") -value = "0" [node name="name" type="Label" parent="."] unique_name_in_owner = true layout_mode = 2 +theme = ExtResource("2_x62bb") text = "最大生命值" [node name="value" type="Label" parent="."] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 10 +theme = ExtResource("2_x62bb") text = "0" diff --git a/project.godot b/project.godot index 30fedff..2a97bca 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,10 @@ config/icon="res://icon.svg" project/assembly_name="ChickenVSBear" +[gui] + +theme/custom_font="res://resources/fonts/HarmonyOS_Sans_Regular.ttf" + [input] m_up={ diff --git a/resources/fonts/HarmonyOS_Sans_Bold.ttf b/resources/fonts/HarmonyOS_Sans_Bold.ttf new file mode 100644 index 0000000..8ea60c1 Binary files /dev/null and b/resources/fonts/HarmonyOS_Sans_Bold.ttf differ diff --git a/resources/fonts/HarmonyOS_Sans_Bold.ttf.import b/resources/fonts/HarmonyOS_Sans_Bold.ttf.import new file mode 100644 index 0000000..60db4a9 --- /dev/null +++ b/resources/fonts/HarmonyOS_Sans_Bold.ttf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://cptiss3xwl43e" +path="res://.godot/imported/HarmonyOS_Sans_Bold.ttf-c6465f4c2be5f8b7fe7dc626b4041be3.fontdata" + +[deps] + +source_file="res://resources/fonts/HarmonyOS_Sans_Bold.ttf" +dest_files=["res://.godot/imported/HarmonyOS_Sans_Bold.ttf-c6465f4c2be5f8b7fe7dc626b4041be3.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/resources/fonts/HarmonyOS_Sans_Regular.ttf b/resources/fonts/HarmonyOS_Sans_Regular.ttf new file mode 100644 index 0000000..d7eccac Binary files /dev/null and b/resources/fonts/HarmonyOS_Sans_Regular.ttf differ diff --git a/resources/fonts/HarmonyOS_Sans_Regular.ttf.import b/resources/fonts/HarmonyOS_Sans_Regular.ttf.import new file mode 100644 index 0000000..a9f0ca1 --- /dev/null +++ b/resources/fonts/HarmonyOS_Sans_Regular.ttf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://xu1n4fjlwpno" +path="res://.godot/imported/HarmonyOS_Sans_Regular.ttf-93cea29793c46dc5de31972fd2b5131f.fontdata" + +[deps] + +source_file="res://resources/fonts/HarmonyOS_Sans_Regular.ttf" +dest_files=["res://.godot/imported/HarmonyOS_Sans_Regular.ttf-93cea29793c46dc5de31972fd2b5131f.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/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index d96b1dc..8390e8e 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -56,7 +56,7 @@ static func generate( var instance: BulletBase = bullet.instantiate() instance.launcher = launchBy instance.position = spawnPosition - instance.rotation = spawnRotation + randf_range(-launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT), launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT)) + instance.rotation = spawnRotation + deg_to_rad(randf_range(-launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT), launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT))) if addToWorld: WorldManager.rootNode.add_child(instance) return instance diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 5d1d8e8..d92d2a2 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -16,6 +16,10 @@ var fields = { @export var isBoss: bool = false @export var displayName: String = "未知实体" @export var sprintMultiplier: float = 7 +@export var inventory = { + ItemStore.ItemType.BASEBALL: 0, + ItemStore.ItemType.BASKETBALL: 0 +} @onready var animatree: AnimationTree = $"%animatree" @onready var texture: AnimatedSprite2D = $"%texture" diff --git a/scripts/Structs/Feed.gd b/scripts/Structs/Feed.gd index 77015b0..75cd78f 100644 --- a/scripts/Structs/Feed.gd +++ b/scripts/Structs/Feed.gd @@ -2,7 +2,7 @@ extends PanelContainer class_name Feed -@export var avatarTexture: Texture2D = null +@export var avatarTexture: Texture2D = preload("res://icon.svg") @export var displayName: String = "未命名饲料" @export var fields: Array[FieldStore.Entity] = [] @export var fieldValues: Array[float] = [] @@ -10,22 +10,26 @@ class_name Feed @export var costCounts: Array[int] = [] @onready var avatarRect: TextureRect = $"%avatar" -@onready var nameLabel: Label = $"%name" +@onready var nameLabel: RichTextLabel = $"%name" @onready var fieldsBox: VBoxContainer = $"%fields" @onready var costsBox: GridContainer = $"%costs" -func _ready(): +func _process(_delta): avatarRect.texture = avatarTexture - nameLabel.text = displayName + nameLabel.text = "[b]" + displayName + "[/b]" for i in fieldsBox.get_children(): i.queue_free() + var noField = true for i in range(min(fields.size(), fieldValues.size())): + noField = false var field = fields[i] var value = fieldValues[i] var fieldShow: FieldShow = preload("res://components/UI/FieldShow.tscn").instantiate() fieldShow.field = field fieldShow.value = value fieldsBox.add_child(fieldShow) + if noField: + fieldsBox.add_child(QuickUI.smallText("无词条")) for i in costsBox.get_children(): i.queue_free() for i in range(min(costs.size(), costCounts.size())): @@ -35,3 +39,20 @@ func _ready(): costShow.type = cost costShow.count = count costsBox.add_child(costShow) +func apply(entity: EntityBase): + var allHave = true + for i in range(min(costs.size(), costCounts.size())): + var item = costs[i] + var count = costCounts[i] + if entity.inventory[item] < count: + allHave = false + break + if allHave: + for i in range(min(costs.size(), costCounts.size())): + var item = costs[i] + var count = costCounts[i] + entity.inventory[item] -= count + for i in range(min(fields.size(), fieldValues.size())): + var field = fields[i] + var value = fieldValues[i] + entity.fields[field] += value diff --git a/scripts/Tools/QuickUI.gd b/scripts/Tools/QuickUI.gd new file mode 100644 index 0000000..ae7bf73 --- /dev/null +++ b/scripts/Tools/QuickUI.gd @@ -0,0 +1,9 @@ +class_name QuickUI + +static func smallText(text: String, center: bool = true): + var label = Label.new() + label.text = text + label.theme = preload("res://themes/smallText.tres") + if center: + label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + return label diff --git a/themes/bigTextAndBold.tres b/themes/bigTextAndBold.tres new file mode 100644 index 0000000..acfb898 --- /dev/null +++ b/themes/bigTextAndBold.tres @@ -0,0 +1,4 @@ +[gd_resource type="Theme" format=3 uid="uid://bje5cd08dyok7"] + +[resource] +RichTextLabel/font_sizes/bold_font_size = 18 diff --git a/themes/smallText.tres b/themes/smallText.tres new file mode 100644 index 0000000..cfd1016 --- /dev/null +++ b/themes/smallText.tres @@ -0,0 +1,4 @@ +[gd_resource type="Theme" format=3 uid="uid://b6nox1qqh50ub"] + +[resource] +Label/font_sizes/font_size = 13