diff --git a/prefab/entitys/Character.tscn b/prefab/entitys/Character.tscn index d015d78..60c295b 100644 --- a/prefab/entitys/Character.tscn +++ b/prefab/entitys/Character.tscn @@ -26,8 +26,8 @@ animations = [{ collision_layer = 4 collision_mask = 34 script = ExtResource("1_1dlls") -metadata/CampId = "Default" -metadata/MaxHp = 32 +MaxHp = 32 +CampId = "Default" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CapsuleShape2D_bb8wt") diff --git a/prefab/entitys/DelivererOfDarkMagic.tscn b/prefab/entitys/DelivererOfDarkMagic.tscn index 1362234..4c90b56 100644 --- a/prefab/entitys/DelivererOfDarkMagic.tscn +++ b/prefab/entitys/DelivererOfDarkMagic.tscn @@ -34,11 +34,10 @@ radius = 172.29 collision_layer = 64 collision_mask = 38 script = ExtResource("1_ubaid") -InitWeaponRes = null +CharacterName = "死灵法师" +MaxHp = 50 +CampId = "Mazoku" LootListId = "test" -metadata/CampId = "Mazoku" -metadata/MaxHp = 50 -metadata/Name = "死灵法师" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, 4) diff --git a/prefab/packsacks/PortableBackpacks.tscn b/prefab/packsacks/PortableBackpacks.tscn index 1f936f2..3079339 100644 --- a/prefab/packsacks/PortableBackpacks.tscn +++ b/prefab/packsacks/PortableBackpacks.tscn @@ -14,9 +14,6 @@ collision_layer = 8 collision_mask = 38 script = ExtResource("1_slakl") NumberSlots = 30 -BackpackAllowed = null -_minContactInjury = null -_maxContactInjury = null [node name="DamageArea2D" type="Area2D" parent="."] collision_layer = 8 diff --git a/prefab/projectile/curseOfTheUndead.tscn b/prefab/projectile/curseOfTheUndead.tscn index 3f34eb5..36c5bbb 100644 --- a/prefab/projectile/curseOfTheUndead.tscn +++ b/prefab/projectile/curseOfTheUndead.tscn @@ -12,11 +12,13 @@ radius = 11.0 collision_layer = 0 collision_mask = 0 script = ExtResource("1_ib3qh") -metadata/Speed = 500.0 -metadata/Durability = 1.0 -metadata/DamageType = 2 -metadata/Knockback = Vector2(2, -3) -metadata/Life = 5000 +Life = 5000 +Durability = 1.0 +MaxDamage = 3 +MinDamage = 10 +DamageType = 2 +KnockbackForce = Vector2(2, -3) +Speed = 500.0 [node name="CurseOfTheUndead" type="Sprite2D" parent="."] texture = ExtResource("1_k8el6") diff --git a/prefab/roomTemplates/dungeon/horizontalCorridor.tscn b/prefab/roomTemplates/dungeon/horizontalCorridor.tscn index b619abc..40c2b67 100644 --- a/prefab/roomTemplates/dungeon/horizontalCorridor.tscn +++ b/prefab/roomTemplates/dungeon/horizontalCorridor.tscn @@ -53,7 +53,7 @@ shape = SubResource("RectangleShape2D_7tsse") [node name="Marker2D" type="Marker2D" parent="."] position = Vector2(260, 87) script = ExtResource("2_wamhd") -metadata/ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn" +ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn" [node name="NavigationRegion2D" type="NavigationRegion2D" parent="."] navigation_polygon = SubResource("NavigationPolygon_rh1gx") diff --git a/scripts/camp/CampManager.cs b/scripts/camp/CampManager.cs index 3ee99c3..6d5bbe8 100644 --- a/scripts/camp/CampManager.cs +++ b/scripts/camp/CampManager.cs @@ -9,7 +9,7 @@ namespace ColdMint.scripts.camp; /// public static class CampManager { - private static readonly Dictionary Camps = new Dictionary(); + private static readonly Dictionary Camps = new(); /// /// The default camp is returned if no corresponding camp is obtained diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 225aea6..d6d8642 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -75,7 +75,8 @@ public partial class CharacterTemplate : CharacterBody2D public string? ReadOnlyCharacterName => CharacterName; - protected string? CharacterName; + [Export] + public string? CharacterName; protected IItemContainer? ProtectedItemContainer; @@ -156,15 +157,18 @@ public partial class CharacterTemplate : CharacterBody2D //The initial health of the character after creation //角色创建后的初始血量 - private int _initialHp; + [Export] + public int InitialHp; + [Export] public int MaxHp; /// /// The camp ID of the role /// 角色的阵营ID /// - public string CampId = null!; + [Export] + public string? CampId; private DamageNumberNodeSpawn? _damageNumber; @@ -253,9 +257,6 @@ public partial class CharacterTemplate : CharacterBody2D { base._Ready(); PickingRangeBodiesList = new List(); - CharacterName = GetMeta("Name", Name).AsString(); - CampId = GetMeta("CampId", Config.CampId.Default).AsString(); - MaxHp = GetMeta("MaxHp", Config.DefaultMaxHp).AsInt32(); if (MaxHp <= 0) { @@ -264,15 +265,14 @@ public partial class CharacterTemplate : CharacterBody2D MaxHp = Config.DefaultMaxHp; } - _initialHp = GetMeta("InitialHp", "0").AsInt32(); - if (_initialHp <= 0 || _initialHp > MaxHp) + if (InitialHp <= 0 || InitialHp > MaxHp) { //If the initial health is less than or equal to 0 or greater than the maximum health, then set it to the maximum health //如果初始血量小于等于0或者大于最大血量,那么将其设置为最大血量 - _initialHp = MaxHp; + InitialHp = MaxHp; } - CurrentHp = _initialHp; + CurrentHp = InitialHp; //The health bar of a creature may be null. //生物的健康条,可能为null。 _healthBar = GetNodeOrNull("HealthBar"); diff --git a/scripts/map/AiCharacterSpawn.cs b/scripts/map/AiCharacterSpawn.cs index 03d598a..5032544 100644 --- a/scripts/map/AiCharacterSpawn.cs +++ b/scripts/map/AiCharacterSpawn.cs @@ -12,14 +12,15 @@ namespace ColdMint.scripts.map; public partial class AiCharacterSpawn : Marker2D { private PackedScene? _packedScene; + [Export] + public string? ResPath; public override void _Ready() { base._Ready(); - var resPath = GetMeta("ResPath", Name).AsString(); - if (!string.IsNullOrEmpty(resPath)) + if (!string.IsNullOrEmpty(ResPath)) { - _packedScene = GD.Load(resPath); + _packedScene = GD.Load(ResPath); } EventManager.AiCharacterGenerateEvent += OnAiCharacterGenerateEvent; diff --git a/scripts/projectile/Projectile.cs b/scripts/projectile/Projectile.cs index 97432f0..18c707d 100644 --- a/scripts/projectile/Projectile.cs +++ b/scripts/projectile/Projectile.cs @@ -16,17 +16,22 @@ namespace ColdMint.scripts.projectile; /// public partial class Projectile : CharacterBody2D { - private long _life; + /// + /// life(ms) + /// 子弹的存在时间(毫秒) + /// + [Export] + public long Life; //The durability of the projectile //抛射体的耐久度 //When the projectile hits the object, the durability will be reduced, and when the durability is less than or equal to 0, the projectile will be destroyed //当抛射体撞击到物体时,会减少耐久度,当耐久度小于等于0时,销毁抛射体 - private double _durability; + [Export] public double Durability; - private int _maxDamage; - private int _minDamage; - private int _damageType; + [Export] public int MaxDamage; + [Export] public int MinDamage; + [Export] public int DamageType; /// /// After this time destroy the projectile @@ -49,9 +54,10 @@ public partial class Projectile : CharacterBody2D ///How much force does it have when hitting the character? Unit: Number of cells,The X direction of the force is inferred automatically. ///当击中角色时带有多大的力?单位:格数,力的X方向是自动推断的。 /// - private Vector2 _knockbackForce; + [Export] + public Vector2 KnockbackForce; - public float Speed => GetMeta("Speed", "15").AsSingle(); + [Export] public float Speed; private List? _projectileDecorators; @@ -70,22 +76,14 @@ public partial class Projectile : CharacterBody2D _area2D.Monitoring = true; _area2D.BodyEntered += OnBodyEnter; _area2D.BodyExited += OnBodyExited; - _durability = GetMeta("Durability", "1").AsDouble(); - _maxDamage = GetMeta("MaxDamage", "7").AsInt32(); - _minDamage = GetMeta("MinDamage", "5").AsInt32(); - _damageType = GetMeta("DamageType", Config.DamageType.Physical).AsInt32(); - _knockbackForce = GetMeta("Knockback", Vector2.Zero).AsVector2(); - //life(ms) - //子弹的存在时间(毫秒) - _life = GetMeta("Life", "10000").AsInt64(); //If the existence time is less than or equal to 0, then it is set to exist for 10 seconds, and projectiles that exist indefinitely are prohibited //如果存在时间小于等于0,那么设置为存在10秒,禁止无限期存在的抛射体 - if (_life <= 0) + if (Life <= 0) { - _life = 10000; + Life = 10000; } - _destructionTime = DateTime.Now.AddMilliseconds(_life); + _destructionTime = DateTime.Now.AddMilliseconds(Life); } /// @@ -180,12 +178,12 @@ public partial class Projectile : CharacterBody2D var damage = new Damage { Attacker = owner, - MaxDamage = _maxDamage, - MinDamage = _minDamage + MaxDamage = MaxDamage, + MinDamage = MinDamage }; damage.CreateDamage(); damage.MoveLeft = Velocity.X < 0; - damage.Type = _damageType; + damage.Type = DamageType; var dead = characterTemplate.Damage(damage); if (dead) { @@ -194,12 +192,12 @@ public partial class Projectile : CharacterBody2D InvokeDecorators(decorator => { decorator.OnKillCharacter(owner, characterTemplate); }); } - if (_knockbackForce != Vector2.Zero) + if (KnockbackForce != Vector2.Zero) { //If we set the attack force, then apply the force to the object //如果我们设置了攻退力,那么将力应用到对象上 var force = new Vector2(); - var forceX = Math.Abs(_knockbackForce.X); + var forceX = Math.Abs(KnockbackForce.X); if (Velocity.X < 0) { //Beat back to port @@ -208,18 +206,18 @@ public partial class Projectile : CharacterBody2D } force.X = forceX * Config.CellSize; - force.Y = _knockbackForce.Y * Config.CellSize; + force.Y = KnockbackForce.Y * Config.CellSize; characterTemplate.AddForce(force); } } else if (target is PickAbleTemplate pickAbleTemplate) { - if (_knockbackForce != Vector2.Zero) + if (KnockbackForce != Vector2.Zero) { //If we set the attack force, then apply the force to the object //如果我们设置了攻退力,那么将力应用到对象上 var force = new Vector2(); - var forceX = Math.Abs(_knockbackForce.X); + var forceX = Math.Abs(KnockbackForce.X); if (Velocity.X < 0) { //Beat back to port @@ -228,7 +226,7 @@ public partial class Projectile : CharacterBody2D } force.X = forceX * Config.CellSize; - force.Y = _knockbackForce.Y * Config.CellSize; + force.Y = KnockbackForce.Y * Config.CellSize; pickAbleTemplate.ApplyImpulse(force); } } @@ -272,8 +270,8 @@ public partial class Projectile : CharacterBody2D //请在Mask内配置子弹会和谁碰撞 //When a bullet hits an object, its durability decreases //子弹撞击到物体时,耐久度减少 - _durability--; - if (_durability <= 0) + Durability--; + if (Durability <= 0) { //When the durability is less than or equal to 0, destroy the bullet //当耐久度小于等于0时,销毁子弹 diff --git a/sprites/Player.png b/sprites/Player.png index 957abca..94c898c 100644 Binary files a/sprites/Player.png and b/sprites/Player.png differ