From 6d9b9ca7ec378f9fcc325fc9679953b08098fff6 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sat, 5 Oct 2024 17:15:19 +0800 Subject: [PATCH] =?UTF-8?q?Improved=20the=20loading=20range=20of=20spells.?= =?UTF-8?q?=20=E6=94=B9=E8=BF=9B=E6=B3=95=E6=9C=AF=E7=9A=84=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E8=8C=83=E5=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/Log.csv | 3 ++- scripts/weapon/ProjectileWeapon.cs | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/locals/Log.csv b/locals/Log.csv index 6975cec..2816f9b 100644 --- a/locals/Log.csv +++ b/locals/Log.csv @@ -115,4 +115,5 @@ log_failed_to_create_room_preview,创建{0}的房间预览图失败。,Failed to log_generated_item_is_empty,生成的物品{0}是空的吗{1}。,Generated item {0} is empty {1}.,生成したアイテム{0}は空ですか{1}。 log_projectile_generate_magic_is_null,没有装填可提供抛射体的法术。,There is no reload spell that provides projectiles.,射出体を提供するスペルを装填していません。 log_projectile_scene_is_null,抛射体场景为空。,Projectile scene is empty.,射出体は空です。 -log_projectile_is_null,抛射体为空。,Projectile scene is empty.,射出シーンは空です。 \ No newline at end of file +log_projectile_is_null,抛射体为空。,Projectile scene is empty.,射出シーンは空です。 +log_projectile_weapon_range,加载法术范围{0}顺序模式吗{1}上次发射法术时采用的索引{2}。,Load spell range {0} Sequential mode {1} Index used when the spell was last fired {2}.,スペル範囲{0}順序モードですか{1}前回スペルを送信した時のインデックス{2}。 \ No newline at end of file diff --git a/scripts/weapon/ProjectileWeapon.cs b/scripts/weapon/ProjectileWeapon.cs index 5e0775c..41b8845 100644 --- a/scripts/weapon/ProjectileWeapon.cs +++ b/scripts/weapon/ProjectileWeapon.cs @@ -55,7 +55,7 @@ public partial class ProjectileWeapon : WeaponTemplate /// The index used the last time a spell was cast /// 上次发射法术时采用的索引 /// - private int _lastUsedProjectileMagicIndex; + private int _lastUsedProjectileMagicIndex = -1; /// /// Get next index @@ -69,7 +69,7 @@ public partial class ProjectileWeapon : WeaponTemplate _lastUsedProjectileMagicIndex++; if (_lastUsedProjectileMagicIndex >= _spellProjectileIndexes.Count) { - return 0; + _lastUsedProjectileMagicIndex = 0; } return _lastUsedProjectileMagicIndex; } @@ -83,25 +83,27 @@ public partial class ProjectileWeapon : WeaponTemplate /// Gets the loading range of the spell /// 获取法术的加载范围 /// - /// + /// + ///Return array meaning: 0, starting position 1, ending position 2, with projectile generated spell position, length 3. + ///返回数组的含义为:0,起始位置1,结束位置2,带有抛射体生成的法术位置,长度为3。 + /// private int[] GetSpellScope() { var index = GetNextProjectileMagicIndex(); - var endIndex = _spellProjectileIndexes[index]; + var projectileSpellPosition = _spellProjectileIndexes[index]; + var endIndex = projectileSpellPosition; + var startIndex = 0; if (index > 0) { //And the previous index can set the starting position.(The starting position is increased by 1 to avoid using spells with projectile generation as starting points.) //还有前面的索引可设定起始位置。(这里起始位置加1是为了避免 具有抛射体生成能力的法术 作为起点。) - var startIndex = _spellProjectileIndexes[index - 1] + 1; - return [startIndex, endIndex]; + startIndex = _spellProjectileIndexes[index - 1] + 1; } - else + if (index == _spellProjectileIndexes.Count - 1) { - return - [ - 0, endIndex - ]; + endIndex = _spells.Count - 1; } + return [startIndex, endIndex, projectileSpellPosition]; } public override int ItemType @@ -207,9 +209,10 @@ public partial class ProjectileWeapon : WeaponTemplate return false; } var spellScope = GetSpellScope(); + LogCat.LogWithFormat("projectile_weapon_range", LogCat.LogLabel.Default, true, string.Join(",", spellScope), _fireSequentially, _lastUsedProjectileMagicIndex); //The final spell is a projectile generator. //最后的法术是拥有抛射体生成能力的。 - var spellProjectile = _spells[spellScope[1]]; + var spellProjectile = _spells[spellScope[2]]; var packedScene = spellProjectile.GetProjectile(); if (packedScene == null) {