This commit is contained in:
ohgushiyuga
2026-07-22 16:20:19 +09:00
parent 8506e8d155
commit 2f47302b9e
6 changed files with 395 additions and 1331 deletions

View File

@@ -3,24 +3,41 @@ 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モード用 入力設定")]
[SerializeField] private InputActionProperty zlButtonAction;
[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;
[Header("ゲージ設定")]
[SerializeField] private float maxGauge = 100f;
[SerializeField] private float currentGauge = 0f;
[Header("表示UI設定")]
[SerializeField] private GameObject codingModeUI;
[SerializeField] private PuzzleGridBoard puzzleBoard; // 盤面参照
[Header("バフパラメータ設定")]
[SerializeField] private float buffDuration = 10f;
[SerializeField] private float attackBuffMultiplier = 1.5f;
[SerializeField] private float defenseBuffMultiplier = 0.5f;
@@ -46,6 +63,37 @@ public class PlayerStatusManager : MonoBehaviour
else { Destroy(gameObject); }
}
private void OnEnable()
{
EnableAction(zlButtonAction);
EnableAction(zrButtonAction);
EnableAction(moveAction);
EnableAction(turnAction);
}
private void OnDisable()
{
DisableAction(zlButtonAction);
DisableAction(zrButtonAction);
DisableAction(moveAction);
DisableAction(turnAction);
}
private void EnableAction(InputActionProperty property)
{
if (property.action != null) property.action.Enable();
}
private void DisableAction(InputActionProperty property)
{
if (property.action != null) property.action.Disable();
}
private void Start()
{
if (codingModeUI != null) codingModeUI.SetActive(false);
}
private void Update()
{
CheckComboInput();
@@ -56,6 +104,7 @@ public class PlayerStatusManager : MonoBehaviour
}
else
{
// CodingMode中の制限時間カウントダウン
codingTimer -= Time.deltaTime;
if (codingTimer <= 0f)
{
@@ -75,21 +124,35 @@ public class PlayerStatusManager : MonoBehaviour
{
if (zlButtonAction.action == null || zrButtonAction.action == null) return;
bool zlPressed = zlButtonAction.action.triggered && zlButtonAction.action.ReadValue<float>() > 0.5f;
bool zrPressed = zrButtonAction.action.triggered && zrButtonAction.action.ReadValue<float>() > 0.5f;
// 入力値の読み取り
float zlVal = zlButtonAction.action.ReadValue<float>();
float zrVal = zrButtonAction.action.ReadValue<float>();
bool isComboTriggered = (zlPressed && zrButtonAction.action.ReadValue<float>() > 0.5f) ||
(zrPressed && zlButtonAction.action.ReadValue<float>() > 0.5f);
bool zlPressed = zlButtonAction.action.triggered || zlVal > 0.5f;
bool zrPressed = zrButtonAction.action.triggered || zrVal > 0.5f;
if (isComboTriggered)
// 両方のトリガーが引かれているか
bool isBothHeld = zlVal > 0.5f && zrVal > 0.5f;
bool isAnyTriggered = zlButtonAction.action.triggered || zrButtonAction.action.triggered;
if (isBothHeld && isAnyTriggered)
{
if (!isCodingMode && currentGauge >= maxGauge)
if (!isCodingMode)
{
StartCodingMode();
// ゲージチェックデバッグフラグがONならゲージ無視で起動
if (ignoreGaugeForDebug || currentGauge >= maxGauge)
{
StartCodingMode();
}
else
{
Debug.LogWarning($"⚠️ ゲージが足りないためCodingModeを開けません。現在: {currentGauge} / 必要: {maxGauge}");
}
}
else if (isCodingMode)
else
{
CancelCodingMode(); // 手動キャンセルはゲージ維持
// CodingMode中に再度同時押し ➔ キャンセルして無消費で復帰
CancelCodingMode();
}
}
}
@@ -97,12 +160,13 @@ public class PlayerStatusManager : MonoBehaviour
private void StartCodingMode()
{
isCodingMode = true;
codingTimer = codingLimitDuration; // タイマーリセット
codingTimer = codingLimitDuration;
if (puzzleBoard != null) puzzleBoard.ClearBoard();
if (moveAction.action != null) moveAction.action.Disable();
if (turnAction.action != null) turnAction.action.Disable();
DisableAction(moveAction);
DisableAction(turnAction);
// 敵のアニメーション・NavMesh停止
foreach (var anim in FindObjectsByType<Animator>(FindObjectsSortMode.None))
{
if (anim == null || anim.gameObject == this.gameObject || anim.CompareTag("Player")) continue;
@@ -130,13 +194,13 @@ public class PlayerStatusManager : MonoBehaviour
private void FailCodingModeByTimeout()
{
ResumeWorldState(consumeGauge: true); // 失敗したのでゲージは消費される
ResumeWorldState(consumeGauge: true);
Debug.Log("💀 時間切れ! Codingモード失敗バフなし・ゲージ消費。");
}
public void CancelCodingMode()
{
ResumeWorldState(consumeGauge: false); // 手動キャンセルはゲージ消費なし
ResumeWorldState(consumeGauge: false);
Debug.Log("↩️ Codingモード手動キャンセル。");
}
@@ -148,8 +212,8 @@ public class PlayerStatusManager : MonoBehaviour
foreach (var agent in pausedAgents) { if (agent != null && agent.enabled) agent.isStopped = false; }
pausedAgents.Clear();
if (moveAction.action != null) moveAction.action.Enable();
if (turnAction.action != null) turnAction.action.Enable();
EnableAction(moveAction);
EnableAction(turnAction);
isCodingMode = false;
if (codingModeUI != null) codingModeUI.SetActive(false);

View File

@@ -45,7 +45,7 @@ public class PuzzleBlock : MonoBehaviour
{
List<Vector2Int> rotated = new List<Vector2Int>();
// 現在のY回転を90度単位に丸める (0, 1, 2, 3)
int steps = Mathf.RoundToInt(transform.eulerAngles.y / 90f) % 4;
int steps = Mathf.RoundToInt(transform.eulerAngles.y / 180f) % 4;
if (steps < 0) steps += 4;
foreach (var cell in LocalCells)