mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
refactor(UI): 优化字段显示逻辑并添加平滑相机移动
将字段显示和隐藏逻辑提取为独立方法 为相机添加位置平滑效果 在游戏重启时重置初始饲料选择状态
This commit is contained in:
@@ -85,6 +85,7 @@ limit_left = -2400
|
|||||||
limit_top = -1800
|
limit_top = -1800
|
||||||
limit_right = 2400
|
limit_right = 2400
|
||||||
limit_bottom = 1800
|
limit_bottom = 1800
|
||||||
|
position_smoothing_enabled = true
|
||||||
editor_draw_limits = true
|
editor_draw_limits = true
|
||||||
script = ExtResource("5_mk7bv")
|
script = ExtResource("5_mk7bv")
|
||||||
constantOffset = Vector2(0, -80)
|
constantOffset = Vector2(0, -80)
|
||||||
|
|||||||
@@ -89,7 +89,10 @@ func startSingleplayerGame():
|
|||||||
), OutGameStorage.upgradableFieldsValue)
|
), OutGameStorage.upgradableFieldsValue)
|
||||||
UIState.player = EntityBase.generatePlayer(playerNameInput.text, selectedCharacter, extras)
|
UIState.player = EntityBase.generatePlayer(playerNameInput.text, selectedCharacter, extras)
|
||||||
WorldManager.rootNode.spawnWave(Vector2.ZERO)
|
WorldManager.rootNode.spawnWave(Vector2.ZERO)
|
||||||
|
if buildingShader:
|
||||||
UIState.setPanel("CompilingTip")
|
UIState.setPanel("CompilingTip")
|
||||||
|
else:
|
||||||
|
UIState.setPanel("SelectInitialFeed")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
historyStack = Composables.useHistoryStack(playerNameInput)
|
historyStack = Composables.useHistoryStack(playerNameInput)
|
||||||
|
|||||||
@@ -48,19 +48,10 @@ func _physics_process(_delta):
|
|||||||
if !fieldsAnimator.is_playing():
|
if !fieldsAnimator.is_playing():
|
||||||
if showingFields:
|
if showingFields:
|
||||||
if Input.is_action_just_released("showFields") || !(currentPanel is PausePanel):
|
if Input.is_action_just_released("showFields") || !(currentPanel is PausePanel):
|
||||||
showingFields = false
|
hideFields()
|
||||||
fieldsAnimator.play("hide")
|
|
||||||
else:
|
else:
|
||||||
if Input.is_action_just_pressed("showFields") || currentPanel is PausePanel:
|
if Input.is_action_just_pressed("showFields") || currentPanel is PausePanel:
|
||||||
showingFields = true
|
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_pressed("pause"):
|
if Input.is_action_just_pressed("pause"):
|
||||||
if currentPanel:
|
if currentPanel:
|
||||||
@@ -100,6 +91,7 @@ static func setPanel(targetName: String = "", args: Array = []):
|
|||||||
panel.hidePanel()
|
panel.hidePanel()
|
||||||
static func closeCurrentPanel():
|
static func closeCurrentPanel():
|
||||||
setPanel()
|
setPanel()
|
||||||
|
|
||||||
static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO):
|
static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO):
|
||||||
var box = TipBox.create(text, messageType)
|
var box = TipBox.create(text, messageType)
|
||||||
tips.add_child(box)
|
tips.add_child(box)
|
||||||
@@ -110,3 +102,17 @@ static func clearTips():
|
|||||||
for child in tips.get_children():
|
for child in tips.get_children():
|
||||||
if child is TipBox:
|
if child is TipBox:
|
||||||
child.destroy()
|
child.destroy()
|
||||||
|
|
||||||
|
static func showFields():
|
||||||
|
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")
|
||||||
|
static func hideFields():
|
||||||
|
showingFields = false
|
||||||
|
fieldsAnimator.play("hide")
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ func _physics_process(_delta):
|
|||||||
if is_instance_valid(UIState.player):
|
if is_instance_valid(UIState.player):
|
||||||
position = UIState.player.position + constantOffset
|
position = UIState.player.position + constantOffset
|
||||||
position += MathTool.sampleInCircle(shakeIntensity)
|
position += MathTool.sampleInCircle(shakeIntensity)
|
||||||
offset += ((get_global_mouse_position() - UIState.player.position).clampf(-100, 100) - offset) * 0.15
|
|
||||||
|
|
||||||
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
|
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
|
||||||
if StarterPanel.buildingShader: return
|
if StarterPanel.buildingShader: return
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ static func restart(tree: SceneTree):
|
|||||||
for item in tree.get_nodes_in_group("items"):
|
for item in tree.get_nodes_in_group("items"):
|
||||||
item.queue_free()
|
item.queue_free()
|
||||||
|
|
||||||
|
UIState.hideFields()
|
||||||
OutGameStorage.saveInventory()
|
OutGameStorage.saveInventory()
|
||||||
CameraManager.shakeStop()
|
CameraManager.shakeStop()
|
||||||
WorldManager.timeRestart()
|
WorldManager.timeRestart()
|
||||||
|
StarterPanel.selectingFeed = true
|
||||||
|
|
||||||
UIState.setPanel("Starter")
|
UIState.setPanel("Starter")
|
||||||
|
|||||||
Reference in New Issue
Block a user