codingmosaku
This commit is contained in:
@@ -1,108 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactors;
|
||||
|
||||
public class CodingModeManager : MonoBehaviour
|
||||
{
|
||||
[Header("ソケットスロットの設定")]
|
||||
[Tooltip("台座に配置した Slot_A の XRSocketInteractor を指定してください")]
|
||||
[SerializeField] private XRSocketInteractor socketA;
|
||||
[Tooltip("台座に配置した Slot_B の XRSocketInteractor を指定してください")]
|
||||
[SerializeField] private XRSocketInteractor socketB;
|
||||
|
||||
[Header("XR Interaction Toolkit 移動系コンポーネント")]
|
||||
[Tooltip("Continuous Move Provider などの移動スクリプトをアタッチ")]
|
||||
[SerializeField] private Behaviour moveProvider;
|
||||
|
||||
[Tooltip("Snap Turn Provider や Continuous Turn Provider などの旋回スクリプトをアタッチ")]
|
||||
[SerializeField] private Behaviour turnProvider;
|
||||
|
||||
public bool IsCodingModeActive { get; private set; } = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// ソケットにオブジェクトが「ハメ込まれた瞬間」のイベントを登録
|
||||
if (socketA != null) socketA.selectEntered.AddListener(OnSocketAEntered);
|
||||
if (socketB != null) socketB.selectEntered.AddListener(OnSocketBEntered);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// イベントの登録解除
|
||||
if (socketA != null) socketA.selectEntered.RemoveListener(OnSocketAEntered);
|
||||
if (socketB != null) socketB.selectEntered.RemoveListener(OnSocketBEntered);
|
||||
}
|
||||
|
||||
// Slot_A に何かがハメ込まれた時のコールバック
|
||||
private void OnSocketAEntered(SelectEnterEventArgs args)
|
||||
{
|
||||
CheckPuzzleCompletion();
|
||||
}
|
||||
|
||||
// Slot_B に何かがハメ込まれた時のコールバック
|
||||
private void OnSocketBEntered(SelectEnterEventArgs args)
|
||||
{
|
||||
CheckPuzzleCompletion();
|
||||
}
|
||||
|
||||
private void CheckPuzzleCompletion()
|
||||
{
|
||||
if (socketA == null || socketB == null) return;
|
||||
|
||||
// 両方のソケットがオブジェクトを保持(hasSelection)しているか確認
|
||||
if (socketA.hasSelection && socketB.hasSelection)
|
||||
{
|
||||
// ハメ込まれているオブジェクト(Interactable)を取得
|
||||
var objA = socketA.firstInteractableSelected;
|
||||
var objB = socketB.firstInteractableSelected;
|
||||
|
||||
if (objA != null && objB != null)
|
||||
{
|
||||
// オブジェクトの名前から、どのバフ四角形かを判別する文字列を抽出
|
||||
string buff1 = GetBuffNameFromObjectName(objA.transform.gameObject.name);
|
||||
string buff2 = GetBuffNameFromObjectName(objB.transform.gameObject.name);
|
||||
|
||||
Debug.Log($"💻 パズル連結完了! 検出されたコンボ: [{buff1}] + [{buff2}]");
|
||||
|
||||
ClearSockets();
|
||||
|
||||
// PlayerStatusManagerにバフを適用させ、時間停止を解除してプレイ画面に戻る
|
||||
if (PlayerStatusManager.Instance != null)
|
||||
{
|
||||
//PlayerStatusManager.Instance.ApplyBuffsAndResume(buff1, buff2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private string GetBuffNameFromObjectName(string objName)
|
||||
{
|
||||
if (objName.Contains("AttackUp")) return "AttackUp";
|
||||
if (objName.Contains("DefenseUp")) return "DefenseUp";
|
||||
if (objName.Contains("Heal")) return "Heal";
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
private void ClearSockets()
|
||||
{
|
||||
|
||||
if (socketA.firstInteractableSelected != null)
|
||||
{
|
||||
socketA.firstInteractableSelected.transform.position = transform.position + (transform.forward * -0.2f);
|
||||
}
|
||||
if (socketB.firstInteractableSelected != null)
|
||||
{
|
||||
socketB.firstInteractableSelected.transform.position = transform.position + (transform.forward * -0.2f) + (transform.right * 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleCodingMode()
|
||||
{
|
||||
IsCodingModeActive = !IsCodingModeActive;
|
||||
|
||||
// CodingModeが有効(true)なら、enabled を false にして足止めする
|
||||
if (moveProvider != null) moveProvider.enabled = !IsCodingModeActive;
|
||||
if (turnProvider != null) turnProvider.enabled = !IsCodingModeActive;
|
||||
|
||||
Debug.Log($"💻 CodingMode: {(IsCodingModeActive ? "ON (移動・旋回を一時ロック)" : "OFF (移動解禁)")}");
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 945a90d6fc5ecb048849ec7b83634441
|
||||
@@ -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)
|
||||
|
||||
@@ -1,105 +1,148 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactables; // XR Toolkit用
|
||||
|
||||
public enum BlockColor { Red, Blue, Green }
|
||||
public enum BlockShapeType { TShape, CShape }
|
||||
public enum BlockShapeType { TShape, CShape } // ト字, コ字
|
||||
|
||||
public class PuzzleBlock : MonoBehaviour
|
||||
{
|
||||
[field: SerializeField] public BlockColor Color { get; private set; }
|
||||
[field: SerializeField] public BlockShapeType ShapeType { get; private set; }
|
||||
|
||||
// 原点(0,0)を基準としたブロックのマス配置データ
|
||||
public List<Vector2Int> LocalCells { get; private set; } = new List<Vector2Int>();
|
||||
[Header("スナップ(合体)位置の設定")]
|
||||
[Tooltip("相手と合体する基準位置(空のGameObject)を指定。未設定でも中心位置でスナップします")]
|
||||
[SerializeField] private Transform snapPoint;
|
||||
|
||||
private PuzzleGridBoard currentBoard;
|
||||
private bool isGrabbed = false;
|
||||
private PuzzleBlock nearbyPartner; // 近くにある結合対象のブロック
|
||||
private bool isConnected = false; // 結合済みフラグ
|
||||
|
||||
// リセット用の初期座標・回転保持用
|
||||
private Vector3 initialPosition;
|
||||
private Quaternion initialRotation;
|
||||
private Rigidbody rb;
|
||||
private XRGrabInteractable grabInteractable;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitializeShapeCells();
|
||||
rb = GetComponent<Rigidbody>();
|
||||
grabInteractable = GetComponent<XRGrabInteractable>();
|
||||
|
||||
// 初期スポーン位置・回転を記憶しておく
|
||||
initialPosition = transform.position;
|
||||
initialRotation = transform.rotation;
|
||||
}
|
||||
|
||||
private void InitializeShapeCells()
|
||||
{
|
||||
LocalCells.Clear();
|
||||
|
||||
if (ShapeType == BlockShapeType.TShape)
|
||||
{
|
||||
LocalCells.Add(new Vector2Int(0, 0));
|
||||
LocalCells.Add(new Vector2Int(0, 1));
|
||||
LocalCells.Add(new Vector2Int(0, 2));
|
||||
LocalCells.Add(new Vector2Int(1, 1));
|
||||
}
|
||||
else if (ShapeType == BlockShapeType.CShape)
|
||||
{
|
||||
LocalCells.Add(new Vector2Int(0, 0));
|
||||
LocalCells.Add(new Vector2Int(1, 0));
|
||||
LocalCells.Add(new Vector2Int(0, 1));
|
||||
LocalCells.Add(new Vector2Int(0, 2));
|
||||
LocalCells.Add(new Vector2Int(1, 2));
|
||||
}
|
||||
}
|
||||
|
||||
public List<Vector2Int> GetRotatedCells()
|
||||
{
|
||||
List<Vector2Int> rotated = new List<Vector2Int>();
|
||||
// 現在のY回転を90度単位に丸める (0, 1, 2, 3)
|
||||
int steps = Mathf.RoundToInt(transform.eulerAngles.y / 180f) % 4;
|
||||
if (steps < 0) steps += 4;
|
||||
|
||||
foreach (var cell in LocalCells)
|
||||
{
|
||||
Vector2Int c = cell;
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
// 時計回りに90度回転: (x, y) -> (y, -x)
|
||||
c = new Vector2Int(c.y, -c.x);
|
||||
}
|
||||
rotated.Add(c);
|
||||
}
|
||||
return rotated;
|
||||
}
|
||||
|
||||
public void OnGrabbed()
|
||||
{
|
||||
isGrabbed = true;
|
||||
if (currentBoard != null)
|
||||
{
|
||||
currentBoard.RemoveBlock(this);
|
||||
currentBoard = null;
|
||||
}
|
||||
}
|
||||
|
||||
// PuzzleBlock.cs 内に以下を追加・修正
|
||||
private PuzzleGridBoard overlappingBoard;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
var board = other.GetComponentInParent<PuzzleGridBoard>();
|
||||
if (board != null) overlappingBoard = board;
|
||||
if (isConnected) return;
|
||||
|
||||
PuzzleBlock partner = other.GetComponentInParent<PuzzleBlock>();
|
||||
if (partner != null && IsValidPartner(partner))
|
||||
{
|
||||
nearbyPartner = partner;
|
||||
Debug.Log($"🧩 パートナー検知: {partner.Color} の {partner.ShapeType}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
var board = other.GetComponentInParent<PuzzleGridBoard>();
|
||||
if (board == overlappingBoard) overlappingBoard = null;
|
||||
}
|
||||
|
||||
// 引数なしで呼べるように変更
|
||||
public void OnReleased()
|
||||
{
|
||||
isGrabbed = false;
|
||||
|
||||
// 1. 手の傾きを最も近い90度単位にスナップ補正
|
||||
Vector3 currentEuler = transform.eulerAngles;
|
||||
float snappedY = Mathf.Round(currentEuler.y / 90f) * 90f;
|
||||
transform.rotation = Quaternion.Euler(0f, snappedY, 0f);
|
||||
|
||||
// 2. 近くにある盤面へのセットを試みる
|
||||
if (overlappingBoard != null && overlappingBoard.TryPlaceBlock(this))
|
||||
PuzzleBlock partner = other.GetComponentInParent<PuzzleBlock>();
|
||||
if (partner == nearbyPartner)
|
||||
{
|
||||
currentBoard = overlappingBoard;
|
||||
nearbyPartner = null;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsValidPartner(PuzzleBlock partner)
|
||||
{
|
||||
if (partner == null || partner.isConnected) return false;
|
||||
// 同一色 & 異なる形状(ト字 + コ字)のみ許可
|
||||
return partner.Color == this.Color && partner.ShapeType != this.ShapeType;
|
||||
}
|
||||
|
||||
public void OnReleased()
|
||||
{
|
||||
if (isConnected) return;
|
||||
|
||||
if (nearbyPartner != null)
|
||||
{
|
||||
ConnectToPartner(nearbyPartner);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectToPartner(PuzzleBlock partner)
|
||||
{
|
||||
isConnected = true;
|
||||
partner.isConnected = true;
|
||||
|
||||
// 1. 位置・回転のスナップ補正
|
||||
if (snapPoint != null && partner.snapPoint != null)
|
||||
{
|
||||
transform.position = partner.snapPoint.position;
|
||||
transform.rotation = partner.snapPoint.rotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = partner.transform.position;
|
||||
transform.rotation = partner.transform.rotation;
|
||||
}
|
||||
|
||||
// 2. 物理&VR掴み動作の完全ロック(完成後に崩れないようにする)
|
||||
LockBlockState();
|
||||
partner.LockBlockState();
|
||||
|
||||
Debug.Log($"🎉 マグネット合体成功! 色: {Color}");
|
||||
|
||||
// 3. バフ適用してCodingMode完了へ
|
||||
string buffName = ConvertColorToBuffName(Color);
|
||||
PlayerStatusManager.Instance.ApplyBuffsAndResume(buffName, buffName);
|
||||
}
|
||||
|
||||
private void LockBlockState()
|
||||
{
|
||||
if (rb != null)
|
||||
{
|
||||
rb.linearVelocity = Vector3.zero;
|
||||
rb.angularVelocity = Vector3.zero;
|
||||
rb.isKinematic = true;
|
||||
}
|
||||
// 掴みコンポーネントをオフにして手から切り離す
|
||||
if (grabInteractable != null) grabInteractable.enabled = false;
|
||||
}
|
||||
|
||||
public void ResetBlock()
|
||||
{
|
||||
isConnected = false;
|
||||
nearbyPartner = null;
|
||||
|
||||
transform.position = initialPosition;
|
||||
transform.rotation = initialRotation;
|
||||
|
||||
if (rb != null)
|
||||
{
|
||||
rb.isKinematic = false;
|
||||
rb.linearVelocity = Vector3.zero;
|
||||
rb.angularVelocity = Vector3.zero;
|
||||
}
|
||||
if (grabInteractable != null) grabInteractable.enabled = true;
|
||||
}
|
||||
|
||||
public static void ResetAllBlocksInScene()
|
||||
{
|
||||
foreach (var block in FindObjectsByType<PuzzleBlock>(FindObjectsSortMode.None))
|
||||
{
|
||||
if (block != null) block.ResetBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private string ConvertColorToBuffName(BlockColor color)
|
||||
{
|
||||
return color switch
|
||||
{
|
||||
BlockColor.Red => "AttackUp",
|
||||
BlockColor.Blue => "DefenseUp",
|
||||
BlockColor.Green => "Heal",
|
||||
_ => "AttackUp"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class PuzzleGridBoard : MonoBehaviour
|
||||
{
|
||||
[Header("盤面設定")]
|
||||
[SerializeField] private float cellSize = 0.1f; // 1マスのサイズ(メートル)
|
||||
[SerializeField] private Transform originAnchor; // 3x3の左下(0,0)の基準Transform
|
||||
|
||||
// 3x3 のマス目データ(設置されているブロックを管理)
|
||||
private PuzzleBlock[,] grid = new PuzzleBlock[3, 3];
|
||||
private List<PuzzleBlock> placedBlocks = new List<PuzzleBlock>();
|
||||
|
||||
public bool TryPlaceBlock(PuzzleBlock block)
|
||||
{
|
||||
// ブロックの原点位置から盤面のグリッド座標(0~2, 0~2)を算出
|
||||
Vector3 localPos = originAnchor.InverseTransformPoint(block.transform.position);
|
||||
int originX = Mathf.RoundToInt(localPos.x / cellSize);
|
||||
int originY = Mathf.RoundToInt(localPos.z / cellSize);
|
||||
|
||||
List<Vector2Int> shapeCells = block.GetRotatedCells();
|
||||
|
||||
// 設置可能かチェック(はみ出し・重ね被りがないか)
|
||||
foreach (var cell in shapeCells)
|
||||
{
|
||||
int targetX = originX + cell.x;
|
||||
int targetY = originY + cell.y;
|
||||
|
||||
if (targetX < 0 || targetX >= 3 || targetY < 0 || targetY >= 3) return false; // 盤面外
|
||||
if (grid[targetX, targetY] != null) return false; // すでに埋まっている
|
||||
}
|
||||
|
||||
// 設置確定処理
|
||||
foreach (var cell in shapeCells)
|
||||
{
|
||||
grid[originX + cell.x, originY + cell.y] = block;
|
||||
}
|
||||
placedBlocks.Add(block);
|
||||
|
||||
// 吸い付き(スナップ)位置の固定
|
||||
Vector3 snapLocalPos = new Vector3(originX * cellSize, 0f, originY * cellSize);
|
||||
block.transform.position = originAnchor.TransformPoint(snapLocalPos);
|
||||
|
||||
// 成功チェック(全9マスが単一色で埋まったか)
|
||||
EvaluateBoardComplete();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RemoveBlock(PuzzleBlock block)
|
||||
{
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
if (grid[x, y] == block) grid[x, y] = null;
|
||||
}
|
||||
}
|
||||
placedBlocks.Remove(block);
|
||||
}
|
||||
|
||||
private void EvaluateBoardComplete()
|
||||
{
|
||||
// 全9マスが埋まっているかチェック
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
if (grid[x, y] == null) return; // 空きマスがあるので未完成
|
||||
}
|
||||
}
|
||||
|
||||
// 全ブロックの色が統一されているかチェック
|
||||
BlockColor firstColor = placedBlocks[0].Color;
|
||||
foreach (var b in placedBlocks)
|
||||
{
|
||||
if (b.Color != firstColor)
|
||||
{
|
||||
Debug.Log("❌ 3x3は埋まりましたが、色が混ざっているため失敗です。");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ★パズル成功! 色に対応したバフを発動してCodingModeを終了する
|
||||
Debug.Log($"🎉 パズル成功! 単一色 ({firstColor}) で完成しました!");
|
||||
string buffName = ConvertColorToBuffName(firstColor);
|
||||
|
||||
PlayerStatusManager.Instance.ApplyBuffsAndResume(buffName, buffName);
|
||||
}
|
||||
|
||||
private string ConvertColorToBuffName(BlockColor color)
|
||||
{
|
||||
return color switch
|
||||
{
|
||||
BlockColor.Red => "AttackUp",
|
||||
BlockColor.Blue => "DefenseUp",
|
||||
BlockColor.Green => "Heal",
|
||||
_ => "AttackUp"
|
||||
};
|
||||
}
|
||||
|
||||
public void ClearBoard()
|
||||
{
|
||||
grid = new PuzzleBlock[3, 3];
|
||||
placedBlocks.Clear();
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c49da017d0074aa4b9f4c23133fbb5d
|
||||
Reference in New Issue
Block a user