开始干活

master
lightyears 2 years ago
parent c975e0e886
commit a4575ede6f
Signed by: lightyears
GPG Key ID: 98D80DDF26D4F2F9

@ -0,0 +1,3 @@
public partial class BattleCharacter : Sprite2D
{
}

@ -0,0 +1,21 @@
[gd_scene load_steps=3 format=3 uid="uid://be4dnt701hcsv"]
[ext_resource type="Texture2D" uid="uid://dgl6fv3okxuoc" path="res://Assets/Characters/1.png" id="1_wpp45"]
[ext_resource type="Script" path="res://Components/BattleCharacter.cs" id="2_upe33"]
[node name="BattleCharacter" type="Sprite2D"]
texture = ExtResource("1_wpp45")
script = ExtResource("2_upe33")
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
[node name="LabelName" type="Label" parent="."]
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = -128.0
offset_top = -165.5
offset_right = -81.0
offset_bottom = -139.5
grow_vertical = 2
text = "Name"

@ -0,0 +1,15 @@
public partial class PauseMenu : Control
{
private GameSettings _settings;
public override void _Ready()
{
_settings = GetNode<GameSettings>("/root/GameSettings");
GetNode<CheckBox>("%CheckBoxPauseBattleWhenCharacterIsSelected").ToggleMode = _settings.PauseBattleWhenCharacterIsSelected;
}
public void On_CheckBoxPauseBattleWhenCharacterIsSelected_Toggled()
{
_settings.PauseBattleWhenCharacterIsSelected = false;
}
}

@ -0,0 +1,37 @@
[gd_scene load_steps=2 format=3 uid="uid://c1c87rr8eubhg"]
[ext_resource type="Script" path="res://Components/PauseMenu.cs" id="1_p1e8d"]
[node name="PauseMenu" 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_p1e8d")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="CheckBoxPauseBattleWhenCharacterIsSelected" type="CheckBox" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "选中角色时暂停战斗"
[node name="ButtonExit" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "退出"
[connection signal="toggled" from="VBoxContainer/CheckBoxPauseBattleWhenCharacterIsSelected" to="." method="_On_CheckBoxPauseBattleWhenCharacterIsSelected_Toggled"]

@ -0,0 +1,35 @@
[gd_scene format=3 uid="uid://blobono0y4pqs"]
[node name="PrebattleMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="ButtonPrepare" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "战前准备"
[node name="ButtonStart" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "开始战斗"
[node name="ButtonEscape" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "逃跑"

@ -0,0 +1,40 @@
public partial class Battle : Control
{
private Label _labelBattleTime;
public double Time;
public bool IsPause = false;
public override void _Ready()
{
_labelBattleTime = GetNode<Label>("%LabelBattleTime");
}
public override void _Process(double delta)
{
if (!IsPause)
{
Time += delta;
}
UpdateUI();
}
public override void _Input(InputEvent input)
{
if (Input.IsActionPressed("battle_pause"))
{
IsPause = !IsPause;
}
}
public void UpdateUI()
{
_labelBattleTime.Text = TimeHelper.FormatTime(Time);
}
public static void On_ButtonBattlePause_Pressed()
{
Input.ParseInputEvent(new InputEventAction { Action = "battle_pause" });
}
}

@ -0,0 +1,51 @@
[gd_scene load_steps=2 format=3 uid="uid://cx6yq8awwkqv3"]
[ext_resource type="Script" path="res://Scenes/Battle.cs" id="1_n6bn7"]
[node name="Battle" 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_n6bn7")
[node name="Camera2D" type="Camera2D" parent="."]
[node name="Characters" type="Node2D" parent="."]
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="HUD" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="LabelBattleTime" type="Label" parent="CanvasLayer/HUD"]
unique_name_in_owner = true
layout_mode = 1
offset_right = 41.0
offset_bottom = 26.0
text = "00:00"
[node name="ButtonBattlePause" type="Button" parent="CanvasLayer/HUD"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -20.0
offset_top = -23.0
offset_right = 20.0
grow_horizontal = 2
grow_vertical = 0
text = "按下 Space 暂停时间"
[connection signal="pressed" from="CanvasLayer/HUD/ButtonBattlePause" to="." method="_On_ButtonBattlePause_Pressed"]

@ -1,16 +1,3 @@
using Godot;
using System;
public partial class Main : Control
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
GD.Print("Hello, world!");
}
}

@ -1,16 +1,43 @@
[gd_scene load_steps=2 format=3 uid="uid://bphcmx4a7omp4"]
[gd_scene load_steps=2 format=3 uid="uid://dxnmltew81ny0"]
[ext_resource type="Script" path="res://scenes/Main.cs" id="1_slm00"]
[ext_resource type="Script" path="res://Scenes/Main.cs" id="1_kso8c"]
[node name="Main" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource("1_slm00")
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_kso8c")
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
text = "The Country of Moutains and Seas"
text = "The Country of Mountains and Seas"
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -52.5
offset_top = -20.0
offset_right = 52.5
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
[node name="ButtonBattleDemo" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "战斗场景 Demo"
[node name="ButtonExit" type="Button" parent="VBoxContainer"]
layout_mode = 2
text = "退出"
[connection signal="pressed" from="VBoxContainer/ButtonBattleDemo" to="." method="_On_button_battle_demo_pressed"]
[connection signal="button_up" from="VBoxContainer/ButtonExit" to="." method="_on_button_exit_button_up"]

@ -0,0 +1,18 @@
public partial class Character : Node
{
private int _hp;
public int Hp
{
get => _hp;
set => _hp = value;
}
public override void _Ready()
{
}
public override void _Process(double delta)
{
}
}

@ -0,0 +1,4 @@
public partial class GameSettings : Node
{
public bool PauseBattleWhenCharacterIsSelected = true;
}

@ -0,0 +1,6 @@
static class TimeHelper {
public static string FormatTime(double time)
{
return TimeSpan.FromSeconds(time).ToString("c");
}
}

@ -11,10 +11,28 @@ config_version=5
[application]
config/name="The Country of Mountains and Seas"
run/main_scene="res://scenes/Main.tscn"
run/main_scene="res://Scenes/Main.tscn"
config/features=PackedStringArray("4.0", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
Settings="*res://Scripts/Settings.cs"
[dotnet]
project/assembly_name="CMSGame"
[editor]
naming/default_signal_callback_name="On_{NodeName}_{SignalName}"
naming/default_signal_callback_to_self_name="On_{SignalName}"
naming/scene_name_casing=1
[input]
battle_pause={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
, null]
}

Loading…
Cancel
Save