Prepare to add forks to the map.
准备为地图添加分叉。
This commit is contained in:
parent
5c4dc37181
commit
92659d23b0
|
@ -7,4 +7,7 @@
|
|||
<RootNamespace>ColdMint</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="scripts\map\branch\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -34,6 +34,7 @@ shape = SubResource("CapsuleShape2D_bb8wt")
|
|||
debug_color = Color(0.886275, 0, 0.803922, 0.419608)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
position_smoothing_enabled = true
|
||||
|
||||
[node name="Area2DPickingArea" type="Area2D" parent="."]
|
||||
collision_layer = 0
|
||||
|
|
|
@ -32,7 +32,7 @@ collision_layer = 64
|
|||
collision_mask = 38
|
||||
script = ExtResource("1_ubaid")
|
||||
metadata/CampId = "Mazoku"
|
||||
metadata/MaxHp = 99999
|
||||
metadata/MaxHp = 50
|
||||
metadata/Name = "死灵法师"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dslr5tdbp4noq"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dslr5tdbp4noq"]
|
||||
|
||||
[ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_rn2om"]
|
||||
|
||||
|
@ -8,9 +8,6 @@ size = Vector2(508.75, 191)
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o85u0"]
|
||||
size = Vector2(20, 48)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_30r3c"]
|
||||
size = Vector2(20, 46)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_x4kt2"]
|
||||
size = Vector2(46, 20)
|
||||
|
||||
|
@ -42,12 +39,6 @@ shape = SubResource("RectangleShape2D_kiih8")
|
|||
position = Vector2(17, 129)
|
||||
shape = SubResource("RectangleShape2D_o85u0")
|
||||
|
||||
[node name="Area2D2" type="Area2D" parent="RoomSlotList"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D2"]
|
||||
position = Vector2(498, 128)
|
||||
shape = SubResource("RectangleShape2D_30r3c")
|
||||
|
||||
[node name="Area2D3" type="Area2D" parent="RoomSlotList"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D3"]
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bnftvkj2cido7"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bnftvkj2cido7"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/loader/sceneLoader/GameSceneLoader.cs" id="1_mqdgt"]
|
||||
[ext_resource type="Texture2D" uid="uid://cs6e0af876ss5" path="res://sprites/ui/HeartEmpty.png" id="2_n1yht"]
|
||||
[ext_resource type="Script" path="res://scripts/inventory/HotBar.cs" id="2_owrhq"]
|
||||
[ext_resource type="Script" path="res://scripts/HealthBarUi.cs" id="2_xrm3v"]
|
||||
[ext_resource type="Script" path="res://scripts/FpsLabel.cs" id="5_dis4v"]
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
script = ExtResource("1_mqdgt")
|
||||
|
@ -55,6 +56,17 @@ bbcode_enabled = true
|
|||
text = "OperationTip"
|
||||
fit_content = true
|
||||
|
||||
[node name="FPSLabel" type="Label" parent="CanvasLayer/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -40.0
|
||||
offset_bottom = 25.0
|
||||
grow_horizontal = 0
|
||||
horizontal_alignment = 2
|
||||
script = ExtResource("5_dis4v")
|
||||
|
||||
[node name="ProjectileContainer" type="Node2D" parent="."]
|
||||
|
||||
[node name="DamageNumberContainer" type="Node2D" parent="."]
|
||||
|
|
56
scripts/FpsLabel.cs
Normal file
56
scripts/FpsLabel.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts;
|
||||
|
||||
/// <summary>
|
||||
/// <para>FPSLabel</para>
|
||||
/// <para>FPS标签</para>
|
||||
/// </summary>
|
||||
public partial class FpsLabel : Label
|
||||
{
|
||||
bool _enable;
|
||||
private LabelSettings? _labelSettings;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Text = null;
|
||||
if (Config.IsDebug())
|
||||
{
|
||||
_labelSettings = new LabelSettings();
|
||||
LabelSettings = _labelSettings;
|
||||
_enable = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (!_enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var fps = Engine.GetFramesPerSecond();
|
||||
Text = "FPS:" + fps;
|
||||
if (_labelSettings != null)
|
||||
{
|
||||
//Green above 54 frames (smooth)
|
||||
//在54帧以上为绿色(流畅)
|
||||
if (fps > 54)
|
||||
{
|
||||
_labelSettings.FontColor = Colors.Green;
|
||||
}
|
||||
else if (fps > 48)
|
||||
{
|
||||
//Yellow between 48 and 54 frames (Karting)
|
||||
//在48到54帧之间为黄色(卡顿)
|
||||
_labelSettings.FontColor = Colors.Yellow;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Red below 48 frames (lag)
|
||||
//在48帧以下为红色(卡)
|
||||
_labelSettings.FontColor = Colors.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,8 +58,15 @@ public static class LogCat
|
|||
GD.Print(string.Format(HandleMessage(message).ToString(), args));
|
||||
}
|
||||
|
||||
public static void LogError(Exception e)
|
||||
/// <summary>
|
||||
/// <para>This method is called when an exception is caught</para>
|
||||
/// <para>当捕获异常后调用此方法</para>
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public static void WhenCaughtException(Exception e)
|
||||
{
|
||||
//Log an exception here or send it to the server.
|
||||
//请在这里记录异常或将异常发送至服务器。
|
||||
GD.PrintErr(HandleMessage(e.Message).Append('\n').Append(e.StackTrace));
|
||||
}
|
||||
}
|
|
@ -46,8 +46,8 @@ public partial class GameSceneLoader : SceneLoaderTemplate
|
|||
new RoomTemplate("res://prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn");
|
||||
var horizontalCorridor = new RoomTemplate("res://prefab/roomTemplates/dungeon/horizontalCorridor.tscn");
|
||||
roomProvider.AddRoom(initialRoom);
|
||||
roomProvider.AddRoom(horizontalCorridor);
|
||||
roomProvider.AddRoom(horizontalCorridorWithSewer);
|
||||
roomProvider.AddRoom(horizontalCorridor);
|
||||
roomProvider.AddRoom(utilityRoom);
|
||||
_mapGenerator.RoomProvider = roomProvider;
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ public class MapGenerator : IMapGenerator
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogCat.LogError(e);
|
||||
throw;
|
||||
LogCat.WhenCaughtException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ColdMint.scripts.map.interfaces;
|
||||
using ColdMint.scripts.debug;
|
||||
using ColdMint.scripts.map.interfaces;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.map;
|
||||
|
@ -9,15 +10,21 @@ public class MapGeneratorConfig : IMapGeneratorConfig
|
|||
/// <para>At least how many rooms are generated</para>
|
||||
/// <para>至少生成多少个房间</para>
|
||||
/// </summary>
|
||||
public const int MinCount = 15;
|
||||
public const int MinRoomCount = 15;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Maximum number of rooms generated</para>
|
||||
/// <para>最多生成多少个房间</para>
|
||||
/// </summary>
|
||||
public const int MaxCount = 30;
|
||||
public const int MaxRoomCount = 30;
|
||||
|
||||
|
||||
public const int MinBranchCount = 3;
|
||||
|
||||
public const int MaxBranchCount = 5;
|
||||
|
||||
private int _roomCount;
|
||||
private int _branchCount;
|
||||
|
||||
public MapGeneratorConfig(Node2D mapRoot, ulong seed)
|
||||
{
|
||||
|
@ -25,11 +32,14 @@ public class MapGeneratorConfig : IMapGeneratorConfig
|
|||
Seed = seed;
|
||||
RandomNumberGenerator = new RandomNumberGenerator();
|
||||
RandomNumberGenerator.Seed = seed;
|
||||
_roomCount = RandomNumberGenerator.RandiRange(MinCount, MaxCount);
|
||||
_roomCount = RandomNumberGenerator.RandiRange(MinRoomCount, MaxRoomCount);
|
||||
_branchCount = RandomNumberGenerator.RandiRange(MinBranchCount, MaxBranchCount);
|
||||
LogCat.Log("Seed:" + seed + " RoomCount:" + _roomCount);
|
||||
}
|
||||
|
||||
public Node2D MapRoot { get; }
|
||||
public int RoomCount => _roomCount;
|
||||
public int BranchCount => _branchCount;
|
||||
|
||||
public ulong Seed { get; }
|
||||
public RandomNumberGenerator RandomNumberGenerator { get; }
|
||||
|
|
18
scripts/map/interfaces/IBranch.cs
Normal file
18
scripts/map/interfaces/IBranch.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace ColdMint.scripts.map.interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Represents a branch on the map.</para>
|
||||
/// <para>表示地图上的一个分支。</para>
|
||||
/// </summary>
|
||||
public interface IBranch
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Master branch or not</para>
|
||||
/// <para>是否为主分支</para>
|
||||
/// </summary>
|
||||
bool IsMasterBranch
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,12 @@ public interface IMapGeneratorConfig
|
|||
/// </summary>
|
||||
int RoomCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>The number of forks in this map</para>
|
||||
/// <para>这个地图的分叉数量</para>
|
||||
/// </summary>
|
||||
int BranchCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>seed</para>
|
||||
/// <para>种子</para>
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
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(IRoom room);
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
namespace ColdMint.scripts.map.interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Room provider</para>
|
||||
/// <para>房间提供者</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>Responsible for providing room templates for map generator.</para>
|
||||
///<para>负责为地图生成器提供房间模板。</para>
|
||||
/// </remarks>
|
||||
public interface IRoomProvider
|
||||
{
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user