codingmosaku
This commit is contained in:
@@ -3,15 +3,11 @@ using UnityEngine.InputSystem;
|
||||
using UnityEngine.AI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// プレイヤーの共通ゲージ、時間停止(Codingモード)、UI、および各種バフの制限時間を管理するクラス
|
||||
/// </summary>
|
||||
public class PlayerStatusManager : MonoBehaviour
|
||||
{
|
||||
public static PlayerStatusManager Instance { get; private set; }
|
||||
|
||||
[Header("デバッグ設定")]
|
||||
[Tooltip("チェックを入れると、ゲージが溜まっていなくてもZLZRでCodingModeを開けます(テスト用)")]
|
||||
[SerializeField] private bool ignoreGaugeForDebug = true;
|
||||
|
||||
[Header("Codingモード用 入力設定")]
|
||||
@@ -19,13 +15,10 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
[SerializeField] private InputActionProperty zrButtonAction;
|
||||
|
||||
[Header("プレイヤー移動・操作制御用 入力設定")]
|
||||
[Tooltip("プレイヤーの移動入力(例: LeftHand Move)のアクションを指定してください")]
|
||||
[SerializeField] private InputActionProperty moveAction;
|
||||
[Tooltip("プレイヤーの視点回転入力(例: RightHand Turn)があれば指定してください(任意)")]
|
||||
[SerializeField] private InputActionProperty turnAction;
|
||||
|
||||
[Header("パズル制限時間設定")]
|
||||
[Tooltip("CodingModeパズルの制限時間(秒)")]
|
||||
[SerializeField] private float codingLimitDuration = 15f;
|
||||
private float codingTimer = 0f;
|
||||
|
||||
@@ -35,12 +28,15 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
|
||||
[Header("表示UI設定")]
|
||||
[SerializeField] private GameObject codingModeUI;
|
||||
[SerializeField] private PuzzleGridBoard puzzleBoard; // 盤面参照
|
||||
|
||||
[Header("バフパラメータ設定")]
|
||||
[Tooltip("攻撃力UP・防御力UPの持続時間 (秒)")]
|
||||
[SerializeField] private float buffDuration = 10f;
|
||||
[Tooltip("攻撃力UP時のダメージ倍率")]
|
||||
[SerializeField] private float attackBuffMultiplier = 1.5f;
|
||||
[Tooltip("防御力UP時の被ダメージ軽減率")]
|
||||
[SerializeField] private float defenseBuffMultiplier = 0.5f;
|
||||
[Tooltip("HP回復バフ発動時の回復量")]
|
||||
[SerializeField] private float hpHealAmount = 30f;
|
||||
|
||||
private float attackBuffTimer = 0f;
|
||||
@@ -124,14 +120,9 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
{
|
||||
if (zlButtonAction.action == null || zrButtonAction.action == null) return;
|
||||
|
||||
// 入力値の読み取り
|
||||
float zlVal = zlButtonAction.action.ReadValue<float>();
|
||||
float zrVal = zrButtonAction.action.ReadValue<float>();
|
||||
|
||||
bool zlPressed = zlButtonAction.action.triggered || zlVal > 0.5f;
|
||||
bool zrPressed = zrButtonAction.action.triggered || zrVal > 0.5f;
|
||||
|
||||
// 両方のトリガーが引かれているか
|
||||
bool isBothHeld = zlVal > 0.5f && zrVal > 0.5f;
|
||||
bool isAnyTriggered = zlButtonAction.action.triggered || zrButtonAction.action.triggered;
|
||||
|
||||
@@ -139,19 +130,17 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
{
|
||||
if (!isCodingMode)
|
||||
{
|
||||
// ゲージチェック(デバッグフラグがONならゲージ無視で起動)
|
||||
if (ignoreGaugeForDebug || currentGauge >= maxGauge)
|
||||
{
|
||||
StartCodingMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"⚠️ ゲージが足りないためCodingModeを開けません。現在: {currentGauge} / 必要: {maxGauge}");
|
||||
Debug.LogWarning($"⚠️ ゲージ不足のためCodingModeを開始できません。現在: {currentGauge} / 必要: {maxGauge}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// CodingMode中に再度同時押し ➔ キャンセルして無消費で復帰
|
||||
CancelCodingMode();
|
||||
}
|
||||
}
|
||||
@@ -162,11 +151,14 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
isCodingMode = true;
|
||||
codingTimer = codingLimitDuration;
|
||||
|
||||
if (puzzleBoard != null) puzzleBoard.ClearBoard();
|
||||
// 1. プレイヤーの移動制御をロック
|
||||
DisableAction(moveAction);
|
||||
DisableAction(turnAction);
|
||||
|
||||
// 敵のアニメーション・NavMesh停止
|
||||
// 2. パズルブロックの状態・位置を全リセット
|
||||
PuzzleBlock.ResetAllBlocksInScene();
|
||||
|
||||
// 3. 敵のアニメーション・NavMeshを停止
|
||||
foreach (var anim in FindObjectsByType<Animator>(FindObjectsSortMode.None))
|
||||
{
|
||||
if (anim == null || anim.gameObject == this.gameObject || anim.CompareTag("Player")) continue;
|
||||
@@ -181,7 +173,7 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
}
|
||||
|
||||
if (codingModeUI != null) codingModeUI.SetActive(true);
|
||||
Debug.Log($"⏳ Codingモード開始(パズル制限時間: {codingLimitDuration}秒)");
|
||||
Debug.Log($"⏳ Codingモード開始(制限時間: {codingLimitDuration}秒)");
|
||||
}
|
||||
|
||||
public void ApplyBuffsAndResume(string buff1, string buff2)
|
||||
@@ -189,19 +181,19 @@ public class PlayerStatusManager : MonoBehaviour
|
||||
ActivateBuffByName(buff1);
|
||||
ActivateBuffByName(buff2);
|
||||
ResumeWorldState(consumeGauge: true);
|
||||
Debug.Log("🎉 パズル成功!バフを適用して再開。");
|
||||
Debug.Log("🎉 パズル成功!バフを適用してゲームを再開しました。");
|
||||
}
|
||||
|
||||
private void FailCodingModeByTimeout()
|
||||
{
|
||||
ResumeWorldState(consumeGauge: true);
|
||||
Debug.Log("💀 時間切れ! Codingモード失敗(バフなし・ゲージ消費)。");
|
||||
Debug.Log("💀 制限時間切れ! Codingモード失敗(バフなし・ゲージ消費)。");
|
||||
}
|
||||
|
||||
public void CancelCodingMode()
|
||||
{
|
||||
ResumeWorldState(consumeGauge: false);
|
||||
Debug.Log("↩️ Codingモード手動キャンセル。");
|
||||
Debug.Log("↩️ Codingモードを手動キャンセルしました。");
|
||||
}
|
||||
|
||||
private void ResumeWorldState(bool consumeGauge)
|
||||
|
||||
Reference in New Issue
Block a user