diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs
index 088413b..a9910a7 100644
--- a/scripts/character/CharacterTemplate.cs
+++ b/scripts/character/CharacterTemplate.cs
@@ -130,7 +130,7 @@ public partial class CharacterTemplate : CharacterBody2D
///Sets the amount of Hp a character has after resurrection
///设置角色复活后拥有的Hp
///
- public void Revive(int newHp)
+ public virtual void Revive(int newHp)
{
//If the new Hp is less than or equal to 0, there is no need to resurrect
//如果新的Hp小于等于0,那么不需要复活
diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs
index 2c754d9..a6c57fd 100644
--- a/scripts/character/Player.cs
+++ b/scripts/character/Player.cs
@@ -378,6 +378,18 @@ public partial class Player : CharacterTemplate
}
}
+ public override void Revive(int newHp)
+ {
+ base.Revive(newHp);
+ var healthBarUi = GameSceneNodeHolder.HealthBarUi;
+ if (healthBarUi!=null)
+ {
+ //The purpose of setting Hp to the current Hp is to cause the life bar to refresh.
+ //将Hp设置为当前Hp的目的是,使生命条刷新。
+ healthBarUi.CurrentHp = CurrentHp;
+ }
+ }
+
protected override async Task OnDie(DamageTemplate damageTemplate)
{
Visible = false;
diff --git a/scripts/loader/sceneLoader/GameSceneLoader.cs b/scripts/loader/sceneLoader/GameSceneLoader.cs
index 0a7f7d6..eb550eb 100644
--- a/scripts/loader/sceneLoader/GameSceneLoader.cs
+++ b/scripts/loader/sceneLoader/GameSceneLoader.cs
@@ -9,6 +9,10 @@ using Godot;
namespace ColdMint.scripts.loader.sceneLoader;
+///
+/// Game scene loader
+/// 游戏场景加载器
+///
public partial class GameSceneLoader : SceneLoaderTemplate
{
private Label? _seedLabel;
@@ -55,7 +59,7 @@ public partial class GameSceneLoader : SceneLoaderTemplate
_seedLabel = GetNodeOrNull("CanvasLayer/Control/SeedLabel");
if (_seedLabel != null)
{
- _seedLabel.Visible = Config.IsDebug();
+ _seedLabel.Visible = debugMode;
}
MapGenerator.MapRoot = GetNode("MapRoot");
@@ -77,16 +81,8 @@ public partial class GameSceneLoader : SceneLoaderTemplate
//If you have a seedLabel, then set the seed to it.
//如果有seedLabel,那么将种子设置上去。
var seedInfo = TranslationServerUtils.TranslateWithFormat("seed_info", MapGenerator.Seed);
- if (seedInfo == null)
- {
- _seedLabel.Text = $"Seed: {MapGenerator.Seed}";
- }
- else
- {
- _seedLabel.Text = seedInfo;
- }
+ _seedLabel.Text = seedInfo ?? $"Seed: {MapGenerator.Seed}";
}
-
await MapGenerator.GenerateMap();
}
}
\ No newline at end of file
diff --git a/scripts/map/LayoutParsingStrategy/SequenceLayoutParsingStrategy.cs b/scripts/map/LayoutParsingStrategy/SequenceLayoutParsingStrategy.cs
index 2c51fe3..4e67f35 100644
--- a/scripts/map/LayoutParsingStrategy/SequenceLayoutParsingStrategy.cs
+++ b/scripts/map/LayoutParsingStrategy/SequenceLayoutParsingStrategy.cs
@@ -19,30 +19,37 @@ namespace ColdMint.scripts.map.LayoutParsingStrategy;
public class SequenceLayoutParsingStrategy : ILayoutParsingStrategy
{
private LevelGraphEditorSaveData? _levelGraphEditorSaveData;
-
- //Check whether data Settings are valid
- //设置数据时,是否检查合法了
+
+ ///
+ /// Check whether data Settings are valid
+ /// 设置数据时,是否检查合法了
+ ///
private bool _checkLegality;
- //The connection index of the query
- //查询的连接索引
+ ///
+ /// The connection index of the query
+ /// 查询的连接索引
+ ///
private int _index;
private int _maxIndex;
- private Dictionary _roomNodeDataDictionary = new Dictionary();
+ ///
+ /// Room ID Indicates the dictionary of room node data
+ /// 房间ID对应房间节点数据的字典
+ ///
+ private readonly Dictionary _roomNodeDataDictionary = new();
public void SetLevelGraph(LevelGraphEditorSaveData levelGraphEditorSaveData)
{
- _checkLegality = false;
- _index = -1;
- _levelGraphEditorSaveData = levelGraphEditorSaveData;
- if (_levelGraphEditorSaveData.RoomNodeDataList == null || _levelGraphEditorSaveData.RoomNodeDataList.Count == 0)
+ if (levelGraphEditorSaveData.RoomNodeDataList == null || levelGraphEditorSaveData.RoomNodeDataList.Count == 0)
{
//No room data, unable to parse.
//没有房间数据,无法解析。
return;
}
-
+ _checkLegality = false;
+ _index = -1;
+ _levelGraphEditorSaveData = levelGraphEditorSaveData;
if (_levelGraphEditorSaveData.ConnectionDataList == null ||
_levelGraphEditorSaveData.ConnectionDataList.Count == 0)
{
diff --git a/scripts/map/interfaces/IRoomHolder.cs b/scripts/map/interfaces/IRoomHolder.cs
deleted file mode 100644
index d0e86a1..0000000
--- a/scripts/map/interfaces/IRoomHolder.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using ColdMint.scripts.map.room;
-
-namespace ColdMint.scripts.map.interfaces;
-
-///
-/// Room holder
-/// 房间持有者
-///
-///
-///This class holds all generated and placed rooms.
-///该类保存所有已生成且已放置的房间。
-///
-public interface IRoomHolder
-{
- bool AddRoom(Room room);
-
- ///
- /// LastRoom
- /// 最后添加的房间
- ///
- Room? LastRoom { get; }
-
- ///
- /// Number of rooms that have been placed
- /// 已放置的房间数量
- ///
- int PlacedRoomNumber { get; }
-}
\ No newline at end of file
diff --git a/scripts/map/interfaces/IRoomTemplate.cs b/scripts/map/interfaces/IRoomTemplate.cs
deleted file mode 100644
index c823b91..0000000
--- a/scripts/map/interfaces/IRoomTemplate.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-namespace ColdMint.scripts.map.interfaces;
-
-public interface IRoomTemplate
-{
- ///
- /// The asset path of the room must be available
- /// 必须可获得房间的资产路径
- ///
- string RoomResPath { get; }
-
- ///
- /// Whether this room template can still be used
- /// 这个房间模板是否还能使用
- ///
- bool CanUse { get; }
-
- ///
- /// The maximum number of times a room template is used
- /// 房间模板的最大使用次数
- ///
- int MaxNumber { get; set; }
-
-
- ///
- /// AddUsedNumber
- /// 添加使用次数
- ///
- void AddUsedNumber();
-
- ///
- /// Times used
- /// 已使用次数
- ///
- int UsedNumber { get; }
-}
\ No newline at end of file
diff --git a/scripts/map/layoutStrategy/TestLayoutStrategy.cs b/scripts/map/layoutStrategy/TestLayoutStrategy.cs
index dad919e..8326104 100644
--- a/scripts/map/layoutStrategy/TestLayoutStrategy.cs
+++ b/scripts/map/layoutStrategy/TestLayoutStrategy.cs
@@ -11,17 +11,17 @@ namespace ColdMint.scripts.map.layoutStrategy;
///
public class TestLayoutStrategy : ILayoutStrategy
{
- private string _path = "res://data/levelGraphs/test.json";
+ private const string Path = "res://data/levelGraphs/test.json";
public Task GetLayout()
{
- var exists = FileAccess.FileExists(_path);
+ var exists = FileAccess.FileExists(Path);
if (!exists)
{
return Task.FromResult(null);
}
- var json = FileAccess.GetFileAsString(_path);
+ var json = FileAccess.GetFileAsString(Path);
if (json == null)
{
return Task.FromResult(null);
diff --git a/scripts/map/room/RoomTemplate.cs b/scripts/map/room/RoomTemplate.cs
deleted file mode 100644
index 4b1647d..0000000
--- a/scripts/map/room/RoomTemplate.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using ColdMint.scripts.map.interfaces;
-
-namespace ColdMint.scripts.map.room;
-
-public class RoomTemplate : IRoomTemplate
-{
- ///
- /// Unlimited use
- /// 无限次使用
- ///
- public const int Infinite = -1;
-
- private int _usedNumber;
-
- public RoomTemplate(string roomResPath)
- {
- RoomResPath = roomResPath;
- MaxNumber = Infinite;
- _usedNumber = 0;
- }
-
- public string RoomResPath { get; }
-
- public bool CanUse
- {
- get
- {
- if (MaxNumber == Infinite)
- {
- return true;
- }
-
- return _usedNumber < MaxNumber;
- }
- }
-
- public int MaxNumber { get; set; }
-
-
- public void AddUsedNumber()
- {
- _usedNumber++;
- }
-
- public int UsedNumber => _usedNumber;
-}
\ No newline at end of file
diff --git a/scripts/map/roomHolder/RoomHolder.cs b/scripts/map/roomHolder/RoomHolder.cs
deleted file mode 100644
index aba133e..0000000
--- a/scripts/map/roomHolder/RoomHolder.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Collections.Generic;
-using ColdMint.scripts.map.interfaces;
-using ColdMint.scripts.map.room;
-
-namespace ColdMint.scripts.map.roomHolder;
-
-public class RoomHolder : IRoomHolder
-{
- private readonly List _rooms = new List();
-
- public bool AddRoom(Room room)
- {
- _rooms.Add(room);
- return true;
- }
-
- public Room? LastRoom
- {
- get
- {
- if (_rooms.Count > 0)
- {
- return _rooms[_rooms.Count - 1];
- }
-
- return null;
- }
- }
-
- public int PlacedRoomNumber => _rooms.Count;
-}
\ No newline at end of file
diff --git a/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs b/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs
index d1c41e3..d6e138c 100644
--- a/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs
+++ b/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs
@@ -263,6 +263,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
{
if (mainRoomSlot == null || mainRoomSlot.Matched)
{
+ //If it's already a match, it's no longer a match
//如果已经匹配过了,就不再匹配
continue;
}
@@ -276,6 +277,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
if (newRoomSlot.Matched)
{
+ //If it's already a match, it's no longer a match
//如果已经匹配过了,就不再匹配
continue;
}