妥協案
慣性をゼロにして蜘蛛と重ならないようにする
This commit is contained in:
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user