Remove the GetMeta method.
移除GetMeta方法。
This commit is contained in:
parent
4459b6a88b
commit
cceda0bd1f
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace ColdMint.scripts.camp;
|
|||
/// </summary>
|
||||
public static class CampManager
|
||||
{
|
||||
private static readonly Dictionary<string, Camp?> Camps = new Dictionary<string, Camp?>();
|
||||
private static readonly Dictionary<string, Camp?> Camps = new();
|
||||
|
||||
/// <summary>
|
||||
/// <para>The default camp is returned if no corresponding camp is obtained</para>
|
||||
|
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// <para>The camp ID of the role</para>
|
||||
/// <para>角色的阵营ID</para>
|
||||
/// </summary>
|
||||
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<Node>();
|
||||
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>("HealthBar");
|
||||
|
|
|
@ -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<PackedScene>(resPath);
|
||||
_packedScene = GD.Load<PackedScene>(ResPath);
|
||||
}
|
||||
|
||||
EventManager.AiCharacterGenerateEvent += OnAiCharacterGenerateEvent;
|
||||
|
|
|
@ -16,17 +16,22 @@ namespace ColdMint.scripts.projectile;
|
|||
/// </summary>
|
||||
public partial class Projectile : CharacterBody2D
|
||||
{
|
||||
private long _life;
|
||||
/// <summary>
|
||||
/// <para>life(ms)</para>
|
||||
/// <para>子弹的存在时间(毫秒)</para>
|
||||
/// </summary>
|
||||
[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;
|
||||
|
||||
/// <summary>
|
||||
/// <para>After this time destroy the projectile</para>
|
||||
|
@ -49,9 +54,10 @@ public partial class Projectile : CharacterBody2D
|
|||
///<para>How much force does it have when hitting the character? Unit: Number of cells,The X direction of the force is inferred automatically.</para>
|
||||
///<para>当击中角色时带有多大的力?单位:格数,力的X方向是自动推断的。</para>
|
||||
/// </remarks>
|
||||
private Vector2 _knockbackForce;
|
||||
[Export]
|
||||
public Vector2 KnockbackForce;
|
||||
|
||||
public float Speed => GetMeta("Speed", "15").AsSingle();
|
||||
[Export] public float Speed;
|
||||
|
||||
private List<IProjectileDecorator>? _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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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时,销毁子弹
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in New Issue
Block a user