diff --git a/DungeonShooting_Godot/editor/ide_cn_font_6.tres b/DungeonShooting_Godot/editor/ide_cn_font_6.tres new file mode 100644 index 0000000..88e27db --- /dev/null +++ b/DungeonShooting_Godot/editor/ide_cn_font_6.tres @@ -0,0 +1,11 @@ +[gd_resource type="DynamicFont" load_steps=2 format=2] + +[ext_resource path="res://SourceHanSerifCN-SemiBold.otf" type="DynamicFontData" id=1] + +[resource] +size = 15 +use_mipmaps = true +use_filter = true +extra_spacing_char = 1 +extra_spacing_space = 2 +font_data = ExtResource( 1 ) diff --git a/DungeonShooting_Godot/editor/prefabs/IdePanel.tscn b/DungeonShooting_Godot/editor/prefabs/IdePanel.tscn new file mode 100644 index 0000000..b2150bd --- /dev/null +++ b/DungeonShooting_Godot/editor/prefabs/IdePanel.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://editor/src/IdeTextEditor.cs" type="Script" id=1] +[ext_resource path="res://editor/ide_cn_font_6.tres" type="DynamicFont" id=2] +[ext_resource path="res://editor/src/IdePanel.cs" type="Script" id=3] + +[node name="IdePanel" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 3 ) + +[node name="ScalePanel" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_right = 720.0 +margin_bottom = 405.0 +rect_scale = Vector2( 0.4, 0.4 ) + +[node name="TextEdit" type="TextEdit" parent="ScalePanel"] +anchor_right = 1.0 +anchor_bottom = 1.0 +custom_colors/member_variable_color = Color( 0.862745, 0.862745, 0.862745, 1 ) +custom_colors/function_color = Color( 0.862745, 0.862745, 0.666667, 1 ) +custom_colors/background_color = Color( 0.117647, 0.117647, 0.117647, 1 ) +custom_colors/number_color = Color( 0.709804, 0.807843, 0.658824, 1 ) +custom_colors/current_line_color = Color( 0.0588235, 0.0588235, 0.0588235, 1 ) +custom_constants/line_spacing = 0 +custom_fonts/font = ExtResource( 2 ) +highlight_current_line = true +syntax_highlighting = true +show_line_numbers = true +bookmark_gutter = true +fold_gutter = true +wrap_enabled = true +minimap_draw = true +caret_blink = true +caret_blink_speed = 0.4 +script = ExtResource( 1 ) + +[connection signal="resized" from="ScalePanel" to="." method="_on_ScalePanel_resized"] diff --git a/DungeonShooting_Godot/editor/src/IdePanel.cs b/DungeonShooting_Godot/editor/src/IdePanel.cs new file mode 100644 index 0000000..7b686c2 --- /dev/null +++ b/DungeonShooting_Godot/editor/src/IdePanel.cs @@ -0,0 +1,24 @@ +using Godot; + +namespace Editor +{ + public class IdePanel : Control + { + private Vector2 StartScale; + private Control ScalePanel; + + public override void _Ready() + { + ScalePanel = GetNode("ScalePanel"); + StartScale = ScalePanel.RectScale; + } + + private void _on_ScalePanel_resized() + { + if (ScalePanel != null) + { + ScalePanel.SetSize(RectSize / StartScale); + } + } + } +} diff --git a/DungeonShooting_Godot/editor/src/IdeTextEditor.cs b/DungeonShooting_Godot/editor/src/IdeTextEditor.cs new file mode 100644 index 0000000..16ad0f1 --- /dev/null +++ b/DungeonShooting_Godot/editor/src/IdeTextEditor.cs @@ -0,0 +1,80 @@ +using Godot; + +namespace Editor +{ + public class IdeTextEditor : TextEdit + { + private readonly Color KeyCodeColor = new Color(86 / 255f,156 / 255f,214 / 255f); + private readonly Color AnnotationColor = new Color(77 / 255f,144 / 255f,52 / 255f); + private readonly Color StringColor = new Color(214 / 255f,157 / 255f,133 / 255f); + private readonly string[] KeyCodes = { + "var", + "namespace", + "this", + "class", + "extends", + "func", + "get", + "set", + "import", + "static", + "new", + "return", + "for", + "switch", + "case", + "break", + "default", + "while", + "do", + "is", + "repeat", + "null", + "true", + "false", + "readonly", + "enum", + "private", + "super", + "if", + "else", + "continue", + "typeof" + }; + + public override void _Ready() + { + //添加关键字 + for (int i = 0; i < KeyCodes.Length; i++) + { + AddKeywordColor(KeyCodes[i], KeyCodeColor); + } + AddColorRegion("//", "", AnnotationColor, true); + AddColorRegion("/*", "*/", AnnotationColor); + AddColorRegion("\"", "\"", StringColor); + Text = @" +//导入命名空间 +import system; +//声明一个类, 继承Object +class MyClass extends Object; + +//声明变量 +var text = ""hello \""world\""""; + +func say(message) { + print(message); +} + +static test() { + var arr = [1, 2, 3]; + if (arr.length > 0) { + for (var i = 0; i < arr.length; i++) { + print(arr[i]); + } + } +} + +"; + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot index 9182f6f..aae89d2 100644 --- a/DungeonShooting_Godot/project.godot +++ b/DungeonShooting_Godot/project.godot @@ -11,7 +11,7 @@ [application] config/name="DungeonShooting" -run/main_scene="res://scene/Room.tscn" +run/main_scene="res://scene/Main.tscn" config/icon="res://icon.png" [autoload] diff --git a/DungeonShooting_Godot/scene/Main.tscn b/DungeonShooting_Godot/scene/Main.tscn new file mode 100644 index 0000000..8aa305d --- /dev/null +++ b/DungeonShooting_Godot/scene/Main.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://editor/prefabs/IdePanel.tscn" type="PackedScene" id=1] + +[node name="Main" type="Node2D"] + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="IdePanel" parent="CanvasLayer" instance=ExtResource( 1 )] diff --git a/DungeonShooting_Godot/src/game/manager/InputManager.cs b/DungeonShooting_Godot/src/game/manager/InputManager.cs new file mode 100644 index 0000000..e176a71 --- /dev/null +++ b/DungeonShooting_Godot/src/game/manager/InputManager.cs @@ -0,0 +1,13 @@ + +using Godot; + +public static class InputManager +{ + // public static Vector2 MousePosition => GameManager.Instance.GetGlobalMousePosition() / 4; + // + // public static Vector2 GetLocalMousePosition(Node2D target) + // { + // return target.GetLocalMousePosition() / 4; + // } + +} \ No newline at end of file