ボスに着手
This commit is contained in:
187
Assets/Scripts/BossController.cs
Normal file
187
Assets/Scripts/BossController.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[RequireComponent(typeof(NavMeshAgent))]
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class BossController : MonoBehaviour
|
||||
{
|
||||
#region インスペクター設定項目
|
||||
[Header("ステータス設定")]
|
||||
[SerializeField] private float maxHp = 500f;
|
||||
[SerializeField] private float currentHp = 500f;
|
||||
[SerializeField] public float chaseRange = 15f;
|
||||
[SerializeField] public float biteRange = 2.5f;
|
||||
|
||||
[Header("必殺技(天井)設定")]
|
||||
[Tooltip("天井の待機座標となる空のGameObjectのTransformを指定してください")]
|
||||
[SerializeField] public Transform ceilingAnchor;
|
||||
[Tooltip("地上に戻る際の、中央の着地座標のTransformを指定してください")]
|
||||
[SerializeField] public Transform groundAnchor;
|
||||
[Tooltip("天井から糸を発射する範囲の広さ")]
|
||||
[SerializeField] public float attackRadius = 10f;
|
||||
[Tooltip("糸が降る前の予兆マークのPrefab")]
|
||||
[SerializeField] private GameObject warningMarkerPrefab;
|
||||
[Tooltip("地面に残る糸(コライダー&鈍足スクリプト付き)のPrefab")]
|
||||
[SerializeField] private GameObject webPrefab;
|
||||
|
||||
[Header("突進(体当たり)設定")]
|
||||
[SerializeField] public float chargeSpeed = 12f;
|
||||
[SerializeField] public float chargeDuration = 1.5f;
|
||||
#endregion
|
||||
|
||||
#region コンポーネント・キャッシュ用(ステートからアクセス可能)
|
||||
[HideInInspector] public NavMeshAgent Agent { get; private set; }
|
||||
[HideInInspector] public Animator Anim { get; private set; }
|
||||
[HideInInspector] public Transform Player { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region FSM(状態管理)システム
|
||||
private ISpiderState currentState;
|
||||
|
||||
// ステートのインスタンスをキャッシュ(ガベージコレクションの発生を抑える)
|
||||
private Dictionary<System.Type, ISpiderState> stateCache;
|
||||
|
||||
// フェーズ管理用フラグ(50%と25%のトリガー管理)
|
||||
private bool triggered50 = false;
|
||||
private bool triggered25 = false;
|
||||
public bool PendingUltimate { get; set; } = false; // 必殺技の発動権があるか
|
||||
#endregion
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Agent = GetComponent<NavMeshAgent>();
|
||||
Anim = GetComponent<Animator>();
|
||||
|
||||
GameObject pObj = GameObject.FindGameObjectWithTag("Player");
|
||||
if (pObj != null) Player = pObj.transform;
|
||||
|
||||
InitializeFSM();
|
||||
}
|
||||
|
||||
private void InitializeFSM()
|
||||
{
|
||||
stateCache = new Dictionary<System.Type, ISpiderState>
|
||||
{
|
||||
{ typeof(SpiderIdleState), new SpiderIdleState(this) },
|
||||
{ typeof(SpiderChaseState), new SpiderChaseState(this) },
|
||||
{ typeof(SpiderBiteState), new SpiderBiteState(this) },
|
||||
{ typeof(SpiderChargeState), new SpiderChargeState(this) },
|
||||
{ typeof(SpiderJumpToCeilingState), new SpiderJumpToCeilingState(this) },
|
||||
{ typeof(SpiderCeilingAttackState), new SpiderCeilingAttackState(this) },
|
||||
{ typeof(SpiderStunState), new SpiderStunState(this) }
|
||||
};
|
||||
|
||||
// 初期ステートをIdleに設定
|
||||
ChangeState<SpiderIdleState>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 現在のステートのUpdate処理を実行(ポリモーフィズム)
|
||||
currentState?.UpdateState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// オブジェクト指向に基づいた、型安全なステート遷移メソッド
|
||||
/// </summary>
|
||||
public void ChangeState<T>() where T : ISpiderState
|
||||
{
|
||||
if (currentState != null)
|
||||
{
|
||||
currentState.ExitState();
|
||||
Debug.Log($"🕷️ BossSpider [Exit]: {currentState.GetType().Name}");
|
||||
}
|
||||
|
||||
currentState = stateCache[typeof(T)];
|
||||
Debug.Log($"🕷️ BossSpider [Enter]: {currentState.GetType().Name}");
|
||||
currentState.EnterState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ダメージを受け取る外部窓口。HPトリガーによるフェーズ遷移をここで監視する
|
||||
/// </summary>
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
currentHp -= damage;
|
||||
currentHp = Mathf.Clamp(currentHp, 0, maxHp);
|
||||
float hpPercentage = (currentHp / maxHp) * 100f;
|
||||
|
||||
Debug.Log($"💥 ボスに {damage} ダメージ。残りHP: {hpPercentage:F1}%");
|
||||
|
||||
// 25%以下カットのトリガー
|
||||
if (hpPercentage <= 25f && !triggered25)
|
||||
{
|
||||
triggered25 = true;
|
||||
PendingUltimate = true;
|
||||
TriggerPhaseTransition();
|
||||
}
|
||||
// 50%以下カットのトリガー
|
||||
else if (hpPercentage <= 50f && !triggered50 && hpPercentage > 25f)
|
||||
{
|
||||
triggered50 = true;
|
||||
PendingUltimate = true;
|
||||
TriggerPhaseTransition();
|
||||
}
|
||||
}
|
||||
|
||||
private void TriggerPhaseTransition()
|
||||
{
|
||||
// 咆哮、ジャンプ、スタン中以外であれば、現在の行動をキャンセルして即座に天井へエスケープ
|
||||
if (currentState is not SpiderJumpToCeilingState &&
|
||||
currentState is not SpiderCeilingAttackState &&
|
||||
currentState is not SpiderStunState)
|
||||
{
|
||||
ChangeState<SpiderJumpToCeilingState>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 【パリィ連携窓口】プレイヤーのVRInputPunchなどから、パリィ成功時にこのメソッドが叩かれる
|
||||
/// </summary>
|
||||
public void TriggerParryStun()
|
||||
{
|
||||
// パリィを受け付ける攻撃ステート(噛みつき、体当たり)のときのみスタンに移行する
|
||||
if (currentState is SpiderBiteState || currentState is SpiderChargeState)
|
||||
{
|
||||
ChangeState<SpiderStunState>();
|
||||
}
|
||||
}
|
||||
|
||||
#region ファクトリメソッド(エフェクトやオブジェクト生成の保守性を担保)
|
||||
public void SpawnWarningAndWeb(Vector3 targetGroundPos, float delay, float webDuration)
|
||||
{
|
||||
StartCoroutine(SpawnWebRoutine(targetGroundPos, delay, webDuration));
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator SpawnWebRoutine(Vector3 pos, float delay, float duration)
|
||||
{
|
||||
// 1. 地面に予兆マークを生成
|
||||
GameObject marker = null;
|
||||
if (warningMarkerPrefab != null)
|
||||
{
|
||||
marker = Instantiate(warningMarkerPrefab, pos + new Vector3(0, 0.02f, 0), Quaternion.identity);
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(delay);
|
||||
|
||||
// 2. 予兆マークを消し、本物の糸オブジェクトを生成
|
||||
if (marker != null) Destroy(marker);
|
||||
|
||||
if (webPrefab != null)
|
||||
{
|
||||
GameObject web = Instantiate(webPrefab, pos, Quaternion.identity);
|
||||
Destroy(web, duration); // 数秒後に自動消滅
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region 1. ステート共通インターフェース
|
||||
public interface ISpiderState
|
||||
{
|
||||
void EnterState();
|
||||
void UpdateState();
|
||||
void ExitState();
|
||||
}
|
||||
#endregion
|
||||
2
Assets/Scripts/BossController.cs.meta
Normal file
2
Assets/Scripts/BossController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60f7f85851ff9b544a35d5dbe1a21285
|
||||
36
Assets/Scripts/SlowWebArea.cs
Normal file
36
Assets/Scripts/SlowWebArea.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SlowWebArea : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float damagePerSecond = 5f;
|
||||
private float damageTimer = 0f;
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
// ★鈍足効果の適用演出
|
||||
// プレイヤーの移動スクリプトに対し、一時的な速度デバフ(例: Speed * 0.3f)を掛けます
|
||||
// ここでは設計の切り離しのため、ログ出力のみとしています
|
||||
Debug.LogWarning("🕸️ プレイヤーが蜘蛛の糸に囚われている! 【鈍足化デバフ発動中】");
|
||||
|
||||
// スリップダメージ(1秒ごとに継続ダメージ)
|
||||
damageTimer += Time.deltaTime;
|
||||
if (damageTimer >= 1.0f)
|
||||
{
|
||||
// プレイヤーのHealthコンポーネントにダメージを通知
|
||||
// other.GetComponent<PlayerHealth>()?.TakeDamage(damagePerSecond);
|
||||
Debug.Log($"🕸️ 糸によるスリップダメージ: {damagePerSecond}");
|
||||
damageTimer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log("🏃 プレイヤーが糸の範囲から脱出。 鈍足効果解除。");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/SlowWebArea.cs.meta
Normal file
2
Assets/Scripts/SlowWebArea.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0926e85a7d8a1a349a8e4e6e2ddfa0a5
|
||||
334
Assets/Scripts/SpiderIdleState.cs
Normal file
334
Assets/Scripts/SpiderIdleState.cs
Normal file
@@ -0,0 +1,334 @@
|
||||
using UnityEngine;
|
||||
|
||||
// ==========================================
|
||||
// ■ STATE: IDLE (待機状態)
|
||||
// ==========================================
|
||||
public class SpiderIdleState : ISpiderState
|
||||
{
|
||||
private BossController boss;
|
||||
public SpiderIdleState(BossController owner) => boss = owner;
|
||||
|
||||
public void EnterState() => boss.Anim.SetTrigger("Idle");
|
||||
public void ExitState() { }
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
if (boss.Player == null) return;
|
||||
|
||||
// プレイヤーを検知したら即座に追跡へ
|
||||
if (Vector3.Distance(boss.transform.position, boss.Player.position) <= boss.chaseRange)
|
||||
{
|
||||
boss.ChangeState<SpiderChaseState>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ■ STATE: CHASE (追跡・行動分岐状態)
|
||||
// ==========================================
|
||||
public class SpiderChaseState : ISpiderState
|
||||
{
|
||||
private BossController boss;
|
||||
private float decisionCooldown = 0f;
|
||||
|
||||
public SpiderChaseState(BossController owner) => boss = owner;
|
||||
|
||||
public void EnterState() => boss.Agent.isStopped = false;
|
||||
public void ExitState() => boss.Agent.isStopped = true;
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
if (boss.Player == null) return;
|
||||
|
||||
// NavMeshでの追従
|
||||
boss.Agent.SetDestination(boss.Player.position);
|
||||
boss.Anim.SetFloat("Speed", boss.Agent.velocity.magnitude);
|
||||
|
||||
// ディシジョン(思考)タイマーの更新
|
||||
decisionCooldown -= Time.deltaTime;
|
||||
if (decisionCooldown > 0f) return;
|
||||
|
||||
float distance = Vector3.Distance(boss.transform.position, boss.Player.position);
|
||||
|
||||
// 1. 至近距離 ➔ 通常噛みつき
|
||||
if (distance <= boss.biteRange)
|
||||
{
|
||||
boss.ChangeState<SpiderBiteState>();
|
||||
decisionCooldown = 2f;
|
||||
}
|
||||
// 2. 中距離 ➔ 走って体当たり攻撃
|
||||
else if (distance > boss.biteRange && distance <= boss.chaseRange * 0.6f)
|
||||
{
|
||||
boss.ChangeState<SpiderChargeState>();
|
||||
decisionCooldown = 5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ■ STATE: BITE (通常噛みつき - パリィ可)
|
||||
// ==========================================
|
||||
public class SpiderBiteState : ISpiderState
|
||||
{
|
||||
private BossController boss;
|
||||
private float stateTimer;
|
||||
|
||||
public SpiderBiteState(BossController owner) => boss = owner;
|
||||
|
||||
public void EnterState()
|
||||
{
|
||||
stateTimer = 1.5f; // 攻撃アニメーションの想定想定想定
|
||||
boss.Anim.SetTrigger("Attack_Bite");
|
||||
Debug.Log("🎯 蜘蛛ボス:噛みつき攻撃!(パリィ受付中)");
|
||||
}
|
||||
|
||||
public void ExitState() { }
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
stateTimer -= Time.deltaTime;
|
||||
if (stateTimer <= 0f)
|
||||
{
|
||||
// 攻撃が終わったら、フェーズ移行チェックを挟みつつ追跡に戻る
|
||||
if (boss.PendingUltimate) boss.ChangeState<SpiderJumpToCeilingState>();
|
||||
else boss.ChangeState<SpiderChaseState>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ■ STATE: CHARGE (走って体当たり突進 - パリィ可)
|
||||
// ==========================================
|
||||
public class SpiderChargeState : ISpiderState
|
||||
{
|
||||
private BossController boss;
|
||||
private float roarTimer;
|
||||
private float chargeTimer;
|
||||
private Vector3 chargeDirection;
|
||||
private bool isChargingPhase;
|
||||
|
||||
public SpiderChargeState(BossController owner) => boss = owner;
|
||||
|
||||
public void EnterState()
|
||||
{
|
||||
roarTimer = 1.5f;
|
||||
chargeTimer = boss.chargeDuration;
|
||||
isChargingPhase = false;
|
||||
|
||||
boss.Agent.enabled = false; // 移動をマニュアル制御するためNavMeshを切る
|
||||
|
||||
// 1. まず「威嚇の咆哮」アニメーションをトリガー
|
||||
boss.Anim.SetTrigger("Attack_Roar");
|
||||
Debug.Log("🔊 蜘蛛ボス:走る前に威嚇の咆哮中...(この間にプレイヤーはパリィの構えが可能)");
|
||||
}
|
||||
|
||||
public void ExitState()
|
||||
{
|
||||
boss.Anim.SetBool("IsCharging", false);
|
||||
boss.Agent.enabled = true;
|
||||
}
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
// フェーズ1:威嚇中(その場で動かない)
|
||||
if (!isChargingPhase)
|
||||
{
|
||||
roarTimer -= Time.deltaTime;
|
||||
|
||||
// 威嚇中もプレイヤーの方向をじっと見据える(ロックオン演出)
|
||||
if (boss.Player != null)
|
||||
{
|
||||
Vector3 lookDir = (boss.Player.position - boss.transform.position).normalized;
|
||||
lookDir.y = 0;
|
||||
if (lookDir != Vector3.zero) boss.transform.rotation = Quaternion.Slerp(boss.transform.rotation, Quaternion.LookRotation(lookDir), Time.deltaTime * 5f);
|
||||
}
|
||||
|
||||
if (roarTimer <= 0f)
|
||||
{
|
||||
// 威嚇終了、ここから本番の突進フェーズへ
|
||||
isChargingPhase = true;
|
||||
boss.Anim.SetTrigger("ChargeStart");
|
||||
boss.Anim.SetBool("IsCharging", true);
|
||||
|
||||
if (boss.Player != null)
|
||||
{
|
||||
chargeDirection = (boss.Player.position - boss.transform.position).normalized;
|
||||
chargeDirection.y = 0;
|
||||
boss.transform.rotation = Quaternion.LookRotation(chargeDirection);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// フェーズ2:突進中(直線移動を実行。ここからプレイヤーはパリィ可能)
|
||||
boss.transform.position += chargeDirection * boss.chargeSpeed * Time.deltaTime;
|
||||
|
||||
chargeTimer -= Time.deltaTime;
|
||||
if (chargeTimer <= 0f)
|
||||
{
|
||||
boss.ChangeState<SpiderChaseState>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ■ STATE: JUMP TO CEILING (天井への大ジャンプ)
|
||||
// ==========================================
|
||||
public class SpiderJumpToCeilingState : ISpiderState
|
||||
{
|
||||
private BossController boss;
|
||||
private float roarTimer;
|
||||
private float jumpProgress;
|
||||
private Vector3 startPos;
|
||||
private bool isJumpingPhase;
|
||||
|
||||
public SpiderJumpToCeilingState(BossController owner) => boss = owner;
|
||||
|
||||
public void EnterState()
|
||||
{
|
||||
roarTimer = 2.0f; // ★天井に飛ぶ前の大威嚇の時間 (2.0秒)
|
||||
jumpProgress = 0f;
|
||||
startPos = boss.transform.position;
|
||||
isJumpingPhase = false;
|
||||
|
||||
boss.Agent.enabled = false;
|
||||
|
||||
// 1. 必殺技移行を知らせる威嚇の咆哮
|
||||
boss.Anim.SetTrigger("Attack_Roar");
|
||||
Debug.Log("🚨 蜘蛛ボス:必殺技前の一大威嚇(咆哮)! このあと天井へ飛びます。");
|
||||
}
|
||||
|
||||
public void ExitState() { }
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
// フェーズ1:飛び立つ前の威嚇ポーズ(その場で足止め)
|
||||
if (!isJumpingPhase)
|
||||
{
|
||||
roarTimer -= Time.deltaTime;
|
||||
if (roarTimer <= 0f)
|
||||
{
|
||||
isJumpingPhase = true;
|
||||
boss.Anim.SetTrigger("JumpUp"); // ジャンプアニメーションへ
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// フェーズ2:本来の大ジャンプ空中移動
|
||||
if (boss.ceilingAnchor == null) return;
|
||||
|
||||
jumpProgress += Time.unscaledDeltaTime * 1.5f;
|
||||
|
||||
Vector3 currentPos = Vector3.Lerp(startPos, boss.ceilingAnchor.position, jumpProgress);
|
||||
currentPos.y += Mathf.Sin(jumpProgress * Mathf.PI) * 3f;
|
||||
|
||||
boss.transform.position = currentPos;
|
||||
|
||||
if (jumpProgress >= 1f)
|
||||
{
|
||||
boss.transform.position = boss.ceilingAnchor.position;
|
||||
boss.ChangeState<SpiderCeilingAttackState>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ■ STATE: CEILING ATTACK (必殺技:天井糸吐き)
|
||||
// ==========================================
|
||||
public class SpiderCeilingAttackState : ISpiderState
|
||||
{
|
||||
private BossController boss;
|
||||
private float stateDuration = 7.0f; // 必殺技全体の長さ(秒)
|
||||
private float shotInterval = 0.4f; // 糸を降らせる間隔
|
||||
private float timer = 0f;
|
||||
private float shotTimer = 0f;
|
||||
|
||||
public SpiderCeilingAttackState(BossController owner) => boss = owner;
|
||||
|
||||
public void EnterState()
|
||||
{
|
||||
timer = stateDuration;
|
||||
shotTimer = 0f;
|
||||
boss.Anim.SetBool("IsOnCeiling", true);
|
||||
boss.PendingUltimate = false; // 発動権を消化
|
||||
Debug.Log("🕸️ 蜘蛛ボス:天井から無数の糸を乱射中!");
|
||||
}
|
||||
|
||||
public void ExitState()
|
||||
{
|
||||
boss.Anim.SetBool("IsOnCeiling", false);
|
||||
// 地上の着地座標へ位置をリセットしてNavMeshを復帰
|
||||
if (boss.groundAnchor != null) boss.transform.position = boss.groundAnchor.position;
|
||||
boss.Agent.enabled = true;
|
||||
boss.Anim.SetTrigger("Land");
|
||||
}
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
shotTimer -= Time.deltaTime;
|
||||
|
||||
if (shotTimer <= 0f)
|
||||
{
|
||||
ExecuteRandomWebAttack();
|
||||
shotTimer = shotInterval;
|
||||
}
|
||||
|
||||
// 時間が来たら、地上へ復帰
|
||||
if (timer <= 0f)
|
||||
{
|
||||
boss.ChangeState<SpiderChaseState>();
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteRandomWebAttack()
|
||||
{
|
||||
// ボスの中央(地上座標)を基準に、ランダムな円内に糸を降らせる
|
||||
Vector2 randomCircle = Random.insideUnitCircle * boss.attackRadius;
|
||||
Vector3 targetGroundPos = new Vector3(
|
||||
boss.groundAnchor.position.x + randomCircle.x,
|
||||
boss.groundAnchor.position.y,
|
||||
boss.groundAnchor.position.z + randomCircle.y
|
||||
);
|
||||
|
||||
// 予兆を出し、1.0秒後に2.5秒間残る糸を生成する
|
||||
boss.SpawnWarningAndWeb(targetGroundPos, 1.0f, 2.5f);
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ■ STATE: STUN (チャンスタイム - パリィ成功時)
|
||||
// ==========================================
|
||||
public class SpiderStunState : ISpiderState
|
||||
{
|
||||
private BossController boss;
|
||||
private float stunTimer;
|
||||
|
||||
public SpiderStunState(BossController owner) => boss = owner;
|
||||
|
||||
public void EnterState()
|
||||
{
|
||||
stunTimer = 4.0f; // 4秒間の完全な無防備状態(チャンスタイム)
|
||||
boss.Anim.SetTrigger("StunStart");
|
||||
boss.Anim.SetBool("IsStunned", true);
|
||||
if (boss.Agent.enabled) boss.Agent.isStopped = true;
|
||||
Debug.Log("🛡️ パリィ成功! 蜘蛛ボスがひっくり返ってスタン中! チャンスタイム!");
|
||||
}
|
||||
|
||||
public void ExitState()
|
||||
{
|
||||
boss.Anim.SetBool("IsStunned", false);
|
||||
if (boss.Agent.enabled) boss.Agent.isStopped = false;
|
||||
}
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
stunTimer -= Time.deltaTime;
|
||||
if (stunTimer <= 0f)
|
||||
{
|
||||
// スンが明けたら、もしHPトリガーが裏で引かれていれば優先して天井へ
|
||||
if (boss.PendingUltimate) boss.ChangeState<SpiderJumpToCeilingState>();
|
||||
else boss.ChangeState<SpiderChaseState>();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/SpiderIdleState.cs.meta
Normal file
2
Assets/Scripts/SpiderIdleState.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67c8b05cbdd96694cbb2b2ef0a5efdd6
|
||||
@@ -42,7 +42,7 @@ public class VRInputPunch : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
Rigidbody rb = GetComponent<Rigidbody>();
|
||||
rb.isKinematic = true;
|
||||
rb.isKinematic = true;
|
||||
rb.useGravity = false;
|
||||
GetComponent<Collider>().isTrigger = true;
|
||||
}
|
||||
@@ -70,11 +70,17 @@ public class VRInputPunch : MonoBehaviour
|
||||
|
||||
// パリィ成功用の強力な振動をプレイヤーに返す
|
||||
TriggerHaptics(parryHapticAmplitude, parryHapticDuration);
|
||||
|
||||
|
||||
Debug.Log($"🛡️ 【ジャストパリィ成功!】 敵の体勢を崩しました。スタン時間: {parryStunDuration}秒");
|
||||
return; // パリィが成立した場合は以降のパンチ処理は行わない
|
||||
}
|
||||
}
|
||||
BossController boss = other.GetComponentInParent<BossController>();
|
||||
if (boss != null)
|
||||
{
|
||||
// ボスにパリィ成立を通知(噛みつき・突進中であれば自動でスタンへ移行)
|
||||
boss.TriggerParryStun();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("🧱 ガード(または速度不足):敵の攻撃は防いだが、弾き返せなかった。");
|
||||
@@ -100,27 +106,27 @@ public class VRInputPunch : MonoBehaviour
|
||||
info.amount = (speed * damageMultiplier) * 2f;
|
||||
info.isPoseBonus = true;
|
||||
|
||||
if(PlayerStatusManager.Instance != null) PlayerStatusManager.Instance.AddGauge(20f);
|
||||
if (PlayerStatusManager.Instance != null) PlayerStatusManager.Instance.AddGauge(20f);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.amount = speed * damageMultiplier;
|
||||
info.isPoseBonus = false;
|
||||
|
||||
if(PlayerStatusManager.Instance != null) PlayerStatusManager.Instance.AddGauge(10f);
|
||||
if (PlayerStatusManager.Instance != null) PlayerStatusManager.Instance.AddGauge(10f);
|
||||
}
|
||||
info.hitPosition = other.transform.position;
|
||||
info.punchDirection = velocity.normalized;
|
||||
info.punchDirection = velocity.normalized;
|
||||
|
||||
if(PlayerStatusManager.Instance != null)
|
||||
if (PlayerStatusManager.Instance != null)
|
||||
{
|
||||
info.amount *= PlayerStatusManager.Instance.CurrentAttackMultiplier;
|
||||
}
|
||||
|
||||
|
||||
damageble.TakeDamage(info);
|
||||
|
||||
|
||||
Debug.Log($"パンチ成功 ダメージ: {info.amount:F1}");
|
||||
|
||||
|
||||
// 通常ヒットの振動を発生
|
||||
TriggerHaptics(hapticAmplitude, hapticDuration);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user