妥協案

慣性をゼロにして蜘蛛と重ならないようにする
This commit is contained in:
oogushiyuuga
2026-07-06 17:59:19 +09:00
parent 4d3fee6ca5
commit bb90c969b4
8 changed files with 8146 additions and 94 deletions

View File

@@ -11,7 +11,7 @@ public class BossController : MonoBehaviour
[SerializeField] private float maxHp = 500f;
[SerializeField] private float currentHp = 500f;
[SerializeField] public float chaseRange = 15f;
[SerializeField] public float biteRange = 2.5f;
[SerializeField] public float biteRange = 8f;
[Header("必殺技(天井)設定")]
[Tooltip("天井の待機座標となる空のGameObjectのTransformを指定してください")]
@@ -30,6 +30,20 @@ public class BossController : MonoBehaviour
[SerializeField] public float chargeDuration = 2f;
[SerializeField] public float chargeMinimumDistance = 6f;
[SerializeField] public float chargeCooldownDuration = 4f;
// ─── ボス固有の通常移動パラメーターStart時に自動キャッシュされます ───
public float NormalSpeed { get; private set; }
public float NormalAcceleration { get; private set; }
private void Start()
{
// インセペクターで設定されたNavMeshAgentの初期値を記憶しておく
if (Agent != null)
{
NormalSpeed = Agent.speed;
NormalAcceleration = Agent.acceleration;
}
}
#endregion
#region
@@ -41,7 +55,7 @@ public class BossController : MonoBehaviour
#region FSM
private ISpiderState currentState;
// ステートのインスタンスをキャッシュ(ガベージコレクションの発生を抑える)
private Dictionary<System.Type, ISpiderState> stateCache;
@@ -55,7 +69,7 @@ public class BossController : MonoBehaviour
{
Agent = GetComponent<NavMeshAgent>();
Anim = GetComponent<Animator>();
GameObject pObj = GameObject.FindGameObjectWithTag("Player");
if (pObj != null) Player = pObj.transform;
@@ -79,20 +93,16 @@ public class BossController : MonoBehaviour
ChangeState<SpiderIdleState>();
}
private void Update()
private void Update()
{
currentState?.UpdateState();
// ★新設突進のクールダウンのみ、通常のUpdateで常に独立して減算する
if (ChargeCooldownTimer > 0f)
{
ChargeCooldownTimer -= Time.deltaTime;
}
}
/// <summary>
/// オブジェクト指向に基づいた、型安全なステート遷移メソッド
/// </summary>
public void ChangeState<T>() where T : ISpiderState
{
if (currentState != null)
@@ -136,8 +146,8 @@ public class BossController : MonoBehaviour
private void TriggerPhaseTransition()
{
// 咆哮、ジャンプ、スタン中以外であれば、現在の行動をキャンセルして即座に天井へエスケープ
if (currentState is not SpiderJumpToCeilingState &&
currentState is not SpiderCeilingAttackState &&
if (currentState is not SpiderJumpToCeilingState &&
currentState is not SpiderCeilingAttackState &&
currentState is not SpiderStunState)
{
ChangeState<SpiderJumpToCeilingState>();