master
lightyears 2 years ago
parent c3ae100197
commit b9c1dbb5b0
Signed by: lightyears
GPG Key ID: 98D80DDF26D4F2F9

@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace CMSGame
{
public class GameSave
{
public List<Character> Characters;
}
}

@ -2,6 +2,13 @@ namespace CMSGame
{
static class TimeHelper
{
/// <summary>获取自引擎启动后经过的时间。</summary>
public static double GetTicks()
{
return Time.GetTicksMsec() / 1000.0;
}
/// <summary>将时间(单位为秒)格式化为字符串“时:分:秒.毫秒”。</summary>
public static string FormatTime(double time)
{
return TimeSpan.FromSeconds(time).ToString("c");

@ -0,0 +1,34 @@
using System.Collections.Generic;
namespace CMSGame
{
public static class BattleGoals
{
public static readonly BattleGoal Escape = new()
{
Name = "保命要紧",
BasePriority = -50
};
public static readonly BattleGoal SelfRegulatory = new()
{
Name = "自律行动",
BasePriority = 0
};
public static readonly BattleGoal FollowOrder = new()
{
Name = "服从指令",
BasePriority = 50
};
public static List<BattleGoal> AllGoals()
{
return new() {
Escape,
SelfRegulatory,
FollowOrder
};
}
}
}

@ -1,6 +1,6 @@
namespace CMSGame
{
public class Characters
public static class Characters
{
}

@ -0,0 +1,26 @@
using System.Collections.Generic;
namespace CMSGame
{
public abstract class Action
{
public string Name;
public ActionTargetTypes TargetType;
public List<IActionTarget> Targets;
public IActionTarget Target => Targets.Count > 0 ? Targets[0] : null;
}
public enum ActionTargetTypes
{
None,
Single,
Multiple
}
public interface IActionTarget
{
}
}

@ -0,0 +1,24 @@
using System.Collections.Generic;
namespace CMSGame
{
public class Battle
{
public List<BattleParty> Parties;
public BattleParty Attacker;
public BattleParty Defender;
public BattleParty PlayerParty;
public Battle()
{
// load characters of the attacker and defender;
}
public void Begin()
{
}
}
}

@ -1,58 +1,22 @@
using System.Collections.Generic;
namespace CMSGame
{
public partial class BattleCharacter : CharacterBody3D
public class BattleCharacter
{
[Signal]
public delegate void MousePressedEventHandler(Vector3 position);
[Export]
public Texture SpriteTexture;
public BattleFieldPosition BattleFieldPosition;
public List<BattleGoal> Goals;
public Character Character;
public Sprite3D Sprite3D;
public Label3D StatusLabel;
public int ActionPoint;
public double ActionPointGathering;
public override void _Ready()
{
this.GetUniqueNode(ref Sprite3D, nameof(Sprite3D));
this.GetUniqueNode(ref StatusLabel, nameof(StatusLabel));
}
public override void _Process(double delta)
{
UpdateStatus(delta);
UpdateUI();
}
public void UpdateStatus(double delta)
{
ActionPointGathering += delta;
ActionPoint += (int)ActionPointGathering / 10;
ActionPointGathering %= 10;
}
public void UpdateUI()
public BattleCharacter(Character character)
{
StatusLabel.Text = $"HP {120}\nAP {ActionPoint}";
Character = character;
EstablishGoals();
}
public override void _InputEvent(Camera3D camera, InputEvent @event, Vector3 position, Vector3 normal, int shapeIdx)
private void EstablishGoals()
{
if (@event is InputEventMouseButton mouseButtonEvent)
{
if (mouseButtonEvent.Pressed)
{
EmitSignal(SignalName.MousePressed, position);
}
}
Goals = BattleGoals.AllGoals();
}
}
}

@ -0,0 +1,15 @@
using System.Collections.Generic;
namespace CMSGame
{
public class BattleParty
{
public bool IsAttacker;
public bool IsDefender;
public bool IsPlayerParty;
public List<BattleCharacter> Characters;
}
}

@ -1,15 +1,15 @@
namespace CMSGame
{
public partial class Character : Node
public class Character
{
public int HealthPoint;
public string FamilyName;
public string GivenName;
public override void _Ready()
{
}
public string Name => FamilyName + GivenName;
public int HealthPoint;
public override void _Process(double delta)
{
}
public int MaxHealthPoint;
}
}

@ -0,0 +1,11 @@
namespace CMSGame
{
public abstract class Effect
{
public string Name;
public string Description;
public abstract void Perform(Character character);
}
}

@ -0,0 +1,20 @@
namespace CMSGame
{
public class Goal
{
public string Name;
public bool IsValid;
public int BasePriority;
}
public class BattleGoal : Goal
{
}
public class GoalModifier
{
}
}

@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace CMSGame
{
public abstract class Skill
{
public string Name;
public List<Effect> Effects;
}
}

@ -0,0 +1,58 @@
namespace CMSGame
{
public partial class BattleCharacterNode : CharacterBody3D
{
[Signal]
public delegate void MousePressedEventHandler(Vector3 position);
[Export]
public Texture SpriteTexture;
public BattleFieldPosition BattleFieldPosition;
public Character Character;
public Sprite3D Sprite3D;
public Label3D StatusLabel;
public int ActionPoint;
public double ActionPointGathering;
public override void _Ready()
{
this.GetUniqueNode(ref Sprite3D, nameof(Sprite3D));
this.GetUniqueNode(ref StatusLabel, nameof(StatusLabel));
}
public override void _Process(double delta)
{
UpdateStatus(delta);
UpdateUI();
}
public void UpdateStatus(double delta)
{
ActionPointGathering += delta;
ActionPoint += (int)ActionPointGathering / 10;
ActionPointGathering %= 10;
}
public void UpdateUI()
{
StatusLabel.Text = $"HP {120}\nAP {ActionPoint}";
}
public override void _InputEvent(Camera3D camera, InputEvent @event, Vector3 position, Vector3 normal, int shapeIdx)
{
if (@event is InputEventMouseButton mouseButtonEvent)
{
if (mouseButtonEvent.Pressed)
{
EmitSignal(SignalName.MousePressed, position);
}
}
}
}
}

@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://igk5375j1keq"]
[gd_scene load_steps=4 format=3 uid="uid://dje5jk73mjb6a"]
[ext_resource type="Texture2D" uid="uid://cnilysgmgw8n4" path="res://Temp/Characters/1_19.png" id="1_o3tjt"]
[ext_resource type="Script" path="res://Models/BattleCharacter.cs" id="2_vbdi8"]
[ext_resource type="Script" path="res://Nodes/BattleCharacterNode.cs" id="2_vbdi8"]
[sub_resource type="BoxShape3D" id="BoxShape3D_r28jb"]
size = Vector3(0.84, 1.46, 0.17)

@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://c3ovsoq6o7y3t"]
[ext_resource type="Script" path="res://Scenes/MainScene.cs" id="1_kso8c"]
[ext_resource type="PackedScene" uid="uid://cslqihnfw0me2" path="res://Components/SettingsMenuPopup.tscn" id="2_d0nn6"]
[ext_resource type="PackedScene" path="res://Components/SettingsMenuPopup.tscn" id="2_d0nn6"]
[node name="MainScene" type="Control"]
layout_mode = 3

@ -1,8 +1,8 @@
[gd_scene load_steps=10 format=3 uid="uid://6phl40durwor"]
[gd_scene load_steps=10 format=3 uid="uid://dgi0d8jybvlk0"]
[ext_resource type="PackedScene" uid="uid://cp6aa655vykt1" path="res://Scenes/BattleScene.tscn" id="1_fdqdi"]
[ext_resource type="Script" path="res://Tests/BattleSceneTest.cs" id="1_tuul4"]
[ext_resource type="PackedScene" uid="uid://igk5375j1keq" path="res://Models/BattleCharacter.tscn" id="3_nau0d"]
[ext_resource type="PackedScene" uid="uid://igk5375j1keq" path="res://Nodes/BattleCharacterNode.tscn" id="3_nau0d"]
[ext_resource type="Texture2D" uid="uid://w6qckexp2he1" path="res://Temp/Characters/2_73.png" id="4_jnah0"]
[ext_resource type="Texture2D" uid="uid://du6o3upum6lkr" path="res://Temp/Characters/3_0.png" id="5_4vahd"]
[ext_resource type="Texture2D" uid="uid://cl11bl8lcnwha" path="res://Temp/Characters/4_2.png" id="6_6563q"]
@ -54,8 +54,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.44713, 0.524168, -12.3572)
[node name="Sprite3D" parent="BattleScene/Characters/BattleCharacter7" index="2"]
texture = ExtResource("9_wor4w")
[connection signal="MousePressed" from="BattleScene/Characters/BattleCharacter" to="." method="On_BattleCharacter_MousePressed"]
[editable path="BattleScene"]
[editable path="BattleScene/Characters/BattleCharacter2"]
[editable path="BattleScene/Characters/BattleCharacter3"]

@ -0,0 +1,16 @@
namespace CMSGame
{
public static class GameSaves
{
public static readonly GameSave Demo1 = new()
{
Characters = new() {
new Character {
FamilyName = "腾",
GivenName = "牧心",
HealthPoint = 80
}
}
};
};
}
Loading…
Cancel
Save