mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat: 添加局外养成系统和游戏结束面板改进
添加新的物品类型紫水晶和钻石 实现局外属性升级系统 改进游戏结束面板的返回和退出功能 添加新的UI组件用于显示属性和物品 更新游戏规则和存储系统以支持局外养成
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
@tool
|
||||
extends FullscreenPanelBase
|
||||
|
||||
@onready var audio: AudioStreamPlayer2D = $"%audio"
|
||||
@onready var deadreason: RichTextLabel = $"%deadreason"
|
||||
@onready var audio: AudioStreamPlayer2D = $%audio
|
||||
@onready var deadreason: RichTextLabel = $%deadreason
|
||||
@onready var returnBtn: Button = $%returnBtn
|
||||
@onready var exitBtn: Button = $%exitBtn
|
||||
|
||||
func _ready():
|
||||
returnBtn.pressed.connect(
|
||||
func():
|
||||
returnBtn.disabled = true
|
||||
for bullet in get_tree().get_nodes_in_group("bullets"):
|
||||
bullet.queue_free()
|
||||
for entity in get_tree().get_nodes_in_group("entities"):
|
||||
entity.queue_free()
|
||||
UIState.setPanel("Starter")
|
||||
)
|
||||
exitBtn.pressed.connect(
|
||||
func():
|
||||
get_tree().quit()
|
||||
)
|
||||
|
||||
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
|
||||
func afterOpen(_args: Array = []):
|
||||
returnBtn.disabled = false
|
||||
exitBtn.disabled = false
|
||||
|
||||
@@ -7,6 +7,10 @@ class_name StarterPanel
|
||||
@onready var gamemodeOption: OptionButton = $%gamemodeOption
|
||||
@onready var useTutorialBtn: Button = $%useTutorialBtn
|
||||
|
||||
@onready var upgradeFieldsBox: Control = $%upgradeFields
|
||||
@onready var crystalShow: ItemShow = $%crystal
|
||||
@onready var diamondShow: ItemShow = $%diamond
|
||||
|
||||
@onready var startSingleplayerBtn: Button = $%startSingleplayerBtn
|
||||
@onready var startMultiplayerBtn: Button = $%startMultiplayerBtn
|
||||
@onready var levelShow: Label = $%levelShow
|
||||
@@ -81,9 +85,6 @@ func startSingleplayerGame():
|
||||
|
||||
func _ready():
|
||||
historyStack = Composables.useHistoryStack(playerNameInput)
|
||||
diffEdit.min_value = GameRule.difficultyRange.x
|
||||
diffEdit.max_value = GameRule.difficultyRange.y
|
||||
diffEdit.value = GameRule.difficulty
|
||||
useTutorialBtn.toggled.connect(
|
||||
func(on: bool):
|
||||
useTutorialBtn.text = "观看" if on else "跳过"
|
||||
@@ -134,7 +135,6 @@ func _ready():
|
||||
setPlayerName(getLast.call(1), newText)
|
||||
mutexPlayer.rpc(newText)
|
||||
)
|
||||
setState(MultiplayerState.ConnectionState.DISCONNECTED)
|
||||
func _physics_process(_delta):
|
||||
levelShow.text = "%d ∈ [%d, %d]" % [diffEdit.value, diffEdit.min_value, diffEdit.max_value]
|
||||
GameRule.difficulty = diffEdit.value
|
||||
@@ -158,3 +158,32 @@ func getPlayerNames() -> Array[String]:
|
||||
for i in playersList.get_children():
|
||||
result.append(i.text)
|
||||
return result
|
||||
|
||||
func beforeOpen(_args: Array = []):
|
||||
diffEdit.min_value = GameRule.difficultyRange.x
|
||||
diffEdit.max_value = GameRule.difficultyRange.y
|
||||
diffEdit.value = GameRule.difficulty
|
||||
setState(MultiplayerState.ConnectionState.DISCONNECTED)
|
||||
|
||||
crystalShow.count = OutGameStorage.inventory[ItemStore.ItemType.CRYSTAL]
|
||||
diamondShow.count = OutGameStorage.inventory[ItemStore.ItemType.DIAMOND]
|
||||
for child in upgradeFieldsBox.get_children():
|
||||
upgradeFieldsBox.remove_child(child)
|
||||
for field in OutGameStorage.upgradableFieldsAdvance:
|
||||
var fieldShow = ComponentManager.getUIComponent("FieldShow").instantiate() as FieldShow
|
||||
fieldShow.cost(ItemStore.ItemType.CRYSTAL, 50)
|
||||
fieldShow.cost(ItemStore.ItemType.DIAMOND, 1)
|
||||
fieldShow.upgradable = true
|
||||
fieldShow.upgradeValue = OutGameStorage.upgradableFieldsAdvance[field]
|
||||
fieldShow.field = field
|
||||
fieldShow.value = OutGameStorage.upgradableFieldsValue[field]
|
||||
fieldShow.showAdvantage = true
|
||||
fieldShow.upgrade.connect(
|
||||
func(newValue: float):
|
||||
OutGameStorage.upgradableFieldsValue[fieldShow.field] = newValue
|
||||
for index in len(fieldShow.costCounts):
|
||||
fieldShow.costCounts[index] *= GameRule.outGameUpgradeMultipiler
|
||||
)
|
||||
upgradeFieldsBox.add_child(fieldShow)
|
||||
|
||||
startSingleplayerBtn.disabled = false
|
||||
|
||||
@@ -560,6 +560,7 @@ static func generate(
|
||||
instance.add_to_group("mobs")
|
||||
else:
|
||||
instance.add_to_group("players")
|
||||
instance.add_to_group("entities")
|
||||
if addToWorld:
|
||||
WorldManager.rootNode.spawn(instance)
|
||||
return instance
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
extends HBoxContainer
|
||||
class_name FieldShow
|
||||
|
||||
signal upgrade(newValue: float)
|
||||
|
||||
@export var field: FieldStore.Entity = FieldStore.Entity.MAX_HEALTH
|
||||
@export var value: float = 0
|
||||
@export var showSign: bool = true
|
||||
@@ -9,19 +11,40 @@ class_name FieldShow
|
||||
@export var useViewCast: bool = false
|
||||
@export var maxed: bool = false
|
||||
@export var showAdvantage: bool = false
|
||||
@export var upgradable: bool = false
|
||||
@export var upgradeValue: float = 0
|
||||
@export var costItems: Array[ItemStore.ItemType] = []
|
||||
@export var costCounts: Array[int] = []
|
||||
|
||||
@onready var icon: TextureRect = $"%icon"
|
||||
@onready var nameLabel: Label = $"%name"
|
||||
@onready var valueLabel: Label = $"%value"
|
||||
@onready var icon: TextureRect = $%icon
|
||||
@onready var nameLabel: Label = $%name
|
||||
@onready var valueLabel: Label = $%value
|
||||
@onready var upgradesBox: Control = $%upgrades
|
||||
@onready var upgradeBtn: Button = $%upgradeBtn
|
||||
@onready var costsBox: Control = $%cost
|
||||
|
||||
func _ready():
|
||||
valueLabel.label_settings = valueLabel.label_settings.duplicate()
|
||||
upgradeBtn.pressed.connect(
|
||||
func():
|
||||
if upgradable:
|
||||
if enoughToUpgrade():
|
||||
value += upgradeValue
|
||||
upgrade.emit(value)
|
||||
rebuildInfo()
|
||||
else:
|
||||
UIState.showTip("物品不足!", TipBox.MessageType.ERROR)
|
||||
)
|
||||
rebuildInfo()
|
||||
|
||||
func rebuildInfo():
|
||||
nameLabel.text = FieldStore.entityMap[field]
|
||||
icon.texture = ComponentManager.getFieldTexture(FieldStore.entityMap.get(field))
|
||||
if useViewCast:
|
||||
var caster = FieldStore.entityViewCastMap.get(field)
|
||||
if caster:
|
||||
value = caster.call(entity, value)
|
||||
nameLabel.text = FieldStore.entityMap[field]
|
||||
icon.texture = ComponentManager.getFieldTexture(FieldStore.entityMap.get(field))
|
||||
var formattedValue: String
|
||||
var formattedValue: String = ""
|
||||
var dataType = FieldStore.entityMapType[field]
|
||||
if dataType == FieldStore.DataType.VALUE:
|
||||
formattedValue = "%s" % (MathTool.toSigned(value) if showSign else str(value))
|
||||
@@ -31,18 +54,46 @@ func _ready():
|
||||
formattedValue = "%s°" % (MathTool.toSigned(value) if showSign else str(value))
|
||||
elif dataType == FieldStore.DataType.PERCENT:
|
||||
formattedValue = (MathTool.toSigned(value * 100) if showSign else str(value * 100)) + "%"
|
||||
valueLabel.label_settings = valueLabel.label_settings.duplicate()
|
||||
valueLabel.text = formattedValue
|
||||
if maxed:
|
||||
valueLabel.label_settings.font_color = Color(1, 0.3, 0.3)
|
||||
valueLabel.text = "MAX%s" % valueLabel.text
|
||||
elif showAdvantage:
|
||||
if field in FieldStore.entityNegativeFields:
|
||||
valueLabel.label_settings.font_color = Color.RED if value > 0 else Color.GREEN
|
||||
if value == 0:
|
||||
valueLabel.label_settings.font_color = Color.WHITE
|
||||
else:
|
||||
valueLabel.label_settings.font_color = Color.GREEN if value > 0 else Color.RED
|
||||
if field in FieldStore.entityNegativeFields:
|
||||
valueLabel.label_settings.font_color = Color.RED if value > 0 else Color.GREEN
|
||||
else:
|
||||
valueLabel.label_settings.font_color = Color.GREEN if value > 0 else Color.RED
|
||||
else:
|
||||
valueLabel.label_settings.font_color = Color(1, 1, 1)
|
||||
upgradesBox.visible = upgradable
|
||||
for child in costsBox.get_children():
|
||||
costsBox.remove_child(child)
|
||||
for index in len(costItems):
|
||||
var item = costItems[index]
|
||||
var itemShow = ComponentManager.getUIComponent("ItemShow").instantiate() as ItemShow
|
||||
itemShow.type = item
|
||||
itemShow.count = costCounts[index]
|
||||
itemShow.enough = OutGameStorage.inventory[item] >= costCounts[index]
|
||||
costsBox.add_child(itemShow)
|
||||
func enoughToUpgrade():
|
||||
var result = true
|
||||
for child in costsBox.get_children():
|
||||
if child is ItemShow:
|
||||
if !child.enough:
|
||||
result = false
|
||||
break
|
||||
return result
|
||||
func cost(item: ItemStore.ItemType, count: int):
|
||||
for index in len(costItems):
|
||||
var itemd = costItems[index]
|
||||
if itemd == item:
|
||||
costCounts[index] += count
|
||||
break
|
||||
costItems.append(item)
|
||||
costCounts.append(count)
|
||||
|
||||
static func create(newField: FieldStore.Entity, newValue: float, newShowSign: bool, newEntity: EntityBase, newUseViewCast: bool) -> FieldShow:
|
||||
var fieldShow = ComponentManager.getUIComponent("FieldShow").instantiate()
|
||||
|
||||
@@ -105,7 +105,7 @@ static var entityMaxValueMap = {
|
||||
Entity.CRIT_RATE: 0.9,
|
||||
Entity.PENERATE: 0.9,
|
||||
Entity.PENARATION_RESISTANCE: 1,
|
||||
Entity.PRICE_REDUCTION: 0.7,
|
||||
Entity.PRICE_REDUCTION: 0.85,
|
||||
Entity.DROP_APPLE_RATE: 0.3,
|
||||
Entity.FEED_COUNT_SHOW: 5,
|
||||
Entity.BULLET_TRACE: 1,
|
||||
|
||||
@@ -23,3 +23,4 @@ static var penerateRateInfluenceByLuckValue: float = MathTool.percent(3) # 幸
|
||||
static var detainTime: float = 250 # 血量如果在这个时间内没有改变才会开始播放降低动画
|
||||
static var weaponUpdateCost: float = 1.1 # 武器升级后消耗的棒球数量倍数
|
||||
static var canSpawnMobWhenBossWave: bool = true # Boss波次是否可生成小怪
|
||||
static var outGameUpgradeMultipiler: float = 2 # 局外养成升级后物品消耗倍率
|
||||
|
||||
@@ -7,6 +7,8 @@ enum ItemType {
|
||||
APPLE,
|
||||
BEACHBALL,
|
||||
SOUL,
|
||||
CRYSTAL,
|
||||
DIAMOND
|
||||
}
|
||||
static var nameMap = {
|
||||
ItemType.BASEBALL: "棒球",
|
||||
@@ -14,6 +16,8 @@ static var nameMap = {
|
||||
ItemType.APPLE: "苹果",
|
||||
ItemType.BEACHBALL: "沙滩球",
|
||||
ItemType.SOUL: "灵魂",
|
||||
ItemType.CRYSTAL: "紫水晶",
|
||||
ItemType.DIAMOND: "钻石"
|
||||
}
|
||||
static var idMap = {
|
||||
ItemType.BASEBALL: "baseball",
|
||||
@@ -21,6 +25,8 @@ static var idMap = {
|
||||
ItemType.APPLE: "apple",
|
||||
ItemType.BEACHBALL: "beachball",
|
||||
ItemType.SOUL: "soul",
|
||||
ItemType.CRYSTAL: "crystal",
|
||||
ItemType.DIAMOND: "diamond"
|
||||
}
|
||||
static func getTexture(type: ItemType) -> Texture2D:
|
||||
return ComponentManager.getItemTexture(idMap.get(type, "baseball"))
|
||||
|
||||
@@ -2,3 +2,20 @@ class_name OutGameStorage
|
||||
|
||||
static var maxInitialFeedCount: int = 3
|
||||
static var maxInitialWeaponCount: int = 3
|
||||
static var inventory = {
|
||||
ItemStore.ItemType.CRYSTAL: 0,
|
||||
ItemStore.ItemType.DIAMOND: 0
|
||||
}
|
||||
|
||||
static var upgradableFieldsAdvance = {
|
||||
FieldStore.Entity.MAX_HEALTH: 10,
|
||||
FieldStore.Entity.DAMAGE_MULTIPILER: 0.1,
|
||||
FieldStore.Entity.ATTACK_SPEED: 0.05,
|
||||
FieldStore.Entity.PRICE_REDUCTION: 0.02
|
||||
}
|
||||
static var upgradableFieldsValue = {
|
||||
FieldStore.Entity.MAX_HEALTH: 0,
|
||||
FieldStore.Entity.DAMAGE_MULTIPILER: 0,
|
||||
FieldStore.Entity.ATTACK_SPEED: 0,
|
||||
FieldStore.Entity.PRICE_REDUCTION: 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user