Upgrade to 4.3.

升级到4.3。
This commit is contained in:
Cold-Mint 2024-08-15 22:58:28 +08:00
parent 5d9643476f
commit 8c02a0548c
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
10 changed files with 49 additions and 73 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.3.0-rc.3"> <Project Sdk="Godot.NET.Sdk/4.3.0">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework> <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>

View File

@ -15,12 +15,6 @@ slide_on_ceiling = false
platform_floor_layers = 4294967042 platform_floor_layers = 4294967042
platform_wall_layers = 32 platform_wall_layers = 32
script = ExtResource("1_ib3qh") script = ExtResource("1_ib3qh")
Life = 30000
Durability = 3.0
MaxDamage = 3
MinDamage = 10
DamageType = 2
KnockbackForce = Vector2(2, -3)
Speed = 300.0 Speed = 300.0
IgnoreWall = true IgnoreWall = true
EnableTracking = true EnableTracking = true

View File

@ -1,25 +1,21 @@
[gd_scene load_steps=5 format=3 uid="uid://c01av43yk1q71"] [gd_scene load_steps=4 format=3 uid="uid://c01av43yk1q71"]
[ext_resource type="Script" path="res://scripts/projectile/Projectile.cs" id="1_ib3qh"] [ext_resource type="Script" path="res://scripts/projectile/Projectile.cs" id="1_ib3qh"]
[ext_resource type="Texture2D" uid="uid://bbcjkyrsx88av" path="res://sprites/projectile/curseOfTheUndead.png" id="1_k8el6"] [ext_resource type="Texture2D" uid="uid://bbcjkyrsx88av" path="res://sprites/projectile/curseOfTheUndead.png" id="1_k8el6"]
[sub_resource type="CircleShape2D" id="CircleShape2D_dgro2"] [sub_resource type="CircleShape2D" id="CircleShape2D_dgro2"]
[sub_resource type="CircleShape2D" id="CircleShape2D_8117d"]
radius = 11.0
[node name="curseOfTheUndead" type="CharacterBody2D"] [node name="curseOfTheUndead" type="CharacterBody2D"]
collision_layer = 0 collision_layer = 0
collision_mask = 0 collision_mask = 0
script = ExtResource("1_ib3qh") script = ExtResource("1_ib3qh")
Life = 30000 _life = 5000
Durability = 1.0 _durability = 1.0
MaxDamage = 3 _maxDamage = 10
MinDamage = 10 _minDamage = 1
DamageType = 2 _damageType = 2
KnockbackForce = Vector2(2, -3) _knockbackForce = Vector2(60, 0)
Speed = 500.0 Speed = 500.0
IgnoreWall = true
[node name="CurseOfTheUndead" type="Sprite2D" parent="."] [node name="CurseOfTheUndead" type="Sprite2D" parent="."]
texture = ExtResource("1_k8el6") texture = ExtResource("1_k8el6")
@ -27,13 +23,6 @@ texture = ExtResource("1_k8el6")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_dgro2") shape = SubResource("CircleShape2D_dgro2")
[node name="CollisionDetectionArea" type="Area2D" parent="."]
collision_layer = 16
collision_mask = 206
[node name="CollisionShape2D" type="CollisionShape2D" parent="CollisionDetectionArea"]
shape = SubResource("CircleShape2D_8117d")
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] [node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
bus = &"SoundEffect" bus = &"SoundEffect"
area_mask = 16 area_mask = 16

View File

@ -2,8 +2,8 @@
[ext_resource type="Texture2D" uid="uid://wt50kx6bup51" path="res://sprites/weapon/StaffNecromancy.png" id="1_ms3us"] [ext_resource type="Texture2D" uid="uid://wt50kx6bup51" path="res://sprites/weapon/StaffNecromancy.png" id="1_ms3us"]
[ext_resource type="Script" path="res://scripts/weapon/ProjectileWeapon.cs" id="1_w8hhv"] [ext_resource type="Script" path="res://scripts/weapon/ProjectileWeapon.cs" id="1_w8hhv"]
[ext_resource type="PackedScene" uid="uid://c01av43yk1q71" path="res://prefab/projectile/curseOfTheUndead.tscn" id="2_mwli5"]
[ext_resource type="Texture2D" uid="uid://dg5vwprt66w4j" path="res://sprites/weapon/StaffNecromancy_Icon.png" id="3_31iau"] [ext_resource type="Texture2D" uid="uid://dg5vwprt66w4j" path="res://sprites/weapon/StaffNecromancy_Icon.png" id="3_31iau"]
[ext_resource type="PackedScene" uid="uid://bdxgx5vcof8em" path="res://prefab/projectile/Catapult.tscn" id="3_hk5nr"]
[ext_resource type="AudioStream" uid="uid://cak6chjjsu7wo" path="res://sounds/fire.wav" id="4_ffr2k"] [ext_resource type="AudioStream" uid="uid://cak6chjjsu7wo" path="res://sounds/fire.wav" id="4_ffr2k"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_obcq2"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_obcq2"]
@ -18,7 +18,7 @@ collision_mask = 34
angular_damp = -1.0 angular_damp = -1.0
script = ExtResource("1_w8hhv") script = ExtResource("1_w8hhv")
OffsetAngle = 0.087 OffsetAngle = 0.087
ProjectileScenes = [ExtResource("3_hk5nr")] ProjectileScenes = [ExtResource("2_mwli5")]
Sequentially = true Sequentially = true
FiringIntervalAsMillisecond = 300 FiringIntervalAsMillisecond = 300
UniqueIcon = ExtResource("3_31iau") UniqueIcon = ExtResource("3_31iau")

View File

@ -27,7 +27,7 @@ public partial class DamageNumber : CharacterBody2D
private bool _enableGravity; private bool _enableGravity;
public void SetVelocity(Vector2 velocity) public new void SetVelocity(Vector2 velocity)
{ {
Velocity = velocity; Velocity = velocity;
_enableGravity = true; _enableGravity = true;

View File

@ -9,7 +9,9 @@ namespace ColdMint.scripts.database;
/// </summary> /// </summary>
public class GameDbContext(DbContextOptions<GameDbContext> options) : DbContext(options) public class GameDbContext(DbContextOptions<GameDbContext> options) : DbContext(options)
{ {
// ReSharper disable UnusedAutoPropertyAccessor.Global
public DbSet<ErrorRecord> ErrorRecords { get; set; } public DbSet<ErrorRecord> ErrorRecords { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
/// <summary> /// <summary>
/// <para>Async add error record</para> /// <para>Async add error record</para>

View File

@ -291,14 +291,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
if (_nodeBinding.TagLineEdit != null) if (_nodeBinding.TagLineEdit != null)
{ {
if (_hasStartNode) _nodeBinding.TagLineEdit.Text = _hasStartNode ? string.Empty : Config.RoomDataTag.StartingRoom;
{
_nodeBinding.TagLineEdit.Text = string.Empty;
}
else
{
_nodeBinding.TagLineEdit.Text = Config.RoomDataTag.StartingRoom;
}
} }
if (_nodeBinding.HBoxContainer != null) if (_nodeBinding.HBoxContainer != null)
@ -316,6 +309,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
{ {
return; return;
} }
GetTree().ChangeSceneToPacked(_mainMenu); GetTree().ChangeSceneToPacked(_mainMenu);
}; };
} }
@ -534,11 +528,6 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
{ {
foreach (var dictionary in connectionList) foreach (var dictionary in connectionList)
{ {
if (dictionary == null)
{
continue;
}
var keys = dictionary.Keys; var keys = dictionary.Keys;
if (keys.Count == 0) if (keys.Count == 0)
{ {
@ -735,4 +724,4 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
_nodeBinding.HBoxContainer.Show(); _nodeBinding.HBoxContainer.Show();
} }
} }
} }

View File

@ -2,7 +2,6 @@
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.Loader; using System.Runtime.Loader;
using ColdMint.scripts.debug; using ColdMint.scripts.debug;
using ColdMint.scripts.utils; using ColdMint.scripts.utils;

View File

@ -19,17 +19,17 @@ public partial class Projectile : CharacterBody2D
/// <para>life(ms)</para> /// <para>life(ms)</para>
/// <para>子弹的存在时间(毫秒)</para> /// <para>子弹的存在时间(毫秒)</para>
/// </summary> /// </summary>
[Export] public long Life; [Export] private long _life;
//The durability of the projectile //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 //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时销毁抛射体 //当抛射体撞击到物体时会减少耐久度当耐久度小于等于0时销毁抛射体
[Export] public double Durability; [Export] private double _durability;
[Export] public int MaxDamage; [Export] private int _maxDamage;
[Export] public int MinDamage; [Export] private int _minDamage;
[Export] public int DamageType; [Export] private int _damageType;
/// <summary> /// <summary>
/// <para>After this time destroy the projectile</para> /// <para>After this time destroy the projectile</para>
@ -38,14 +38,14 @@ public partial class Projectile : CharacterBody2D
private DateTime? _destructionTime; private DateTime? _destructionTime;
/// <summary> /// <summary>
/// <para>knockback</para> /// <para>knockBack</para>
/// <para>击退</para> /// <para>击退</para>
/// </summary> /// </summary>
/// <remarks> /// <remarks>
///<para>How much force does it have when hitting the character? Unit: Number of cellsThe X direction of the force is inferred automatically.</para> ///<para>How much force does it have when hitting the character? Unit: Number of cellsThe X direction of the force is inferred automatically.</para>
///<para>当击中角色时带有多大的力单位格数力的X方向是自动推断的。</para> ///<para>当击中角色时带有多大的力单位格数力的X方向是自动推断的。</para>
/// </remarks> /// </remarks>
[Export] public Vector2 KnockbackForce; [Export] private Vector2 _knockBackForce;
[Export] public float Speed; [Export] public float Speed;
@ -53,25 +53,25 @@ public partial class Projectile : CharacterBody2D
/// <para>Whether it bounces back after hitting an enemy or a wall</para> /// <para>Whether it bounces back after hitting an enemy or a wall</para>
/// <para>是否撞到敌人或墙壁后反弹</para> /// <para>是否撞到敌人或墙壁后反弹</para>
/// </summary> /// </summary>
[Export] public bool EnableBounce; [Export] private bool _enableBounce;
/// <summary> /// <summary>
/// <para>Can it penetrate the wall</para> /// <para>Can it penetrate the wall</para>
/// <para>是否可以穿透墙壁</para> /// <para>是否可以穿透墙壁</para>
/// </summary> /// </summary>
[Export] public bool IgnoreWall; [Export] private bool _ignoreWall;
/// <summary> /// <summary>
/// <para>Enable the tracking of the enemy</para> /// <para>Enable the tracking of the enemy</para>
/// <para>启用追踪敌人的功能</para> /// <para>启用追踪敌人的功能</para>
/// </summary> /// </summary>
[Export] public bool EnableTracking; [Export] private bool _enableTracking;
/// <summary> /// <summary>
/// <para>The target</para> /// <para>The target</para>
/// <para>设置目标</para> /// <para>设置目标</para>
/// </summary> /// </summary>
public Node2D? Target { get; set; } private Node2D? Target { get; set; }
private List<IProjectileDecorator>? _projectileDecorators; private List<IProjectileDecorator>? _projectileDecorators;
@ -86,14 +86,17 @@ public partial class Projectile : CharacterBody2D
{ {
//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 //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秒禁止无限期存在的抛射体 //如果存在时间小于等于0那么设置为存在10秒禁止无限期存在的抛射体
if (Life <= 0) if (_life <= 0)
{ {
Life = 10000; _life = 10000;
} }
_destructionTime = DateTime.Now.AddMilliseconds(Life); _destructionTime = DateTime.Now.AddMilliseconds(_life);
SetCollisionMaskValue(Config.LayerNumber.Wall, !IgnoreWall); SetCollisionLayerValue(Config.LayerNumber.Projectile, true);
SetCollisionMaskValue(Config.LayerNumber.Floor, !IgnoreWall); SetCollisionMaskValue(Config.LayerNumber.Wall, !_ignoreWall);
SetCollisionMaskValue(Config.LayerNumber.Floor, !_ignoreWall);
SetCollisionMaskValue(Config.LayerNumber.Player, true);
SetCollisionMaskValue(Config.LayerNumber.Mob, true);
//Platform collision layer is not allowed to collide //Platform collision layer is not allowed to collide
//平台碰撞层不可碰撞 //平台碰撞层不可碰撞
SetCollisionMaskValue(Config.LayerNumber.Platform, false); SetCollisionMaskValue(Config.LayerNumber.Platform, false);
@ -189,12 +192,12 @@ public partial class Projectile : CharacterBody2D
var damage = new Damage var damage = new Damage
{ {
Attacker = owner, Attacker = owner,
MaxDamage = MaxDamage, MaxDamage = _maxDamage,
MinDamage = MinDamage MinDamage = _minDamage
}; };
damage.CreateDamage(); damage.CreateDamage();
damage.MoveLeft = Velocity.X < 0; damage.MoveLeft = Velocity.X < 0;
damage.Type = DamageType; damage.Type = _damageType;
var dead = characterTemplate.Damage(damage); var dead = characterTemplate.Damage(damage);
if (dead) if (dead)
{ {
@ -203,12 +206,12 @@ public partial class Projectile : CharacterBody2D
InvokeDecorators(decorator => { decorator.OnKillCharacter(owner, characterTemplate); }); 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 //If we set the attack force, then apply the force to the object
//如果我们设置了攻退力,那么将力应用到对象上 //如果我们设置了攻退力,那么将力应用到对象上
var force = new Vector2(); var force = new Vector2();
var forceX = Math.Abs(KnockbackForce.X); var forceX = Math.Abs(_knockBackForce.X);
if (Velocity.X < 0) if (Velocity.X < 0)
{ {
//Beat back to port //Beat back to port
@ -217,18 +220,18 @@ public partial class Projectile : CharacterBody2D
} }
force.X = forceX * Config.CellSize; force.X = forceX * Config.CellSize;
force.Y = KnockbackForce.Y * Config.CellSize; force.Y = _knockBackForce.Y * Config.CellSize;
characterTemplate.AddForce(force); characterTemplate.AddForce(force);
} }
} }
else if (target is PickAbleTemplate pickAbleTemplate) 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 //If we set the attack force, then apply the force to the object
//如果我们设置了攻退力,那么将力应用到对象上 //如果我们设置了攻退力,那么将力应用到对象上
var force = new Vector2(); var force = new Vector2();
var forceX = Math.Abs(KnockbackForce.X); var forceX = Math.Abs(_knockBackForce.X);
if (Velocity.X < 0) if (Velocity.X < 0)
{ {
//Beat back to port //Beat back to port
@ -237,7 +240,7 @@ public partial class Projectile : CharacterBody2D
} }
force.X = forceX * Config.CellSize; force.X = forceX * Config.CellSize;
force.Y = KnockbackForce.Y * Config.CellSize; force.Y = _knockBackForce.Y * Config.CellSize;
pickAbleTemplate.ApplyImpulse(force); pickAbleTemplate.ApplyImpulse(force);
} }
} }
@ -287,7 +290,7 @@ public partial class Projectile : CharacterBody2D
{ {
//No collision. //No collision.
//没有撞到任何东西。 //没有撞到任何东西。
if (EnableTracking && Target != null) if (_enableTracking && Target != null)
{ {
//Track the target //Track the target
//追踪目标 //追踪目标
@ -303,7 +306,7 @@ public partial class Projectile : CharacterBody2D
{ {
//Bump into other objects. //Bump into other objects.
//撞到其他对象。 //撞到其他对象。
if (EnableBounce) if (_enableBounce)
{ {
Velocity = Velocity.Bounce(collisionInfo.GetNormal()); Velocity = Velocity.Bounce(collisionInfo.GetNormal());
} }
@ -323,8 +326,8 @@ public partial class Projectile : CharacterBody2D
//请在Mask内配置子弹会和谁碰撞 //请在Mask内配置子弹会和谁碰撞
//When a bullet hits an object, its durability decreases //When a bullet hits an object, its durability decreases
//子弹撞击到物体时,耐久度减少 //子弹撞击到物体时,耐久度减少
Durability--; _durability--;
if (Durability <= 0) if (_durability <= 0)
{ {
//When the durability is less than or equal to 0, destroy the bullet //When the durability is less than or equal to 0, destroy the bullet
//当耐久度小于等于0时销毁子弹 //当耐久度小于等于0时销毁子弹

View File

@ -29,6 +29,6 @@ public static class TranslationServerUtils
/// <returns></returns> /// <returns></returns>
public static string? Translate(string? key) public static string? Translate(string? key)
{ {
return TranslationServer.Translate(key); return key == null ? null : TranslationServer.Translate(key);
} }
} }