mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-07-02 00:02:13 +08:00
feat(角色系统): 重构角色生成和升级系统
- 在EntityBase.gd中修改角色生成逻辑,使用FeedCardBase初始化角色属性 - 调整OutGameStorage.gd中的升级字段初始值和成本配置 - 在ComponentManager.gd中添加抽象组件管理功能 - 更新Rooster.tscn的默认武器为ChainGun - 在Starter.gd中优化升级界面刷新逻辑,提取rebuildInfo方法 - 在MakeFeed.gd中添加feed卡片重建功能
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_e5pl8"]
|
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_e5pl8"]
|
||||||
[ext_resource type="Script" uid="uid://cthtupc6dtbav" path="res://scripts/Contents/Characters/Rooster.gd" id="2_oqdqd"]
|
[ext_resource type="Script" uid="uid://cthtupc6dtbav" path="res://scripts/Contents/Characters/Rooster.gd" id="2_oqdqd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c0n3igy4hucrg" path="res://components/Weapons/PurpleCrystal.tscn" id="3_s7kxe"]
|
[ext_resource type="PackedScene" uid="uid://dlaks67h2osms" path="res://components/Weapons/ChainGun.tscn" id="3_s7kxe"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"]
|
[ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"]
|
||||||
[ext_resource type="AudioStream" uid="uid://benyec5bqni0b" path="res://resources/sounds/effect/Chomp.wav" id="4_k0yme"]
|
[ext_resource type="AudioStream" uid="uid://benyec5bqni0b" path="res://resources/sounds/effect/Chomp.wav" id="4_k0yme"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dmxh3bpk8vyy5" path="res://resources/sounds/effect/Coin.mp3" id="5_xnbhq"]
|
[ext_resource type="AudioStream" uid="uid://dmxh3bpk8vyy5" path="res://resources/sounds/effect/Coin.mp3" id="5_xnbhq"]
|
||||||
@@ -97,7 +97,8 @@ process_material = SubResource("ParticleProcessMaterial_joj4g")
|
|||||||
[node name="weaponStore" parent="." index="2"]
|
[node name="weaponStore" parent="." index="2"]
|
||||||
process_mode = 4
|
process_mode = 4
|
||||||
|
|
||||||
[node name="PurpleCrystal" parent="weaponStore" index="0" unique_id=1991730660 instance=ExtResource("3_s7kxe")]
|
[node name="ChainGun" parent="weaponStore" index="0" unique_id=1992324853 instance=ExtResource("3_s7kxe")]
|
||||||
|
debugRebuild = false
|
||||||
|
|
||||||
[node name="sprint" parent="sounds" index="0"]
|
[node name="sprint" parent="sounds" index="0"]
|
||||||
stream = ExtResource("4_66s6c")
|
stream = ExtResource("4_66s6c")
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ func _ready():
|
|||||||
updateValue()
|
updateValue()
|
||||||
if selectedCount >= UIState.player.fields[FieldStore.Entity.FEED_COUNT_CAN_MADE]:
|
if selectedCount >= UIState.player.fields[FieldStore.Entity.FEED_COUNT_CAN_MADE]:
|
||||||
finish()
|
finish()
|
||||||
|
for feedCard in feedCards.get_children():
|
||||||
|
if feedCard is Feed:
|
||||||
|
feed.rebuildInfo()
|
||||||
)
|
)
|
||||||
avaliableFeeds.add_child(feed)
|
avaliableFeeds.add_child(feed)
|
||||||
|
|
||||||
|
|||||||
@@ -164,15 +164,19 @@ func beforeOpen(_args: Array = []):
|
|||||||
diffEdit.max_value = GameRule.difficultyRange.y
|
diffEdit.max_value = GameRule.difficultyRange.y
|
||||||
diffEdit.value = GameRule.difficulty
|
diffEdit.value = GameRule.difficulty
|
||||||
setState(MultiplayerState.ConnectionState.DISCONNECTED)
|
setState(MultiplayerState.ConnectionState.DISCONNECTED)
|
||||||
|
rebuildInfo()
|
||||||
|
startSingleplayerBtn.disabled = false
|
||||||
|
Wave.current = 0
|
||||||
|
|
||||||
|
func rebuildInfo():
|
||||||
crystalShow.count = OutGameStorage.inventory[ItemStore.ItemType.CRYSTAL]
|
crystalShow.count = OutGameStorage.inventory[ItemStore.ItemType.CRYSTAL]
|
||||||
diamondShow.count = OutGameStorage.inventory[ItemStore.ItemType.DIAMOND]
|
diamondShow.count = OutGameStorage.inventory[ItemStore.ItemType.DIAMOND]
|
||||||
for child in upgradeFieldsBox.get_children():
|
for child in upgradeFieldsBox.get_children():
|
||||||
upgradeFieldsBox.remove_child(child)
|
upgradeFieldsBox.remove_child(child)
|
||||||
for field in OutGameStorage.upgradableFieldsAdvance:
|
for field in OutGameStorage.upgradableFieldsAdvance:
|
||||||
var fieldShow = ComponentManager.getUIComponent("FieldShow").instantiate() as FieldShow
|
var fieldShow = ComponentManager.getUIComponent("FieldShow").instantiate() as FieldShow
|
||||||
fieldShow.cost(ItemStore.ItemType.CRYSTAL, 50 * OutGameStorage.upgradableFieldsLevel[fieldShow.field])
|
fieldShow.cost(ItemStore.ItemType.CRYSTAL, OutGameStorage.upgradableFieldsCost[ItemStore.ItemType.CRYSTAL] * (OutGameStorage.upgradableFieldsLevel[field] + 1))
|
||||||
fieldShow.cost(ItemStore.ItemType.DIAMOND, OutGameStorage.upgradableFieldsLevel[fieldShow.field] - 1)
|
fieldShow.cost(ItemStore.ItemType.DIAMOND, OutGameStorage.upgradableFieldsCost[ItemStore.ItemType.DIAMOND] * OutGameStorage.upgradableFieldsLevel[field])
|
||||||
fieldShow.upgradable = true
|
fieldShow.upgradable = true
|
||||||
fieldShow.upgradeValue = OutGameStorage.upgradableFieldsAdvance[field]
|
fieldShow.upgradeValue = OutGameStorage.upgradableFieldsAdvance[field]
|
||||||
fieldShow.field = field
|
fieldShow.field = field
|
||||||
@@ -182,13 +186,6 @@ func beforeOpen(_args: Array = []):
|
|||||||
func(newValue: float):
|
func(newValue: float):
|
||||||
OutGameStorage.upgradableFieldsValue[fieldShow.field] = newValue
|
OutGameStorage.upgradableFieldsValue[fieldShow.field] = newValue
|
||||||
OutGameStorage.upgradableFieldsLevel[fieldShow.field] += 1
|
OutGameStorage.upgradableFieldsLevel[fieldShow.field] += 1
|
||||||
for index in len(fieldShow.costCounts):
|
rebuildInfo()
|
||||||
if fieldShow.costCounts[index] == 0:
|
|
||||||
fieldShow.costCounts[index] += 1
|
|
||||||
else:
|
|
||||||
fieldShow.costCounts[index] *= (OutGameStorage.upgradableFieldsLevel[fieldShow.field] + 1) / OutGameStorage.upgradableFieldsLevel[fieldShow.field]
|
|
||||||
)
|
)
|
||||||
upgradeFieldsBox.add_child(fieldShow)
|
upgradeFieldsBox.add_child(fieldShow)
|
||||||
|
|
||||||
startSingleplayerBtn.disabled = false
|
|
||||||
Wave.current = 0
|
|
||||||
|
|||||||
@@ -560,8 +560,12 @@ static func generatePlayer(playerName: String) -> EntityBase:
|
|||||||
var player = generate(ComponentManager.getCharacter("Rooster"), Vector2.ZERO, false)
|
var player = generate(ComponentManager.getCharacter("Rooster"), Vector2.ZERO, false)
|
||||||
player.displayName = playerName
|
player.displayName = playerName
|
||||||
player.name = "Player_%s" % playerName
|
player.name = "Player_%s" % playerName
|
||||||
|
var feed = ComponentManager.getAbstract("FeedCardBase").instantiate() as Feed
|
||||||
for field in OutGameStorage.upgradableFieldsValue:
|
for field in OutGameStorage.upgradableFieldsValue:
|
||||||
player.fields[field] += OutGameStorage.upgradableFieldsValue[field]
|
feed.fields.append(field)
|
||||||
|
feed.fieldValues.append(OutGameStorage.upgradableFieldsValue[field])
|
||||||
|
feed.freeToBuy = true
|
||||||
|
feed.apply(player)
|
||||||
return player
|
return player
|
||||||
static func generate(
|
static func generate(
|
||||||
entity: PackedScene,
|
entity: PackedScene,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
extends Node
|
extends Node
|
||||||
class_name ComponentManager
|
class_name ComponentManager
|
||||||
|
|
||||||
|
static var abstracts = {}
|
||||||
static var bullets = {}
|
static var bullets = {}
|
||||||
static var characters = {}
|
static var characters = {}
|
||||||
static var weapons = {}
|
static var weapons = {}
|
||||||
@@ -16,6 +17,8 @@ static var fieldTextures = {}
|
|||||||
static var itemTextures = {}
|
static var itemTextures = {}
|
||||||
|
|
||||||
static func init():
|
static func init():
|
||||||
|
for i in DirTool.listdir("res://components/Abstracts"):
|
||||||
|
abstracts[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
for i in DirTool.listdir("res://components/Bullets"):
|
for i in DirTool.listdir("res://components/Bullets"):
|
||||||
bullets[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
bullets[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
for i in DirTool.listdir("res://components/Characters"):
|
for i in DirTool.listdir("res://components/Characters"):
|
||||||
@@ -40,6 +43,9 @@ static func init():
|
|||||||
fieldTextures[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
fieldTextures[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
for i in DirTool.listdir("res://resources/items"):
|
for i in DirTool.listdir("res://resources/items"):
|
||||||
itemTextures[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
itemTextures[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
|
|
||||||
|
static func getAbstract(t: String) -> PackedScene:
|
||||||
|
return MathTool.priority(abstracts.get(t, false), load("res://components/Abstracts/%s.tscn" % t))
|
||||||
static func getBullet(t: String) -> PackedScene:
|
static func getBullet(t: String) -> PackedScene:
|
||||||
return MathTool.priority(bullets.get(t, false), load("res://components/Bullets/%s.tscn" % t))
|
return MathTool.priority(bullets.get(t, false), load("res://components/Bullets/%s.tscn" % t))
|
||||||
static func getCharacter(t: String) -> PackedScene:
|
static func getCharacter(t: String) -> PackedScene:
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ static var inventory = {
|
|||||||
ItemStore.ItemType.DIAMOND: 0
|
ItemStore.ItemType.DIAMOND: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static var upgradableFieldsCost = {
|
||||||
|
ItemStore.ItemType.CRYSTAL: 50,
|
||||||
|
ItemStore.ItemType.DIAMOND: 1,
|
||||||
|
}
|
||||||
static var upgradableFieldsAdvance = {
|
static var upgradableFieldsAdvance = {
|
||||||
FieldStore.Entity.MAX_HEALTH: 10,
|
FieldStore.Entity.MAX_HEALTH: 10,
|
||||||
FieldStore.Entity.DAMAGE_MULTIPILER: 0.1,
|
FieldStore.Entity.DAMAGE_MULTIPILER: 0.1,
|
||||||
@@ -20,8 +24,8 @@ static var upgradableFieldsValue = {
|
|||||||
FieldStore.Entity.PRICE_REDUCTION: 0,
|
FieldStore.Entity.PRICE_REDUCTION: 0,
|
||||||
}
|
}
|
||||||
static var upgradableFieldsLevel = {
|
static var upgradableFieldsLevel = {
|
||||||
FieldStore.Entity.MAX_HEALTH: 1,
|
FieldStore.Entity.MAX_HEALTH: 0,
|
||||||
FieldStore.Entity.DAMAGE_MULTIPILER: 1,
|
FieldStore.Entity.DAMAGE_MULTIPILER: 0,
|
||||||
FieldStore.Entity.ATTACK_SPEED: 1,
|
FieldStore.Entity.ATTACK_SPEED: 0,
|
||||||
FieldStore.Entity.PRICE_REDUCTION: 1,
|
FieldStore.Entity.PRICE_REDUCTION: 0,
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user