diff --git a/scripts/Contents/Panels/GameOver.gd b/scripts/Contents/Panels/GameOver.gd index 5c9fc9f..9a9cc14 100644 --- a/scripts/Contents/Panels/GameOver.gd +++ b/scripts/Contents/Panels/GameOver.gd @@ -9,7 +9,5 @@ func beforeOpen(args: Array = []): audio.play() var reasonTemplate = MathTool.randomChoiceFrom(GameRule.deadReasons) deadreason.text = ("[color=gray]" + reasonTemplate + "凶手是[b]%s[/b]的[b]%s[/b]。[/color]") % args - for item in OutGameStorage.inventory: - OutGameStorage.inventory[item] += UIState.player.inventory[item] func afterOpen(_args: Array = []): gameControl.enable() diff --git a/scripts/Contents/Panels/Pause.gd b/scripts/Contents/Panels/Pause.gd index 540f868..afd3663 100644 --- a/scripts/Contents/Panels/Pause.gd +++ b/scripts/Contents/Panels/Pause.gd @@ -1,5 +1,6 @@ @tool extends FullscreenPanelBase +class_name PausePanel @onready var gameControl: GameControl = $%gameControl diff --git a/scripts/Statemachine/TipBox.gd b/scripts/Statemachine/TipBox.gd index fe4e2d4..254a4fb 100644 --- a/scripts/Statemachine/TipBox.gd +++ b/scripts/Statemachine/TipBox.gd @@ -31,6 +31,7 @@ func _process(_delta): label.text = text func destroy(): + if animator.is_playing(): return animator.play("hide") await animator.animation_finished queue_free() diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index f59d56a..ef30fc9 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -15,6 +15,8 @@ static var tips: VBoxContainer static var itemsContainer: Control static var energyContainer: Control +static var showingFields: bool = false + func _ready(): bossbar = $%bossbar panels = $%panels @@ -44,17 +46,22 @@ func _physics_process(_delta): itemsContainer.visible = true energyContainer.visible = true if !fieldsAnimator.is_playing(): - if Input.is_action_just_pressed("showFields"): - for i in fields.get_children(): - fields.remove_child(i) - for i in player.fields: - if player.fields[i] == EntityBase.TITLE_FLAG: - fields.add_child(QuickUI.graySmallText(i)) - else: - fields.add_child(FieldShow.create(i, player.fields[i], false, player, true)) - fieldsAnimator.play("show") - if Input.is_action_just_released("showFields"): - fieldsAnimator.play("hide") + if showingFields: + if Input.is_action_just_released("showFields") || !(currentPanel is PausePanel): + showingFields = false + fieldsAnimator.play("hide") + else: + if Input.is_action_just_pressed("showFields") || currentPanel is PausePanel: + showingFields = true + for i in fields.get_children(): + fields.remove_child(i) + for i in player.fields: + if player.fields[i] == EntityBase.TITLE_FLAG: + fields.add_child(QuickUI.graySmallText(i)) + else: + fields.add_child(FieldShow.create(i, player.fields[i], false, player, true)) + fieldsAnimator.play("show") + if Input.is_action_just_pressed("pause"): if currentPanel: if currentPanel is MakeFeedPanel: @@ -96,5 +103,10 @@ static func closeCurrentPanel(): static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO): var box = TipBox.create(text, messageType) tips.add_child(box) + await box.animator.animation_finished await TickTool.millseconds(500 * len(text)) box.destroy() +static func clearTips(): + for child in tips.get_children(): + if child is TipBox: + child.destroy() diff --git a/scripts/Tools/Managers/GameBusManager.gd b/scripts/Tools/Managers/GameBusManager.gd index c7e0049..9e670bb 100644 --- a/scripts/Tools/Managers/GameBusManager.gd +++ b/scripts/Tools/Managers/GameBusManager.gd @@ -9,6 +9,9 @@ static func restart(tree: SceneTree): effect.queue_free() for item in tree.get_nodes_in_group("items"): item.queue_free() + + OutGameStorage.saveInventory() CameraManager.shakeStop() WorldManager.timeRestart() + UIState.setPanel("Starter") diff --git a/scripts/Tools/OutGameStorage.gd b/scripts/Tools/OutGameStorage.gd index f27817a..3e5c1c3 100644 --- a/scripts/Tools/OutGameStorage.gd +++ b/scripts/Tools/OutGameStorage.gd @@ -19,3 +19,7 @@ static var upgradableFieldsLevel = ArrayTool.fill(upgradableFieldsAdvance, func( static var maxInitialFeedCount: int = 3 static var maxInitialWeaponCount: int = 3 static var inventory = ArrayTool.fill(upgradableFieldsCost, func(_k): return 0) + +static func saveInventory(): + for item in OutGameStorage.inventory: + OutGameStorage.inventory[item] += UIState.player.inventory[item]