Merge branch 'dev_UI' into dev
This commit is contained in:
+7
-1
@@ -115,4 +115,10 @@ func load_from_dict(d) -> void
|
|||||||
```mermaid
|
```mermaid
|
||||||
graph TD
|
graph TD
|
||||||
A[分配属性总量,按正正态分布] --> B[随机分配5种属性,属性之和为1] --> C[分配灵气利用率]
|
A[分配属性总量,按正正态分布] --> B[随机分配5种属性,属性之和为1] --> C[分配灵气利用率]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 修炼说明
|
||||||
|
|
||||||
|
每个小境界修炼需要的经验 = 基础经验值 * 属性总量
|
||||||
|
|
||||||
|
经验获取量 = 基础经验 * 灵气吸收效率
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ config/icon="res://icon.svg"
|
|||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
GameState="*res://src/Core/GameState.gd"
|
GameState="*res://src/Core/GameState.gd"
|
||||||
TimeSystem="*res://src/Core/TimeSystem.gd"
|
|
||||||
Settings="*res://src/Core/Settings.gd"
|
Settings="*res://src/Core/Settings.gd"
|
||||||
SaveSystem="*res://src/Core/SaveSystem.gd"
|
SaveSystem="*res://src/Core/SaveSystem.gd"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
# 初始版本不提供添加弟子的接口
|
# 初始版本不提供添加弟子的接口
|
||||||
|
|
||||||
|
|
||||||
class_name DiscipleManager
|
class_name DiscipleManager
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@@ -14,6 +12,7 @@ const INITIAL_ROSTER := [
|
|||||||
# 1 玄真(宗主):修士·炼气9层,五行全高,炼丹3级
|
# 1 玄真(宗主):修士·炼气9层,五行全高,炼丹3级
|
||||||
{
|
{
|
||||||
"name": "玄真",
|
"name": "玄真",
|
||||||
|
"id" : 1,
|
||||||
"metal": 45, "wood": 38, "water": 22, "fire": 31, "earth": 19,
|
"metal": 45, "wood": 38, "water": 22, "fire": 31, "earth": 19,
|
||||||
"efficiency": 85,
|
"efficiency": 85,
|
||||||
"realm_level": 1, "sub_realm_level": 9,
|
"realm_level": 1, "sub_realm_level": 9,
|
||||||
@@ -23,6 +22,7 @@ const INITIAL_ROSTER := [
|
|||||||
# 2 凌霄:修士·炼气4层,金火旺
|
# 2 凌霄:修士·炼气4层,金火旺
|
||||||
{
|
{
|
||||||
"name": "凌霄",
|
"name": "凌霄",
|
||||||
|
"id" : 2,
|
||||||
"metal": 62, "wood": 12, "water": 15, "fire": 44, "earth": 20,
|
"metal": 62, "wood": 12, "water": 15, "fire": 44, "earth": 20,
|
||||||
"efficiency": 76,
|
"efficiency": 76,
|
||||||
"realm_level": 1, "sub_realm_level": 4,
|
"realm_level": 1, "sub_realm_level": 4,
|
||||||
@@ -32,6 +32,7 @@ const INITIAL_ROSTER := [
|
|||||||
# 3 青禾:凡人带灵根(木47≥20 可修炼破境),药草天赋
|
# 3 青禾:凡人带灵根(木47≥20 可修炼破境),药草天赋
|
||||||
{
|
{
|
||||||
"name": "青禾",
|
"name": "青禾",
|
||||||
|
"id" : 3,
|
||||||
"metal": 8, "wood": 47, "water": 25, "fire": 12, "earth": 10,
|
"metal": 8, "wood": 47, "water": 25, "fire": 12, "earth": 10,
|
||||||
"efficiency": 68,
|
"efficiency": 68,
|
||||||
"realm_level": 0, "sub_realm_level": 1,
|
"realm_level": 0, "sub_realm_level": 1,
|
||||||
@@ -41,6 +42,7 @@ const INITIAL_ROSTER := [
|
|||||||
# 4 阿福:凡人杂役(无灵根,五行均<20)
|
# 4 阿福:凡人杂役(无灵根,五行均<20)
|
||||||
{
|
{
|
||||||
"name": "阿福",
|
"name": "阿福",
|
||||||
|
"id" : 4,
|
||||||
"metal": 5, "wood": 12, "water": 8, "fire": 9, "earth": 10,
|
"metal": 5, "wood": 12, "water": 8, "fire": 9, "earth": 10,
|
||||||
"efficiency": 41,
|
"efficiency": 41,
|
||||||
"realm_level": 0, "sub_realm_level": 1,
|
"realm_level": 0, "sub_realm_level": 1,
|
||||||
@@ -50,6 +52,7 @@ const INITIAL_ROSTER := [
|
|||||||
# 5 阿禄:凡人杂役(无灵根)
|
# 5 阿禄:凡人杂役(无灵根)
|
||||||
{
|
{
|
||||||
"name": "阿禄",
|
"name": "阿禄",
|
||||||
|
"id" : 5,
|
||||||
"metal": 3, "wood": 6, "water": 5, "fire": 8, "earth": 15,
|
"metal": 3, "wood": 6, "water": 5, "fire": 8, "earth": 15,
|
||||||
"efficiency": 35,
|
"efficiency": 35,
|
||||||
"realm_level": 0, "sub_realm_level": 1,
|
"realm_level": 0, "sub_realm_level": 1,
|
||||||
@@ -61,103 +64,101 @@ const INITIAL_ROSTER := [
|
|||||||
var _disciples: Array[Disciple] = [] # 弟子列表
|
var _disciples: Array[Disciple] = [] # 弟子列表
|
||||||
var _master_id: int = 0 # 管理器的发号计数,id 的唯一来源
|
var _master_id: int = 0 # 管理器的发号计数,id 的唯一来源
|
||||||
|
|
||||||
# ---- 工厂 ----
|
func _enter_tree() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# ---- 工厂 ----
|
||||||
# 初始编队(复用 _create_from_data)
|
# 初始编队(复用 _create_from_data)
|
||||||
func spawn_initial_roster() -> Array[Disciple]:
|
func spawn_initial_roster() -> void:
|
||||||
for data in INITIAL_ROSTER:
|
for data in INITIAL_ROSTER:
|
||||||
var disciple = _create_from_data(data)
|
var disciple = _create_from_data(data)
|
||||||
if disciple != null:
|
if disciple != null:
|
||||||
add_disciple(disciple)
|
add_disciple(disciple)
|
||||||
# _disciples.append(disciple)
|
else:
|
||||||
# emit_signal("disciple_added", disciple)
|
push_error("Failed to spawn disciple from data: %s" % data)
|
||||||
else:
|
pass
|
||||||
push_error("Failed to spawn disciple from data: %s" % data)
|
|
||||||
pass
|
|
||||||
|
|
||||||
# 补 id → Disciple.create()
|
# 补 id → Disciple.create()
|
||||||
# 从数据字典创建 Disciple 实例,若失败返回 null
|
# 从数据字典创建 Disciple 实例,若失败返回 null
|
||||||
func _create_from_data(data: Dictionary) -> Disciple:
|
func _create_from_data(data: Dictionary) -> Disciple:
|
||||||
var disciple := Disciple.create(data)
|
var copy := data.duplicate() # 可写副本(浅拷贝,顶层加键足够)
|
||||||
if disciple == null:
|
copy["id"] = _master_id
|
||||||
push_error("Failed to create disciple from data: %s" % data)
|
_master_id += 1
|
||||||
return null
|
var disciple := Disciple.create(copy)
|
||||||
disciple.id = _master_id
|
if disciple == null:
|
||||||
_master_id += 1
|
push_error("Failed to create disciple from data: %s" % data)
|
||||||
return disciple
|
return null
|
||||||
pass
|
return disciple
|
||||||
|
|
||||||
# ---- 仓储 ----
|
# ---- 仓储 ----
|
||||||
|
|
||||||
# 公开接口:添加弟子
|
# 公开接口:添加弟子
|
||||||
func add_disciple(d : Disciple) -> void:
|
func add_disciple(d : Disciple) -> void:
|
||||||
if d == null:
|
if d == null:
|
||||||
push_error("Cannot add null disciple.")
|
push_error("Cannot add null disciple.")
|
||||||
return
|
return
|
||||||
_disciples.append(d)
|
_disciples.append(d)
|
||||||
emit_signal("disciple_added", d)
|
emit_signal("disciple_added", d)
|
||||||
|
|
||||||
# 移除弟子
|
# 移除弟子
|
||||||
func remove_disciple(d : Disciple) -> bool:
|
func remove_disciple(d : Disciple) -> bool:
|
||||||
if d != null and _disciples.has(d):
|
if d != null and _disciples.has(d):
|
||||||
_disciples.erase(d)
|
_disciples.erase(d)
|
||||||
emit_signal("disciple_removed", d)
|
emit_signal("disciple_removed", d)
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# 公开接口:通过id获取弟子
|
# 公开接口:通过id获取弟子
|
||||||
func get_disciple(id : int) -> Disciple:
|
func get_disciple(id : int) -> Disciple:
|
||||||
for d in _disciples:
|
for d in _disciples:
|
||||||
if d.id == id:
|
if d.id == id:
|
||||||
return d
|
return d
|
||||||
return null
|
return null
|
||||||
|
|
||||||
# 公开接口:获取所有弟子(返回副本,避免外部修改原数组)
|
# 公开接口:获取所有弟子(返回副本,避免外部修改原数组)
|
||||||
func get_all() -> Array[Disciple]:
|
func get_all() -> Array[Disciple]:
|
||||||
return _disciples.duplicate() # 返回副本,避免外部修改原数组
|
return _disciples.duplicate() # 返回副本,避免外部修改原数组
|
||||||
|
|
||||||
# ---- 修改唯一入口 ----
|
# ---- 修改唯一入口 ----
|
||||||
|
|
||||||
# 调 d.set_attr + 发信号(name 特判)
|
# 调 d.set_attr + 发信号(name 特判)
|
||||||
func set_attr(d :Disciple, attr: String, value: Variant) -> bool:
|
func set_attr(d :Disciple, attr: String, value: Variant) -> bool:
|
||||||
if _disciples.has(d):
|
if _disciples.has(d):
|
||||||
var old_value = d.get_attr(attr)
|
var old_value = d.get_attr(attr)
|
||||||
if d.set_attr(attr, value):
|
if d.set_attr(attr, value):
|
||||||
emit_signal("disciple_attr_changed", d, attr, old_value, value)
|
emit_signal("disciple_attr_changed", d, attr, old_value, value)
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# ---- 经验晋级(领域操作)----
|
# ---- 经验晋级(领域操作)----
|
||||||
|
|
||||||
# 跨小境界继承循环;跨大境界清零;满级不涨;无灵根拒绝
|
# 跨小境界继承循环;跨大境界清零;满级不涨;无灵根拒绝
|
||||||
func add_cultivation_exp(d : Disciple, amount : int) -> void:
|
func add_cultivation_exp(d : Disciple, amount : int) -> void:
|
||||||
if _disciples.has(d):
|
if _disciples.has(d):
|
||||||
var old_realm = d.realm_level
|
var old_realm = d.realm_level
|
||||||
var old_sub_realm = d.sub_realm_level
|
var old_sub_realm = d.sub_realm_level
|
||||||
d.add_cultivation_exp(amount)
|
d.add_cultivation_exp(amount)
|
||||||
if d.realm_level != old_realm or d.sub_realm_level != old_sub_realm:
|
if d.realm_level != old_realm or d.sub_realm_level != old_sub_realm:
|
||||||
emit_signal("disciple_attr_changed", d, "realm_level", old_realm, d.realm_level)
|
emit_signal("disciple_attr_changed", d, "realm_level", old_realm, d.realm_level)
|
||||||
emit_signal("disciple_attr_changed", d, "sub_realm_level", old_sub_realm, d.sub_realm_level)
|
emit_signal("disciple_attr_changed", d, "sub_realm_level", old_sub_realm, d.sub_realm_level)
|
||||||
|
|
||||||
# skill∈{farming,herb,alchemy},查 SKILL_EXP_CAPS,溢出继承至满级
|
# skill∈{farming,herb,alchemy},查 SKILL_EXP_CAPS,溢出继承至满级
|
||||||
func add_skill_exp(d : Disciple, skill: String, amount : int) -> void:
|
func add_skill_exp(d : Disciple, skill: String, amount : int) -> void:
|
||||||
if _disciples.has(d):
|
if _disciples.has(d):
|
||||||
var old_level = d.get_skill_level(skill)
|
var old_level = d.get_skill_level(skill)
|
||||||
d.add_skill_exp(skill, amount)
|
d.add_skill_exp(skill, amount)
|
||||||
var new_level = d.get_skill_level(skill)
|
var new_level = d.get_skill_level(skill)
|
||||||
if new_level != old_level:
|
if new_level != old_level:
|
||||||
emit_signal("disciple_attr_changed", d, skill + "_level", old_level, new_level)
|
emit_signal("disciple_attr_changed", d, skill + "_level", old_level, new_level)
|
||||||
|
|
||||||
# ---- 月度结算(预留)----
|
# ---- 月度结算(预留)----
|
||||||
# 月收益 = f(efficiency),依赖经济扣灵石 —— 取决于下列问题
|
# 月收益 = f(efficiency),依赖经济扣灵石 —— 取决于下列问题
|
||||||
func settle_month() -> void:
|
func settle_month() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# ---- 存档 ----
|
# ---- 存档 ----
|
||||||
func to_dict():
|
func to_dict():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func load_from_dict():
|
func load_from_dict():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bstiea1nx61b8
|
||||||
@@ -1,5 +1,17 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
var cnt := 0;
|
||||||
|
func _ready() -> void:
|
||||||
|
%DiscipleManager.spawn_initial_roster()
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if cnt >= 1000:
|
||||||
|
var d : Disciple= %DiscipleManager.get_disciple(2);
|
||||||
|
%DiscipleManager.remove_disciple(d);
|
||||||
|
else:
|
||||||
|
cnt = cnt + 1;
|
||||||
|
pass
|
||||||
|
|
||||||
func _on_top_bar_hud_sign_return_mainmenu() -> void:
|
func _on_top_bar_hud_sign_return_mainmenu() -> void:
|
||||||
if GameState.mode == GameState.GameMode.NEW_GAME:
|
if GameState.mode == GameState.GameMode.NEW_GAME:
|
||||||
@@ -8,3 +20,13 @@ func _on_top_bar_hud_sign_return_mainmenu() -> void:
|
|||||||
SaveSystem.save(GameState.profile_id) # 进游戏立即存首档,防开局就丢
|
SaveSystem.save(GameState.profile_id) # 进游戏立即存首档,防开局就丢
|
||||||
get_tree().change_scene_to_file("res://src/UI/Panels/MainMenu/MainMenu.tscn")
|
get_tree().change_scene_to_file("res://src/UI/Panels/MainMenu/MainMenu.tscn")
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
func _on_disciple_manager_disciple_added(disciple: Disciple) -> void:
|
||||||
|
$PanelContainer/Manager.add_disciple_card(disciple)
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_disciple_manager_disciple_removed(disciple: Disciple) -> void:
|
||||||
|
$PanelContainer/Manager.remove_disciple_card(disciple.id)
|
||||||
|
pass # Replace with function body.
|
||||||
|
|||||||
+16
-2
@@ -1,12 +1,14 @@
|
|||||||
[gd_scene format=3 uid="uid://c1exffg84ojqx"]
|
[gd_scene format=3 uid="uid://c1exffg84ojqx"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cr4by5k8vgkcq" path="res://src/Core/MainGame.gd" id="1_8bu23"]
|
[ext_resource type="Script" uid="uid://cr4by5k8vgkcq" path="res://src/Core/MainGame.gd" id="1_2atgf"]
|
||||||
|
[ext_resource type="Script" uid="uid://bstiea1nx61b8" path="res://src/Character/DiscipleManager.gd" id="1_dl5bp"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d3njijtx7ws1m" path="res://src/UI/HUD/MainSceneHud.tscn" id="2_8bu23"]
|
[ext_resource type="PackedScene" uid="uid://d3njijtx7ws1m" path="res://src/UI/HUD/MainSceneHud.tscn" id="2_8bu23"]
|
||||||
[ext_resource type="StyleBox" uid="uid://e86yw57h4v2s" path="res://resources/manager_style_box_flat.tres" id="3_dl5bp"]
|
[ext_resource type="StyleBox" uid="uid://e86yw57h4v2s" path="res://resources/manager_style_box_flat.tres" id="3_dl5bp"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d1mbwdtarjqof" path="res://src/UI/Panels/Manager/Manager.tscn" id="4_58g0x"]
|
[ext_resource type="PackedScene" uid="uid://d1mbwdtarjqof" path="res://src/UI/Panels/Manager/Manager.tscn" id="4_58g0x"]
|
||||||
|
[ext_resource type="Script" uid="uid://b8f8t2phmhq2e" path="res://src/Core/TimeSystem.gd" id="5_58g0x"]
|
||||||
|
|
||||||
[node name="MainGame" type="Node" unique_id=42551660]
|
[node name="MainGame" type="Node" unique_id=42551660]
|
||||||
script = ExtResource("1_8bu23")
|
script = ExtResource("1_2atgf")
|
||||||
|
|
||||||
[node name="MainHud" parent="." unique_id=836125968 instance=ExtResource("2_8bu23")]
|
[node name="MainHud" parent="." unique_id=836125968 instance=ExtResource("2_8bu23")]
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
@@ -23,4 +25,16 @@ theme_override_styles/panel = ExtResource("3_dl5bp")
|
|||||||
[node name="Manager" parent="PanelContainer" unique_id=360636457 instance=ExtResource("4_58g0x")]
|
[node name="Manager" parent="PanelContainer" unique_id=360636457 instance=ExtResource("4_58g0x")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="DiscipleManager" type="Node" parent="." unique_id=1485476702]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("1_dl5bp")
|
||||||
|
metadata/_custom_type_script = "uid://bstiea1nx61b8"
|
||||||
|
|
||||||
|
[node name="TimeSystem" type="Node" parent="." unique_id=1280036358]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("5_58g0x")
|
||||||
|
metadata/_custom_type_script = "uid://b8f8t2phmhq2e"
|
||||||
|
|
||||||
|
[connection signal="disciple_added" from="DiscipleManager" to="." method="_on_disciple_manager_disciple_added"]
|
||||||
|
[connection signal="disciple_removed" from="DiscipleManager" to="." method="_on_disciple_manager_disciple_removed"]
|
||||||
[connection signal="sign_return_mainmenu" from="MainHud" to="." method="_on_top_bar_hud_sign_return_mainmenu"]
|
[connection signal="sign_return_mainmenu" from="MainHud" to="." method="_on_top_bar_hud_sign_return_mainmenu"]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
## 全局时间系统(Autoload 单例)。
|
## 全局时间系统(Autoload 单例)。
|
||||||
## 负责游戏时间的推进与播报,仅在世界场景中运行。
|
## 负责游戏时间的推进与播报,仅在世界场景中运行。
|
||||||
## 历法:12 月 × 30 日 = 360 日/年。
|
## 历法:12 月 × 30 日 = 360 日/年。
|
||||||
|
class_name TimeSystem
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
const MONTHS_PER_YEAR := 12
|
const MONTHS_PER_YEAR := 12
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ var total_amount: int:
|
|||||||
|
|
||||||
## 构造:按 data 覆盖属性,数值属性经 RANGES 夹取;缺键保留字段默认值。
|
## 构造:按 data 覆盖属性,数值属性经 RANGES 夹取;缺键保留字段默认值。
|
||||||
## @param data: 键名与属性名一致,如 {"id": 1, "name": "玄真", "metal": 60}
|
## @param data: 键名与属性名一致,如 {"id": 1, "name": "玄真", "metal": 60}
|
||||||
func _init(data: Dictionary[String, Variant] = {}) -> void:
|
func _init(data: Dictionary = {}) -> void:
|
||||||
if data.has("id"):
|
if data.has("id"):
|
||||||
id = int(data["id"])
|
id = int(data["id"])
|
||||||
if data.has("name"):
|
if data.has("name"):
|
||||||
@@ -187,12 +187,12 @@ func set_attr(key: String, value: int) -> bool:
|
|||||||
if key == "realm_level":
|
if key == "realm_level":
|
||||||
# 大境界变化后,小境界不得超过新境界的上限(如落入凡人则强制 1)
|
# 大境界变化后,小境界不得超过新境界的上限(如落入凡人则强制 1)
|
||||||
set("realm_level", v)
|
set("realm_level", v)
|
||||||
var max_sub := SUB_MAX_BY_REALM[v]
|
var max_sub : int = SUB_MAX_BY_REALM[v]
|
||||||
if int(get("sub_realm_level")) > max_sub:
|
if int(get("sub_realm_level")) > max_sub:
|
||||||
set("sub_realm_level", max_sub)
|
set("sub_realm_level", max_sub)
|
||||||
elif key == "sub_realm_level":
|
elif key == "sub_realm_level":
|
||||||
# 小境界写入时按当前大境界上限夹取(凡人上限 1 / 练气 13 / 其余 4)
|
# 小境界写入时按当前大境界上限夹取(凡人上限 1 / 练气 13 / 其余 4)
|
||||||
var max_sub := SUB_MAX_BY_REALM[int(get("realm_level"))]
|
var max_sub : int = SUB_MAX_BY_REALM[int(get("realm_level"))]
|
||||||
set("sub_realm_level", clampi(v, 1, max_sub))
|
set("sub_realm_level", clampi(v, 1, max_sub))
|
||||||
else:
|
else:
|
||||||
set(key, v)
|
set(key, v)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ extends Control
|
|||||||
signal sign_return_mainmenu
|
signal sign_return_mainmenu
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
time_label.text = TimeSystem.get_date_text()
|
time_label.text = %TimeSystem.get_date_text()
|
||||||
TimeSystem.month_passed.connect(_on_TimeMonthPassed)
|
%TimeSystem.month_passed.connect(_on_TimeMonthPassed)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _on_ButtonEsc_ButtonUp() -> void:
|
func _on_ButtonEsc_ButtonUp() -> void:
|
||||||
@@ -20,5 +20,5 @@ func _on_TimeMonthPassed(_year: int, _month: int) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_button_continue_button_up() -> void:
|
func _on_button_continue_button_up() -> void:
|
||||||
TimeSystem.advance_month()
|
%TimeSystem.advance_month()
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
var disciple_id: int;
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
custom_maximum_size = Vector2(180, 320);
|
custom_maximum_size = Vector2(180, 320);
|
||||||
custom_minimum_size = Vector2(180, 240);
|
custom_minimum_size = Vector2(180, 240);
|
||||||
pass;
|
pass;
|
||||||
|
|
||||||
func set_info(info: Dictionary):
|
func set_info(info: Dictionary):
|
||||||
|
disciple_id = info['id'];
|
||||||
$VBoxContainer/HBoxContainer/Name.text = info['name'];
|
$VBoxContainer/HBoxContainer/Name.text = info['name'];
|
||||||
$VBoxContainer/HBoxContainer2/Level.text = info['level']
|
$VBoxContainer/HBoxContainer2/Level.text = info['level']
|
||||||
$VBoxContainer/HBoxContainer3/GridContainer/MetalVal.text = str(info['metal'])
|
$VBoxContainer/HBoxContainer3/GridContainer/MetalVal.text = str(info['metal'])
|
||||||
@@ -13,4 +16,6 @@ func set_info(info: Dictionary):
|
|||||||
$VBoxContainer/HBoxContainer3/GridContainer/WaterVal.text = str(info['water'])
|
$VBoxContainer/HBoxContainer3/GridContainer/WaterVal.text = str(info['water'])
|
||||||
$VBoxContainer/HBoxContainer3/GridContainer/FireVal.text = str(info['fire'])
|
$VBoxContainer/HBoxContainer3/GridContainer/FireVal.text = str(info['fire'])
|
||||||
$VBoxContainer/HBoxContainer3/GridContainer/EarthVal.text = str(info['earth'])
|
$VBoxContainer/HBoxContainer3/GridContainer/EarthVal.text = str(info['earth'])
|
||||||
|
|
||||||
|
#print(info)
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ grow_vertical = 2
|
|||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
theme_override_styles/panel = ExtResource("1_po3i5")
|
theme_override_styles/panel = ExtResource("1_po3i5")
|
||||||
script = ExtResource("2_6fig8")
|
script = ExtResource("2_6fig8")
|
||||||
|
metadata/discipleId = 0
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1066350214]
|
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1066350214]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
var test_disciple_table : Array[Dictionary] = [] # 弟子
|
|
||||||
var test_field_table : Array[Dictionary] = [] # 建筑
|
var test_field_table : Array[Dictionary] = [] # 建筑
|
||||||
var test_order_table : Array[Dictionary] = [] # 订单
|
var test_order_table : Array[Dictionary] = [] # 订单
|
||||||
var test_alchemy_table : Array[Dictionary] = [] # 炼丹配方
|
var test_alchemy_table : Array[Dictionary] = [] # 炼丹配方
|
||||||
@@ -22,7 +21,6 @@ func _ready() -> void:
|
|||||||
var manager_panel_scene := load("res://src/UI/Panels/Manager/ManagerPanel.tscn") as PackedScene
|
var manager_panel_scene := load("res://src/UI/Panels/Manager/ManagerPanel.tscn") as PackedScene
|
||||||
var inventory_panel_scene := load("res://src/UI/Panels/Manager/InventoryPanel/InventoryPanel.tscn") as PackedScene
|
var inventory_panel_scene := load("res://src/UI/Panels/Manager/InventoryPanel/InventoryPanel.tscn") as PackedScene
|
||||||
|
|
||||||
|
|
||||||
sect_resources["弟子"] = manager_panel_scene.instantiate();
|
sect_resources["弟子"] = manager_panel_scene.instantiate();
|
||||||
sect_resources["弟子"].name = "弟子";
|
sect_resources["弟子"].name = "弟子";
|
||||||
$TabContainer.add_child(sect_resources["弟子"]);
|
$TabContainer.add_child(sect_resources["弟子"]);
|
||||||
@@ -42,12 +40,6 @@ func _ready() -> void:
|
|||||||
sect_resources["库房"] = inventory_panel_scene.instantiate();
|
sect_resources["库房"] = inventory_panel_scene.instantiate();
|
||||||
sect_resources["库房"].name = "库房";
|
sect_resources["库房"].name = "库房";
|
||||||
$TabContainer.add_child(sect_resources["库房"]);
|
$TabContainer.add_child(sect_resources["库房"]);
|
||||||
|
|
||||||
for e in test_disciple_table:
|
|
||||||
var d := disciple_info_scene.instantiate()
|
|
||||||
d.set_info(e)
|
|
||||||
sect_resources["弟子"].add_info_card(d)
|
|
||||||
pass
|
|
||||||
|
|
||||||
for e in test_field_table:
|
for e in test_field_table:
|
||||||
var d := field_info_scene.instantiate()
|
var d := field_info_scene.instantiate()
|
||||||
@@ -66,25 +58,12 @@ func _ready() -> void:
|
|||||||
d.set_alchemy_info(e)
|
d.set_alchemy_info(e)
|
||||||
sect_resources['炼丹'].add_info_card(d)
|
sect_resources['炼丹'].add_info_card(d)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func init_test_data() -> void:
|
func init_test_data() -> void:
|
||||||
|
|
||||||
test_disciple_table.append_array([
|
|
||||||
{"name": "赵一", "gender": "男", "level": "练气一层", "metal": 0.5, "wood": 0.9, "water": 0.1, "fire": 0.2, "earth": 0.15},
|
|
||||||
{"name": "钱二", "gender": "男", "level": "练气一层", "metal": 0.5, "wood": 0.9, "water": 0.1, "fire": 0.2, "earth": 0.15},
|
|
||||||
{"name": "孙三", "gender": "男", "level": "练气一层", "metal": 0.5, "wood": 0.9, "water": 0.1, "fire": 0.2, "earth": 0.15},
|
|
||||||
{"name": "李四", "gender": "男", "level": "练气一层", "metal": 0.5, "wood": 0.9, "water": 0.1, "fire": 0.2, "earth": 0.15},
|
|
||||||
{"name": "周五", "gender": "男", "level": "练气一层", "metal": 0.5, "wood": 0.9, "water": 0.1, "fire": 0.2, "earth": 0.15},
|
|
||||||
{"name": "吴六", "gender": "男", "level": "练气一层", "metal": 0.5, "wood": 0.9, "water": 0.1, "fire": 0.2, "earth": 0.15},
|
|
||||||
{"name": "郑七", "gender": "男", "level": "练气一层", "metal": 0.5, "wood": 0.9, "water": 0.1, "fire": 0.2, "earth": 0.15}
|
|
||||||
])
|
|
||||||
|
|
||||||
test_field_table.append_array([
|
test_field_table.append_array([
|
||||||
{"name": "灵田", "弟子": 0},
|
{"name": "灵田", "弟子": 0},
|
||||||
{"name": "灵田", "弟子": 1},
|
{"name": "灵田", "弟子": 1},
|
||||||
@@ -129,3 +108,30 @@ func init_test_data() -> void:
|
|||||||
|
|
||||||
test_inventory.append_array([{"草药": test_sub_inventory1}, {"粮食": test_sub_inventory2}, {"丹药": test_sub_inventory3}]);
|
test_inventory.append_array([{"草药": test_sub_inventory1}, {"粮食": test_sub_inventory2}, {"丹药": test_sub_inventory3}]);
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func add_disciple_card(d : Disciple) -> void:
|
||||||
|
var ds := disciple_info_scene.instantiate()
|
||||||
|
var info := {
|
||||||
|
"id": d.id,
|
||||||
|
"name": d.name,
|
||||||
|
"gender" : "x",
|
||||||
|
"level" : d.realm_name(),
|
||||||
|
"metal" : int(d.get_attr("metal")),
|
||||||
|
"wood" : int(d.get_attr("wood")),
|
||||||
|
"water" : int(d.get_attr("water")),
|
||||||
|
"fire" : int(d.get_attr("fire")),
|
||||||
|
"earth" : int(d.get_attr("earth"))
|
||||||
|
}
|
||||||
|
ds.set_info(info)
|
||||||
|
sect_resources["弟子"].add_info_card(ds)
|
||||||
|
pass
|
||||||
|
|
||||||
|
func remove_disciple_card(id: int) -> void:
|
||||||
|
var panel: Control = sect_resources["弟子"] # ManagerPanel 页
|
||||||
|
var flow: Node = panel.get_node("ScrollContainer/HFlowContainer")
|
||||||
|
|
||||||
|
for child in flow.get_children():
|
||||||
|
if child.disciple_id == id: # 指定项匹配
|
||||||
|
flow.remove_child(child) # 1. 先从树摘除
|
||||||
|
child.queue_free() # 2. 再排队销毁
|
||||||
|
return # 匹配唯一,删完即走
|
||||||
|
|||||||
Reference in New Issue
Block a user