From 8c02a0548cab230887b582af54c148b0aeed0b76 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Thu, 15 Aug 2024 22:58:28 +0800 Subject: [PATCH] =?UTF-8?q?Upgrade=20to=204.3.=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=B04.3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ColdMint.Traveler.csproj | 2 +- prefab/projectile/Catapult.tscn | 6 -- prefab/projectile/curseOfTheUndead.tscn | 25 +++----- prefab/weapons/StaffNecromancy.tscn | 4 +- scripts/damage/DamageNumber.cs | 2 +- scripts/database/GameDbContext.cs | 2 + .../loader/uiLoader/LevelGraphEditorLoader.cs | 17 +----- scripts/mod/ModLoader.cs | 1 - scripts/projectile/Projectile.cs | 61 ++++++++++--------- scripts/utils/TranslationServerUtils.cs | 2 +- 10 files changed, 49 insertions(+), 73 deletions(-) diff --git a/ColdMint.Traveler.csproj b/ColdMint.Traveler.csproj index c2e6d54..2c11ffe 100644 --- a/ColdMint.Traveler.csproj +++ b/ColdMint.Traveler.csproj @@ -1,4 +1,4 @@ - + net6.0 net7.0 diff --git a/prefab/projectile/Catapult.tscn b/prefab/projectile/Catapult.tscn index cccc863..8c4a986 100644 --- a/prefab/projectile/Catapult.tscn +++ b/prefab/projectile/Catapult.tscn @@ -15,12 +15,6 @@ slide_on_ceiling = false platform_floor_layers = 4294967042 platform_wall_layers = 32 script = ExtResource("1_ib3qh") -Life = 30000 -Durability = 3.0 -MaxDamage = 3 -MinDamage = 10 -DamageType = 2 -KnockbackForce = Vector2(2, -3) Speed = 300.0 IgnoreWall = true EnableTracking = true diff --git a/prefab/projectile/curseOfTheUndead.tscn b/prefab/projectile/curseOfTheUndead.tscn index 0be0bb3..543ba4b 100644 --- a/prefab/projectile/curseOfTheUndead.tscn +++ b/prefab/projectile/curseOfTheUndead.tscn @@ -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="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_8117d"] -radius = 11.0 - [node name="curseOfTheUndead" type="CharacterBody2D"] collision_layer = 0 collision_mask = 0 script = ExtResource("1_ib3qh") -Life = 30000 -Durability = 1.0 -MaxDamage = 3 -MinDamage = 10 -DamageType = 2 -KnockbackForce = Vector2(2, -3) +_life = 5000 +_durability = 1.0 +_maxDamage = 10 +_minDamage = 1 +_damageType = 2 +_knockbackForce = Vector2(60, 0) Speed = 500.0 -IgnoreWall = true [node name="CurseOfTheUndead" type="Sprite2D" parent="."] texture = ExtResource("1_k8el6") @@ -27,13 +23,6 @@ texture = ExtResource("1_k8el6") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] 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="."] bus = &"SoundEffect" area_mask = 16 diff --git a/prefab/weapons/StaffNecromancy.tscn b/prefab/weapons/StaffNecromancy.tscn index a186043..ce940cc 100644 --- a/prefab/weapons/StaffNecromancy.tscn +++ b/prefab/weapons/StaffNecromancy.tscn @@ -2,8 +2,8 @@ [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="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="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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_obcq2"] @@ -18,7 +18,7 @@ collision_mask = 34 angular_damp = -1.0 script = ExtResource("1_w8hhv") OffsetAngle = 0.087 -ProjectileScenes = [ExtResource("3_hk5nr")] +ProjectileScenes = [ExtResource("2_mwli5")] Sequentially = true FiringIntervalAsMillisecond = 300 UniqueIcon = ExtResource("3_31iau") diff --git a/scripts/damage/DamageNumber.cs b/scripts/damage/DamageNumber.cs index 4cc68c4..e1eb780 100644 --- a/scripts/damage/DamageNumber.cs +++ b/scripts/damage/DamageNumber.cs @@ -27,7 +27,7 @@ public partial class DamageNumber : CharacterBody2D private bool _enableGravity; - public void SetVelocity(Vector2 velocity) + public new void SetVelocity(Vector2 velocity) { Velocity = velocity; _enableGravity = true; diff --git a/scripts/database/GameDbContext.cs b/scripts/database/GameDbContext.cs index 922d056..37c054e 100644 --- a/scripts/database/GameDbContext.cs +++ b/scripts/database/GameDbContext.cs @@ -9,7 +9,9 @@ namespace ColdMint.scripts.database; /// public class GameDbContext(DbContextOptions options) : DbContext(options) { + // ReSharper disable UnusedAutoPropertyAccessor.Global public DbSet ErrorRecords { get; set; } + // ReSharper restore UnusedAutoPropertyAccessor.Global /// /// Async add error record diff --git a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs index 826caad..e3a3180 100644 --- a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs +++ b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs @@ -291,14 +291,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate if (_nodeBinding.TagLineEdit != null) { - if (_hasStartNode) - { - _nodeBinding.TagLineEdit.Text = string.Empty; - } - else - { - _nodeBinding.TagLineEdit.Text = Config.RoomDataTag.StartingRoom; - } + _nodeBinding.TagLineEdit.Text = _hasStartNode ? string.Empty : Config.RoomDataTag.StartingRoom; } if (_nodeBinding.HBoxContainer != null) @@ -316,6 +309,7 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate { return; } + GetTree().ChangeSceneToPacked(_mainMenu); }; } @@ -534,11 +528,6 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate { foreach (var dictionary in connectionList) { - if (dictionary == null) - { - continue; - } - var keys = dictionary.Keys; if (keys.Count == 0) { @@ -735,4 +724,4 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate _nodeBinding.HBoxContainer.Show(); } } -} +} \ No newline at end of file diff --git a/scripts/mod/ModLoader.cs b/scripts/mod/ModLoader.cs index e1e86be..9955fe5 100644 --- a/scripts/mod/ModLoader.cs +++ b/scripts/mod/ModLoader.cs @@ -2,7 +2,6 @@ using System.Data; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.Loader; using ColdMint.scripts.debug; using ColdMint.scripts.utils; diff --git a/scripts/projectile/Projectile.cs b/scripts/projectile/Projectile.cs index 01c6c82..4acb566 100644 --- a/scripts/projectile/Projectile.cs +++ b/scripts/projectile/Projectile.cs @@ -19,17 +19,17 @@ public partial class Projectile : CharacterBody2D /// life(ms) /// 子弹的存在时间(毫秒) /// - [Export] public long Life; + [Export] private 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时,销毁抛射体 - [Export] public double Durability; + [Export] private double _durability; - [Export] public int MaxDamage; - [Export] public int MinDamage; - [Export] public int DamageType; + [Export] private int _maxDamage; + [Export] private int _minDamage; + [Export] private int _damageType; /// /// After this time destroy the projectile @@ -38,14 +38,14 @@ public partial class Projectile : CharacterBody2D private DateTime? _destructionTime; /// - /// knockback + /// knockBack /// 击退 /// /// ///How much force does it have when hitting the character? Unit: Number of cells,The X direction of the force is inferred automatically. ///当击中角色时带有多大的力?单位:格数,力的X方向是自动推断的。 /// - [Export] public Vector2 KnockbackForce; + [Export] private Vector2 _knockBackForce; [Export] public float Speed; @@ -53,25 +53,25 @@ public partial class Projectile : CharacterBody2D /// Whether it bounces back after hitting an enemy or a wall /// 是否撞到敌人或墙壁后反弹 /// - [Export] public bool EnableBounce; + [Export] private bool _enableBounce; /// /// Can it penetrate the wall /// 是否可以穿透墙壁 /// - [Export] public bool IgnoreWall; + [Export] private bool _ignoreWall; /// /// Enable the tracking of the enemy /// 启用追踪敌人的功能 /// - [Export] public bool EnableTracking; + [Export] private bool _enableTracking; /// /// The target /// 设置目标 /// - public Node2D? Target { get; set; } + private Node2D? Target { get; set; } private List? _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 //如果存在时间小于等于0,那么设置为存在10秒,禁止无限期存在的抛射体 - if (Life <= 0) + if (_life <= 0) { - Life = 10000; + _life = 10000; } - _destructionTime = DateTime.Now.AddMilliseconds(Life); - SetCollisionMaskValue(Config.LayerNumber.Wall, !IgnoreWall); - SetCollisionMaskValue(Config.LayerNumber.Floor, !IgnoreWall); + _destructionTime = DateTime.Now.AddMilliseconds(_life); + SetCollisionLayerValue(Config.LayerNumber.Projectile, true); + 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 //平台碰撞层不可碰撞 SetCollisionMaskValue(Config.LayerNumber.Platform, false); @@ -189,12 +192,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) { @@ -203,12 +206,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 @@ -217,18 +220,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 @@ -237,7 +240,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); } } @@ -287,7 +290,7 @@ public partial class Projectile : CharacterBody2D { //No collision. //没有撞到任何东西。 - if (EnableTracking && Target != null) + if (_enableTracking && Target != null) { //Track the target //追踪目标 @@ -303,7 +306,7 @@ public partial class Projectile : CharacterBody2D { //Bump into other objects. //撞到其他对象。 - if (EnableBounce) + if (_enableBounce) { Velocity = Velocity.Bounce(collisionInfo.GetNormal()); } @@ -323,8 +326,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/scripts/utils/TranslationServerUtils.cs b/scripts/utils/TranslationServerUtils.cs index 2bb9e84..56a526c 100644 --- a/scripts/utils/TranslationServerUtils.cs +++ b/scripts/utils/TranslationServerUtils.cs @@ -29,6 +29,6 @@ public static class TranslationServerUtils /// public static string? Translate(string? key) { - return TranslationServer.Translate(key); + return key == null ? null : TranslationServer.Translate(key); } } \ No newline at end of file