Remove unused source files. Fixed an issue where the health tank was empty after resurrection.

移除未使用的源文件。修复复活后生命槽为空的问题。
This commit is contained in:
Cold-Mint 2024-06-05 22:15:23 +08:00
parent 39ca716e3d
commit 4c61f3b50e
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
10 changed files with 42 additions and 165 deletions

View File

@ -130,7 +130,7 @@ public partial class CharacterTemplate : CharacterBody2D
///<para>Sets the amount of Hp a character has after resurrection</para>
///<para>设置角色复活后拥有的Hp</para>
/// </remarks>
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那么不需要复活

View File

@ -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;

View File

@ -9,6 +9,10 @@ using Godot;
namespace ColdMint.scripts.loader.sceneLoader;
/// <summary>
/// <para>Game scene loader</para>
/// <para>游戏场景加载器</para>
/// </summary>
public partial class GameSceneLoader : SceneLoaderTemplate
{
private Label? _seedLabel;
@ -55,7 +59,7 @@ public partial class GameSceneLoader : SceneLoaderTemplate
_seedLabel = GetNodeOrNull<Label>("CanvasLayer/Control/SeedLabel");
if (_seedLabel != null)
{
_seedLabel.Visible = Config.IsDebug();
_seedLabel.Visible = debugMode;
}
MapGenerator.MapRoot = GetNode<Node>("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}";
_seedLabel.Text = seedInfo ?? $"Seed: {MapGenerator.Seed}";
}
else
{
_seedLabel.Text = seedInfo;
}
}
await MapGenerator.GenerateMap();
}
}

View File

@ -20,29 +20,36 @@ public class SequenceLayoutParsingStrategy : ILayoutParsingStrategy
{
private LevelGraphEditorSaveData? _levelGraphEditorSaveData;
//Check whether data Settings are valid
//设置数据时,是否检查合法了
/// <summary>
/// <para>Check whether data Settings are valid</para>
/// <para>设置数据时,是否检查合法了</para>
/// </summary>
private bool _checkLegality;
//The connection index of the query
//查询的连接索引
/// <summary>
/// <para>The connection index of the query</para>
/// <para>查询的连接索引</para>
/// </summary>
private int _index;
private int _maxIndex;
private Dictionary<string, RoomNodeData> _roomNodeDataDictionary = new Dictionary<string, RoomNodeData>();
/// <summary>
/// <para>Room ID Indicates the dictionary of room node data</para>
/// <para>房间ID对应房间节点数据的字典</para>
/// </summary>
private readonly Dictionary<string, RoomNodeData> _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)
{

View File

@ -1,28 +0,0 @@
using ColdMint.scripts.map.room;
namespace ColdMint.scripts.map.interfaces;
/// <summary>
/// <para>Room holder</para>
/// <para>房间持有者</para>
/// </summary>
/// <remarks>
///<para>This class holds all generated and placed rooms.</para>
///<para>该类保存所有已生成且已放置的房间。</para>
/// </remarks>
public interface IRoomHolder
{
bool AddRoom(Room room);
/// <summary>
/// <para>LastRoom</para>
/// <para>最后添加的房间</para>
/// </summary>
Room? LastRoom { get; }
/// <summary>
/// <para>Number of rooms that have been placed</para>
/// <para>已放置的房间数量</para>
/// </summary>
int PlacedRoomNumber { get; }
}

View File

@ -1,35 +0,0 @@
namespace ColdMint.scripts.map.interfaces;
public interface IRoomTemplate
{
/// <summary>
/// <para>The asset path of the room must be available</para>
/// <para>必须可获得房间的资产路径</para>
/// </summary>
string RoomResPath { get; }
/// <summary>
/// <para>Whether this room template can still be used</para>
/// <para>这个房间模板是否还能使用</para>
/// </summary>
bool CanUse { get; }
/// <summary>
/// <para>The maximum number of times a room template is used</para>
/// <para>房间模板的最大使用次数</para>
/// </summary>
int MaxNumber { get; set; }
/// <summary>
/// <para>AddUsedNumber</para>
/// <para>添加使用次数</para>
/// </summary>
void AddUsedNumber();
/// <summary>
/// <para>Times used</para>
/// <para>已使用次数</para>
/// </summary>
int UsedNumber { get; }
}

View File

@ -11,17 +11,17 @@ namespace ColdMint.scripts.map.layoutStrategy;
/// </summary>
public class TestLayoutStrategy : ILayoutStrategy
{
private string _path = "res://data/levelGraphs/test.json";
private const string Path = "res://data/levelGraphs/test.json";
public Task<LevelGraphEditorSaveData?> GetLayout()
{
var exists = FileAccess.FileExists(_path);
var exists = FileAccess.FileExists(Path);
if (!exists)
{
return Task.FromResult<LevelGraphEditorSaveData?>(null);
}
var json = FileAccess.GetFileAsString(_path);
var json = FileAccess.GetFileAsString(Path);
if (json == null)
{
return Task.FromResult<LevelGraphEditorSaveData?>(null);

View File

@ -1,46 +0,0 @@
using ColdMint.scripts.map.interfaces;
namespace ColdMint.scripts.map.room;
public class RoomTemplate : IRoomTemplate
{
/// <summary>
/// <para>Unlimited use</para>
/// <para>无限次使用</para>
/// </summary>
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;
}

View File

@ -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<Room> _rooms = new List<Room>();
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;
}

View File

@ -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;
}