Make a level map editor.
制作关卡图编辑器。
This commit is contained in:
parent
92659d23b0
commit
2a28702fc6
|
@ -11,4 +11,10 @@ use_item,使用,Use,しよう
|
|||
jump_down,跳下平台,Jump off platform,踊り場から飛び降ります
|
||||
de,的,'s,の
|
||||
default_player_name,白纸,blankPaper,しらかみ
|
||||
item_prompt_debug,ID:{0}\n名称:{1}\n数量:{2}\n最大叠加数量:{3}\n数据类型:{4}\n描述:{5},ID: {0}\nName: {1}\nQuantity: {2}\nMaximum stacking quantity: {3}\nData type: {4}\nDescription:{5},id:{0}\n名称:{1}\nの数は最大{2}\nシナジー数:{3}\nデータタイプ:{4}\n述べ表わす:{5}
|
||||
item_prompt_debug,ID:{0}\n名称:{1}\n数量:{2}\n最大叠加数量:{3}\n数据类型:{4}\n描述:{5},ID: {0}\nName: {1}\nQuantity: {2}\nMaximum stacking quantity: {3}\nData type: {4}\nDescription:{5},id:{0}\n名称:{1}\nの数は最大{2}\nシナジー数:{3}\nデータタイプ:{4}\n述べ表わす:{5}
|
||||
level_graph_editor,关卡图编辑器,Level graph editor,ステージマップエディター
|
||||
create_room,创建房间,Create room,部屋を作ります
|
||||
close,关闭,Close,閉じます
|
||||
name,名称,Name,めいしょう
|
||||
describe,描述,Describe,ないよう
|
||||
creation,创建,Creation,創建
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://dslr5tdbp4noq"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dslr5tdbp4noq"]
|
||||
|
||||
[ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_rn2om"]
|
||||
|
||||
|
@ -11,6 +11,9 @@ size = Vector2(20, 48)
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_x4kt2"]
|
||||
size = Vector2(46, 20)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_131jn"]
|
||||
size = Vector2(20, 54)
|
||||
|
||||
[node name="InitialRoom" type="Node2D"]
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="."]
|
||||
|
@ -44,3 +47,10 @@ shape = SubResource("RectangleShape2D_o85u0")
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D3"]
|
||||
position = Vector2(224, 178)
|
||||
shape = SubResource("RectangleShape2D_x4kt2")
|
||||
|
||||
[node name="Area2D2" type="Area2D" parent="RoomSlotList"]
|
||||
position = Vector2(498, 109)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D2"]
|
||||
position = Vector2(0, 17)
|
||||
shape = SubResource("RectangleShape2D_131jn")
|
||||
|
|
|
@ -19,7 +19,7 @@ layer_0/tile_data = PackedInt32Array(393230, 393217, 5, 393229, 393217, 5, 39322
|
|||
layer_1/name = "BackgroundDecoration"
|
||||
layer_1/tile_data = PackedInt32Array(393218, 458753, 5, 65550, 458753, 4)
|
||||
layer_2/name = "Ground"
|
||||
layer_2/tile_data = PackedInt32Array(0, 1, 3, 65536, 131073, 1, 131072, 131073, 1, 196608, 131073, 1, 262144, 131073, 1, 458752, 1, 5, 1, 65537, 2, 458753, 65537, 0, 2, 65537, 2, 458754, 65537, 0, 3, 65537, 2, 458755, 65537, 0, 4, 65537, 2, 458756, 65537, 0, 5, 65537, 2, 458757, 65537, 0, 6, 65537, 2, 458758, 65537, 0, 7, 65537, 2, 458759, 65537, 0, 8, 65537, 2, 9, 65537, 2, 458761, 65537, 0, 10, 65537, 2, 458762, 65537, 0, 11, 65537, 2, 458763, 65537, 0, 12, 65537, 2, 458764, 65537, 0, 13, 65537, 2, 458765, 65537, 0, 14, 65537, 3, 458766, 65537, 0, 15, 131073, 3, 65551, 131073, 4, 131087, 131073, 4, 196623, 131073, 4, 262159, 131073, 4, 458767, 131073, 5, 458760, 65537, 0, 327680, 131073, 1, 393216, 131073, 1)
|
||||
layer_2/tile_data = PackedInt32Array(0, 1, 3, 65536, 131073, 1, 131072, 131073, 1, 196608, 131073, 1, 262144, 131073, 1, 458752, 1, 5, 15, 131073, 3, 65551, 131073, 4, 131087, 131073, 4, 196623, 131073, 4, 262159, 131073, 4, 458767, 131073, 5, 327680, 131073, 1, 393216, 131073, 1, 1, 65537, 2, 2, 65537, 2, 3, 65537, 2, 4, 65537, 2, 5, 65537, 2, 6, 65537, 2, 7, 65537, 2, 8, 65537, 2, 9, 65537, 2, 10, 65537, 2, 11, 65537, 2, 12, 65537, 2, 13, 65537, 2, 14, 65537, 3, 458753, 65537, 0, 458754, 65537, 0, 458755, 65537, 0, 458756, 65537, 0, 458757, 65537, 0, 458758, 65537, 0, 458759, 65537, 0, 458760, 65537, 0, 458761, 65537, 0, 458762, 65537, 0, 458763, 65537, 0, 458764, 65537, 0, 458765, 65537, 0, 458766, 65537, 0)
|
||||
|
||||
[node name="RoomArea" type="Area2D" parent="."]
|
||||
|
||||
|
|
8
prefab/ui/RoomNode.tscn
Normal file
8
prefab/ui/RoomNode.tscn
Normal file
|
@ -0,0 +1,8 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://y6rg5jc4viwn"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/levelGraphEditor/RoomNode.cs" id="1_jiu7r"]
|
||||
|
||||
[node name="RoomNode" type="GraphNode"]
|
||||
offset_right = 571.0
|
||||
offset_bottom = 253.0
|
||||
script = ExtResource("1_jiu7r")
|
111
scenes/LevelGraphEditor.tscn
Normal file
111
scenes/LevelGraphEditor.tscn
Normal file
|
@ -0,0 +1,111 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ckl23uwxrjat4"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/loader/uiLoader/LevelGraphEditorLoader.cs" id="1_7nyq6"]
|
||||
|
||||
[node name="LevelGraphEditor" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_7nyq6")
|
||||
|
||||
[node name="GraphEdit" type="GraphEdit" parent="."]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = 39.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
show_grid = false
|
||||
minimap_enabled = false
|
||||
show_minimap_button = false
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 11.0
|
||||
offset_top = 7.0
|
||||
offset_right = 143.0
|
||||
offset_bottom = 32.0
|
||||
text = "level_graph_editor"
|
||||
|
||||
[node name="CreateOrEditorPanel" type="Panel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 45.0
|
||||
offset_top = 42.0
|
||||
offset_right = -39.0
|
||||
offset_bottom = -45.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Label" type="Label" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 15.0
|
||||
offset_top = 11.0
|
||||
offset_right = 102.0
|
||||
offset_bottom = 36.0
|
||||
text = "create_room"
|
||||
|
||||
[node name="Label3" type="Label" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 7.0
|
||||
offset_top = 109.0
|
||||
offset_right = 94.0
|
||||
offset_bottom = 134.0
|
||||
text = "describe"
|
||||
|
||||
[node name="RoomNameLineEdit" type="LineEdit" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 75.0
|
||||
offset_top = 54.0
|
||||
offset_right = 1053.0
|
||||
offset_bottom = 87.0
|
||||
|
||||
[node name="RoomDescriptionLineEdit" type="LineEdit" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 82.0
|
||||
offset_top = 108.0
|
||||
offset_right = 1060.0
|
||||
offset_bottom = 141.0
|
||||
|
||||
[node name="HideCreateRoomPanelButton" type="Button" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -46.0
|
||||
offset_bottom = 33.0
|
||||
grow_horizontal = 0
|
||||
text = "close"
|
||||
|
||||
[node name="Label2" type="Label" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 22.0
|
||||
offset_top = 56.0
|
||||
offset_right = 62.0
|
||||
offset_bottom = 81.0
|
||||
text = "name"
|
||||
|
||||
[node name="CreateRoomButton" type="Button" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 972.0
|
||||
offset_top = 507.0
|
||||
offset_right = 1039.0
|
||||
offset_bottom = 540.0
|
||||
text = "creation"
|
||||
|
||||
[node name="ShowCreateRoomPanelButton" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -95.0
|
||||
offset_bottom = 33.0
|
||||
grow_horizontal = 0
|
||||
text = "create_room"
|
|
@ -37,6 +37,18 @@ offset_bottom = 248.0
|
|||
grow_horizontal = 2
|
||||
text = "settings"
|
||||
|
||||
[node name="levelGraphEditorButton" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -44.5
|
||||
offset_top = 269.0
|
||||
offset_right = 50.5
|
||||
offset_bottom = 302.0
|
||||
grow_horizontal = 2
|
||||
text = "level_graph_editor"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
|
|
16
scripts/levelGraphEditor/IRoomNodeData.cs
Normal file
16
scripts/levelGraphEditor/IRoomNodeData.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
namespace ColdMint.scripts.levelGraphEditor;
|
||||
|
||||
public interface IRoomNodeData
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Title</para>
|
||||
/// <para>标题</para>
|
||||
/// </summary>
|
||||
string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>描述</para>
|
||||
/// <para>Description</para>
|
||||
/// </summary>
|
||||
string Description { get; set; }
|
||||
}
|
8
scripts/levelGraphEditor/RoomNode.cs
Normal file
8
scripts/levelGraphEditor/RoomNode.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.levelGraphEditor;
|
||||
|
||||
public partial class RoomNode : GraphNode
|
||||
{
|
||||
|
||||
}
|
7
scripts/levelGraphEditor/RoomNodeData.cs
Normal file
7
scripts/levelGraphEditor/RoomNodeData.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace ColdMint.scripts.levelGraphEditor;
|
||||
|
||||
public class RoomNodeData : IRoomNodeData
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
146
scripts/loader/uiLoader/LevelGraphEditorLoader.cs
Normal file
146
scripts/loader/uiLoader/LevelGraphEditorLoader.cs
Normal file
|
@ -0,0 +1,146 @@
|
|||
using ColdMint.scripts.levelGraphEditor;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.loader.uiLoader;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Level graph editor</para>
|
||||
/// <para>关卡图编辑器</para>
|
||||
/// </summary>
|
||||
public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
||||
{
|
||||
private GraphEdit? _graphEdit;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Button to display the room creation panel.</para>
|
||||
/// <para>用于展示房间创建面板的按钮。</para>
|
||||
/// </summary>
|
||||
private Button? _showCreateRoomPanelButton;
|
||||
|
||||
private PackedScene? _roomNodeScene;
|
||||
private Panel? _createOrEditorPanel;
|
||||
private Button? _hideCreateRoomPanelButton;
|
||||
private LineEdit? _roomNameLineEdit;
|
||||
private LineEdit? _roomDescriptionLineEdit;
|
||||
private Button? _createRoomButton;
|
||||
|
||||
public override void InitializeData()
|
||||
{
|
||||
base.InitializeData();
|
||||
_roomNodeScene = (PackedScene)GD.Load("res://prefab/ui/RoomNode.tscn");
|
||||
}
|
||||
|
||||
|
||||
public override void InitializeUi()
|
||||
{
|
||||
base.InitializeUi();
|
||||
_graphEdit = GetNode<GraphEdit>("GraphEdit");
|
||||
_showCreateRoomPanelButton = GetNode<Button>("ShowCreateRoomPanelButton");
|
||||
_createOrEditorPanel = GetNode<Panel>("CreateOrEditorPanel");
|
||||
_hideCreateRoomPanelButton = GetNode<Button>("CreateOrEditorPanel/HideCreateRoomPanelButton");
|
||||
_roomNameLineEdit = GetNode<LineEdit>("CreateOrEditorPanel/RoomNameLineEdit");
|
||||
_roomDescriptionLineEdit = GetNode<LineEdit>("CreateOrEditorPanel/RoomDescriptionLineEdit");
|
||||
_createRoomButton = GetNode<Button>("CreateOrEditorPanel/CreateRoomButton");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Creating room node</para>
|
||||
/// <para>创建房间节点</para>
|
||||
/// </summary>
|
||||
/// <param name="roomNodeData"></param>
|
||||
/// <returns></returns>
|
||||
private bool CreateRoomNode(IRoomNodeData roomNodeData)
|
||||
{
|
||||
if (_roomNodeScene == null || _graphEdit == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var node = _roomNodeScene.Instantiate();
|
||||
if (node == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_graphEdit?.AddChild(node);
|
||||
if (node is not RoomNode roomNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
roomNode.Title = roomNodeData.Title;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void LoadUiActions()
|
||||
{
|
||||
base.LoadUiActions();
|
||||
if (_showCreateRoomPanelButton != null)
|
||||
{
|
||||
_showCreateRoomPanelButton.Pressed += () =>
|
||||
{
|
||||
if (_graphEdit != null)
|
||||
{
|
||||
_graphEdit.Visible = false;
|
||||
}
|
||||
|
||||
if (_createOrEditorPanel != null)
|
||||
{
|
||||
_createOrEditorPanel.Visible = true;
|
||||
}
|
||||
|
||||
_showCreateRoomPanelButton.Visible = false;
|
||||
};
|
||||
}
|
||||
|
||||
if (_hideCreateRoomPanelButton != null)
|
||||
{
|
||||
_hideCreateRoomPanelButton.Pressed += HideCreateRoomPanel;
|
||||
}
|
||||
|
||||
if (_createRoomButton != null)
|
||||
{
|
||||
_createRoomButton.Pressed += () =>
|
||||
{
|
||||
if (_roomNameLineEdit == null || _roomDescriptionLineEdit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var roomNodeData = new RoomNodeData
|
||||
{
|
||||
Title = _roomNameLineEdit.Text,
|
||||
Description = _roomDescriptionLineEdit.Text
|
||||
};
|
||||
var result = CreateRoomNode(roomNodeData);
|
||||
if (result)
|
||||
{
|
||||
HideCreateRoomPanel();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>Hide the Create Room panel</para>
|
||||
/// <para>隐藏创建房间面板</para>
|
||||
/// </summary>
|
||||
private void HideCreateRoomPanel()
|
||||
{
|
||||
if (_graphEdit != null)
|
||||
{
|
||||
_graphEdit.Visible = true;
|
||||
}
|
||||
|
||||
if (_createOrEditorPanel != null)
|
||||
{
|
||||
_createOrEditorPanel.Visible = false;
|
||||
}
|
||||
|
||||
if (_showCreateRoomPanelButton != null)
|
||||
{
|
||||
_showCreateRoomPanelButton.Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
private PackedScene? _gameScene;
|
||||
private Label? _sloganLabel;
|
||||
private Label? _versionLabel;
|
||||
private Button? _levelGraphEditorButton;
|
||||
|
||||
public override void InitializeData()
|
||||
{
|
||||
|
@ -55,6 +56,10 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
public override void InitializeUi()
|
||||
{
|
||||
_startGameButton = GetNode<Button>("StartGameButton");
|
||||
_levelGraphEditorButton = GetNode<Button>("levelGraphEditorButton");
|
||||
//The level map editor is only available in debug mode.
|
||||
//关卡图编辑器仅在调试模式可用。
|
||||
_levelGraphEditorButton.Visible = Config.IsDebug();
|
||||
_startGameButton.GrabFocus();
|
||||
_versionLabel = GetNode<Label>("VBoxContainer2/VersionLabel");
|
||||
//Generative copyright
|
||||
|
@ -89,5 +94,14 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
GetTree().ChangeSceneToPacked(_gameScene);
|
||||
};
|
||||
}
|
||||
|
||||
if (_levelGraphEditorButton!=null)
|
||||
{
|
||||
_levelGraphEditorButton.Pressed += () =>
|
||||
{
|
||||
LogCat.Log("level_graph_editor");
|
||||
GetTree().ChangeSceneToPacked((PackedScene)GD.Load("res://scenes/LevelGraphEditor.tscn"));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user