diff --git a/components/Abstracts/FeedCardBase.tscn b/components/Abstracts/FeedCardBase.tscn index 38139cc..e448f5e 100644 --- a/components/Abstracts/FeedCardBase.tscn +++ b/components/Abstracts/FeedCardBase.tscn @@ -28,7 +28,7 @@ script = ExtResource("1_2ea75") [node name="container" type="VBoxContainer" parent="."] layout_mode = 2 -theme_override_constants/separation = 20 +theme_override_constants/separation = 10 [node name="selectBtn" type="Button" parent="container"] unique_name_in_owner = true diff --git a/components/Characters/Rooster.tscn b/components/Characters/Rooster.tscn index 689dc19..99a5acb 100644 --- a/components/Characters/Rooster.tscn +++ b/components/Characters/Rooster.tscn @@ -37,6 +37,10 @@ radius = 41.0122 [node name="Rooster" instance=ExtResource("1_e5pl8")] script = ExtResource("2_oqdqd") cooldownUnit = 200.0 +inventory = { +0: 100, +1: 100 +} [node name="sprint" parent="sounds" index="0"] stream = ExtResource("4_66s6c") diff --git a/components/Feeds/Banana.tscn b/components/Feeds/Banana.tscn index d1eceb7..0f7f726 100644 --- a/components/Feeds/Banana.tscn +++ b/components/Feeds/Banana.tscn @@ -6,8 +6,8 @@ [node name="Banana" instance=ExtResource("1_vapev")] avatarTexture = ExtResource("2_2mlfi") displayName = "香蕉" -fields = Array[int]([0, 3]) -fieldValues = Array[float]([10.0, 0.1]) +fields = Array[int]([0, 3, 1]) +fieldValues = Array[float]([10.0, 0.1, 0.1]) costs = Array[int]([0, 1]) costCounts = Array[int]([10, 5]) diff --git a/components/Scenes/FullscreenPanels/MakeFeed.tscn b/components/Scenes/FullscreenPanels/MakeFeed.tscn index 09a8b3c..de501e1 100644 --- a/components/Scenes/FullscreenPanels/MakeFeed.tscn +++ b/components/Scenes/FullscreenPanels/MakeFeed.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=3 format=3 uid="uid://1n28ji5sl6bx"] +[gd_scene load_steps=4 format=3 uid="uid://1n28ji5sl6bx"] [ext_resource type="PackedScene" uid="uid://d3qojeqa3difn" path="res://components/Abstracts/FullscreenPanelBase.tscn" id="1_1wmro"] -[ext_resource type="PackedScene" uid="uid://bykwevnv7keeh" path="res://components/Abstracts/FeedCardBase.tscn" id="2_ae402"] +[ext_resource type="Script" path="res://scripts/Contents/Panels/MakeFeed.gd" id="2_pr610"] +[ext_resource type="PackedScene" uid="uid://btisbc7ehj4fo" path="res://components/Feeds/Banana.tscn" id="3_f2lyw"] [node name="MakeFeed" instance=ExtResource("1_1wmro")] +script = ExtResource("2_pr610") [node name="wrapper" parent="content" index="0"] theme_override_constants/separation = 50 @@ -53,15 +55,19 @@ fit_content = true autowrap_mode = 0 [node name="feedcards" type="HBoxContainer" parent="content/wrapper" index="1"] +unique_name_in_owner = true layout_mode = 2 theme_override_constants/separation = 30 alignment = 1 -[node name="FeedCard" parent="content/wrapper/feedcards" index="0" instance=ExtResource("2_ae402")] -layout_mode = 2 +[node name="avaliableFeeds" type="Node" parent="content/wrapper" index="2"] +unique_name_in_owner = true -[node name="FeedCard2" parent="content/wrapper/feedcards" index="1" instance=ExtResource("2_ae402")] -layout_mode = 2 +[node name="Banana" parent="content/wrapper/avaliableFeeds" index="0" instance=ExtResource("3_f2lyw")] +visible = false -[node name="FeedCard3" parent="content/wrapper/feedcards" index="2" instance=ExtResource("2_ae402")] -layout_mode = 2 +[node name="Banana2" parent="content/wrapper/avaliableFeeds" index="1" instance=ExtResource("3_f2lyw")] +visible = false + +[node name="Banana3" parent="content/wrapper/avaliableFeeds" index="2" instance=ExtResource("3_f2lyw")] +visible = false diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index e63a7f8..c028a9b 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -20,6 +20,7 @@ corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 [node name="UI" type="CanvasLayer"] +process_mode = 3 script = ExtResource("1_f00a6") [node name="root" type="Control" parent="."] @@ -59,7 +60,8 @@ unique_name_in_owner = true layout_mode = 2 type = 1 -[node name="fullscreenPanels" type="Control" parent="root"] +[node name="panels" type="Control" parent="root"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -67,6 +69,6 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="MakeFeed" parent="root/fullscreenPanels" instance=ExtResource("4_kkki3")] +[node name="MakeFeed" parent="root/panels" instance=ExtResource("4_kkki3")] visible = false layout_mode = 1 diff --git a/scripts/Contents/Panels/MakeFeed.gd b/scripts/Contents/Panels/MakeFeed.gd new file mode 100644 index 0000000..452a274 --- /dev/null +++ b/scripts/Contents/Panels/MakeFeed.gd @@ -0,0 +1,23 @@ +extends FullscreenPanelBase + +@onready var avaliableFeeds: Node = $"%avaliableFeeds" +@onready var feedCards: HBoxContainer = $"%feedcards" + +func hideAll(): + for i in avaliableFeeds.get_children(): + i.hide() + +func beforeOpen(): + hideAll() + var feeds = [] + for i in avaliableFeeds.get_children(): + feeds.append(i) + feeds.shuffle() + for i in range(3): + var feed = feeds[i] + var cloned = feed.duplicate() + cloned.show() + feedCards.add_child(cloned) +func afterClose(): + for i in feedCards.get_children(): + feedCards.remove_child(i) diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index 90c30eb..4099236 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -13,7 +13,7 @@ static var countBoost: float = 0.1 # 每波增加的敌人数量百分比,指 static var data: Array[Wave] = [ # entity, minCount, maxCount, isBoss, from, to, per create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1), - create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 1, INF, 2) + create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 8, INF, 1) ] static func create( diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index a674529..75f87d3 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -74,7 +74,7 @@ func move(direction: Vector2, isSprinting: bool = false): lastDirection = currentDirection func takeDamage(bullet: BulletBase, crit: bool): hurtAnimator.play("hurt") - var baseDamage: float = bullet.fields.get(FieldStore.Bullet.DAMAGE) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset) + var baseDamage: float = bullet.fields.get(FieldStore.Bullet.DAMAGE) * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset) var damage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE) if sprinting: playSound("miss") diff --git a/scripts/Statemachine/FieldShow.gd b/scripts/Statemachine/FieldShow.gd index ef531cb..9eef6ae 100644 --- a/scripts/Statemachine/FieldShow.gd +++ b/scripts/Statemachine/FieldShow.gd @@ -8,7 +8,7 @@ class_name FieldShow @onready var nameLabel: Label = $"%name" @onready var valueLabel: Label = $"%value" -func _physics_process(_delta): +func _ready(): nameLabel.text = FieldStore.entityMap[field] var formattedValue: String var dataType = FieldStore.entityMapType[field] diff --git a/scripts/Statemachine/FullscreenPanelBase.gd b/scripts/Statemachine/FullscreenPanelBase.gd index e07a0bf..d49e22c 100644 --- a/scripts/Statemachine/FullscreenPanelBase.gd +++ b/scripts/Statemachine/FullscreenPanelBase.gd @@ -1 +1,25 @@ +@tool extends Control +class_name FullscreenPanelBase + +@onready var animator = $"%animator" + +func hidePanel(): + animator.play("hide") + await animator.animation_finished + visible = false + afterClose() +func showPanel(): + beforeOpen() + visible = true + animator.play("show") + await animator.animation_finished + +func _ready(): + visible = false + +# 钩子 +func beforeOpen(): + pass +func afterClose(): + pass diff --git a/scripts/Statemachine/ItemShow.gd b/scripts/Statemachine/ItemShow.gd index 8412eac..ff4ada5 100644 --- a/scripts/Statemachine/ItemShow.gd +++ b/scripts/Statemachine/ItemShow.gd @@ -8,6 +8,6 @@ class_name ItemShow @onready var avatarTexture: TextureRect = $"%avatar" @onready var countLabel: Label = $"%count" -func _physics_process(_delta: float): +func _ready(): avatarTexture.texture = ItemStore.getTexture(type) countLabel.text = str(count) diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index 19eae72..9062057 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -6,12 +6,29 @@ class_name UIState static var player: EntityBase = null static var bossbar: EntityStateBar +static var currentPanel: FullscreenPanelBase = null +static var panels: Control func _ready(): bossbar = $"%bossbar" + panels = $"%panels" func _process(_delta): bossbar.visible = !!bossbar.entity func _physics_process(_delta): if is_instance_valid(player): baseball.count = player.inventory[ItemStore.ItemType.BASEBALL] basketball.count = player.inventory[ItemStore.ItemType.BASKETBALL] + if currentPanel: + WorldManager.rootNode.process_mode = Node.PROCESS_MODE_DISABLED + else: + WorldManager.rootNode.process_mode = Node.PROCESS_MODE_INHERIT + +static func setPanel(targetName: String = ""): + currentPanel = null + for panel in panels.get_children(): + if panel is FullscreenPanelBase: + if panel.name == targetName: + currentPanel = panel + panel.showPanel() + else: + panel.hidePanel() diff --git a/scripts/Structs/Feed.gd b/scripts/Structs/Feed.gd index 4e8a833..a175834 100644 --- a/scripts/Structs/Feed.gd +++ b/scripts/Structs/Feed.gd @@ -18,10 +18,11 @@ class_name Feed func _ready(): selectButton.pressed.connect( func(): - apply(UIState.player) - queue_free() + if apply(UIState.player): + UIState.setPanel() + queue_free() + Wave.next() ) -func _process(_delta): avatarRect.texture = avatarTexture nameLabel.text = "[b]" + displayName + "[/b]" for i in fieldsBox.get_children(): @@ -64,3 +65,7 @@ func apply(entity: EntityBase): var field = fields[i] var value = fieldValues[i] entity.fields[field] += value + if field == FieldStore.Entity.MAX_HEALTH: + entity.health += value + print(entity.fields) + return allHave diff --git a/scripts/Tools/GameRule.gd b/scripts/Tools/GameRule.gd index 8e1a32c..f6867fe 100644 --- a/scripts/Tools/GameRule.gd +++ b/scripts/Tools/GameRule.gd @@ -4,4 +4,4 @@ static var allowFriendlyFire: bool = false # 是否允许友军伤害 static var bulletSpeedMultiplier: float = 1 # 子弹速度倍率 static var damageOffset: float = 0.2 # 伤害随机浮动比例,默认20%,即10的基础伤害会应用为8~12 static var damageLabelSpawnOffset: float = 10 # 伤害标签生成位置的随机偏移 -static var itemDroppedSpawnOffset: float = 10 # 掉落物生成位置的随机偏移 +static var itemDroppedSpawnOffset: float = 30 # 掉落物生成位置的随机偏移 diff --git a/scripts/Tools/WorldManager.gd b/scripts/Tools/WorldManager.gd index 5c9d81e..f149474 100644 --- a/scripts/Tools/WorldManager.gd +++ b/scripts/Tools/WorldManager.gd @@ -9,4 +9,4 @@ func _ready(): rootNode = self func _physics_process(_delta): if EntityBase.mobCount() == 0: - Wave.next() + UIState.setPanel("MakeFeed")