Codingモード研究中

This commit is contained in:
ohgushiyuga
2026-06-09 12:37:09 +09:00
parent d900c0aa47
commit 14ebaa11be
13 changed files with 1733 additions and 83 deletions

8
Assets/Material.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 733b151e3155ff047bc44a0f3f64f909
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Material 1
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0, g: 0, b: 1, a: 1}
- _Color: {r: 0, g: 0, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!114 &2344268579193699850
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
version: 10

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1ec014f54cfb2c74aa3a4f66e8169883
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7141186158001946892
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
version: 10
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Material 2
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0, g: 1, b: 0, a: 1}
- _Color: {r: 0, g: 1, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 412e67d7c363e1546ad63eafb782fbc8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-3456904790123304626
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
version: 10
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Material
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 0, b: 0, a: 1}
- _Color: {r: 1, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8f047b861e188db4492aa9d5ef2c408e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,115 +1,195 @@
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using System.Collections;
/// <summary>
/// プレイヤーの共通ゲージ、時間停止Codingモード、UI、および各種バフの制限時間を管理するクラス
/// </summary>
public class PlayerStatusManager : MonoBehaviour public class PlayerStatusManager : MonoBehaviour
{ {
public static PlayerStatusManager Instance { get; private set;} public static PlayerStatusManager Instance { get; private set; }
[Header("Codingモード用 入力設定")]
[SerializeField] private InputActionProperty zlButtonAction; [SerializeField] private InputActionProperty zlButtonAction;
[SerializeField] private InputActionProperty zrButtonAction; [SerializeField] private InputActionProperty zrButtonAction;
[Header("ゲージ設定")]
[SerializeField] private float maxGauge = 100f; [SerializeField] private float maxGauge = 100f;
[SerializeField] private float currentGauge = 0f; [SerializeField] private float currentGauge = 0f;
[Header("表示UI設定")]
[Tooltip("画面全体を追従させる親オブジェクトWorld Space Canvasや3D台座を指定してください")]
[SerializeField] private GameObject codingModeUI; [SerializeField] private GameObject codingModeUI;
private bool isCodingMode = false; // ─── ★ここからバフ設定を新しく追加 ───
[Header("バフパラメータ設定")]
[Tooltip("攻撃力UP・防御力UPの持続時間 (秒)")]
[SerializeField] private float buffDuration = 10f;
[Tooltip("攻撃力UP時のダメージ倍率 (例: 1.5倍)")]
[SerializeField] private float attackBuffMultiplier = 1.5f;
[Tooltip("防御力UP時の被ダメージ軽減率 (例: 0.5ならダメージ50%カット)")]
[SerializeField] private float defenseBuffMultiplier = 0.5f;
[Tooltip("HP回復バフ発動時の回復量")]
[SerializeField] private float hpHealAmount = 30f;
void Awake() // 各バフの残り時間を管理するタイマー0より大きければバフ有効
private float attackBuffTimer = 0f;
private float defenseBuffTimer = 0f;
// 現在Codingモード時間停止中かどうかのフラグ
private bool isCodingMode = false;
// ─────────────────────────────────────
#region
/// <summary> 現在攻撃力UPバフが有効かどうか </summary>
public bool IsAttackBuffActive => attackBuffTimer > 0f;
/// <summary> 現在防御力UPバフが有効かどうか </summary>
public bool IsDefenseBuffActive => defenseBuffTimer > 0f;
/// <summary> 現在の攻撃力倍率を返すバフなしなら1.0倍) </summary>
public float CurrentAttackMultiplier => IsAttackBuffActive ? attackBuffMultiplier : 1.0f;
/// <summary> 現在の防御倍率を返すバフなしなら1.0倍、バフありなら0.5倍など) </summary>
public float CurrentDefenseMultiplier => IsDefenseBuffActive ? defenseBuffMultiplier : 1.0f;
#endregion
private void Awake()
{ {
if(Instance == null) if (Instance == null) { Instance = this; }
{ else { Destroy(gameObject); }
Instance = this;
}
else
{
Destroy(gameObject);
}
} }
private void OnEnable() private void OnEnable()
{ {
if(zlButtonAction.action != null) zlButtonAction.action.Enable(); if (zlButtonAction.action != null) zlButtonAction.action.Enable();
if(zrButtonAction.action != null) zrButtonAction.action.Enable(); if (zrButtonAction.action != null) zrButtonAction.action.Enable();
} }
private void OnDisable() private void OnDisable()
{ {
if(zlButtonAction.action != null) zlButtonAction.action.Disable(); if (zlButtonAction.action != null) zlButtonAction.action.Disable();
if(zrButtonAction.action != null) zrButtonAction.action.Disable(); if (zrButtonAction.action != null) zrButtonAction.action.Disable();
} }
// Start is called once before the first execution of Update after the MonoBehaviour is created private void Start()
void Start()
{ {
if(codingModeUI != null) if (codingModeUI != null) codingModeUI.SetActive(false);
{
codingModeUI.SetActive(false);
}
} }
// Update is called once per frame private void Update()
void Update()
{ {
CheckComboInput(); CheckComboInput();
// ★新設:ゲームプレイ中(時間停止中でないとき)のみ、バフのタイマーを減算する
if (!isCodingMode)
{
UpdateBuffTimers();
}
} }
public void AddGauge(float amout) public void AddGauge(float amount)
{ {
if(isCodingMode) return; if (isCodingMode) return;
currentGauge += amount;
currentGauge += amout;
currentGauge = Mathf.Clamp(currentGauge, 0f, maxGauge); currentGauge = Mathf.Clamp(currentGauge, 0f, maxGauge);
Debug.Log($"🔋 共通ゲージ増加: {currentGauge} / {maxGauge}");
} }
private void CheckComboInput() private void CheckComboInput()
{ {
if(zlButtonAction.action == null || zrButtonAction.action ==null) return; if (zlButtonAction.action == null || zrButtonAction.action == null) return;
bool zlPressed = zlButtonAction.action.triggered && zlButtonAction.action.ReadValue<float>() > 0.5f; bool zlPressed = zlButtonAction.action.triggered && zlButtonAction.action.ReadValue<float>() > 0.5f;
bool zrPressed = zlButtonAction.action.triggered && zrButtonAction.action.ReadValue<float>() > 0.5f; bool zrPressed = zrButtonAction.action.triggered && zrButtonAction.action.ReadValue<float>() > 0.5f;
if(!isCodingMode && currentGauge >= maxGauge) if (!isCodingMode && currentGauge >= maxGauge)
{ {
if((zlPressed && zrButtonAction.action.ReadValue<float>() > 0.5f) || if ((zlPressed && zrButtonAction.action.ReadValue<float>() > 0.5f) ||
(zrPressed && zlButtonAction.action.ReadValue<float>() > 0.5f)) (zrPressed && zlButtonAction.action.ReadValue<float>() > 0.5f))
{ {
StartCodingMode(); StartCodingMode();
} }
} }
else if(isCodingMode)
{
if((zlPressed && zrButtonAction.action.ReadValue<float>() > 0.5f) ||
(zrPressed && zlButtonAction.action.ReadValue<float>() > 0.5f))
{
EndCodingMode();
}
}
} }
private void StartCodingMode() private void StartCodingMode()
{ {
isCodingMode = true; isCodingMode = true;
Time.timeScale = 0f; // 時間を完全停止
Time.timeScale = 0f; if (codingModeUI != null) codingModeUI.SetActive(true);
if(codingModeUI != null)
{
codingModeUI.SetActive(true);
}
} }
private void EndCodingMode() /// <summary>
/// ★役割拡張パズル完了時に呼び出され、指定された2つのバフを発動して時間を再開する
/// </summary>
public void ApplyBuffsAndResume(string buff1, string buff2)
{ {
// 1. 選択された2つのバフをそれぞれ発動重複なしの仕様を適用
ActivateBuffByName(buff1);
ActivateBuffByName(buff2);
// 2. Codingモードの終了処理
isCodingMode = false; isCodingMode = false;
Time.timeScale = 1f; // 時間を再開
Time.timeScale = 1f; if (codingModeUI != null) codingModeUI.SetActive(false);
currentGauge = 0f; // ゲージを消費
if(codingModeUI != null)
{
codingModeUI.SetActive(false);
} }
currentGauge = 0f; /// <summary>
/// 文字列に応じて対象のバフを起動する内部メソッド
/// </summary>
private void ActivateBuffByName(string buffName)
{
switch (buffName)
{
case "AttackUp":
attackBuffTimer = buffDuration; // タイマーをリセット(上書き補給)
Debug.Log($"⚔️ 攻撃力UPバフ発動 倍率: {attackBuffMultiplier} / 効果時間: {buffDuration}秒");
break;
case "DefenseUp":
defenseBuffTimer = buffDuration; // タイマーをリセット(上書き補給)
Debug.Log($"🛡️ 防御力UPバフ発動 被ダメージ倍率: {defenseBuffMultiplier} / 効果時間: {buffDuration}秒");
break;
case "Heal":
ExecuteHeal(); // HP回復は即時発動
break;
default:
Debug.LogWarning($"未定義のバフ名が検出されました: {buffName}");
break;
}
}
/// <summary>
/// HP回復の即時実行処理
/// </summary>
private void ExecuteHeal()
{
Debug.Log($"💚 HP回復バフ発動 回復量: {hpHealAmount}");
// 【将来の拡張】プレイヤーのHealthスクリプトが完成したら、ここに回復処理を記述します
// PlayerHealth.Instance.Heal(hpHealAmount);
}
/// <summary>
/// 毎フレーム、有効なバフタイマーをリアルタイムで減算する
/// </summary>
private void UpdateBuffTimers()
{
if (attackBuffTimer > 0f)
{
attackBuffTimer -= Time.deltaTime;
if (attackBuffTimer <= 0f) Debug.Log("⚔️ 攻撃力UPバフの効果が終了しました。");
}
if (defenseBuffTimer > 0f)
{
defenseBuffTimer -= Time.deltaTime;
if (defenseBuffTimer <= 0f) Debug.Log("🛡️ 防御力UPバフの効果が終了しました。");
}
} }
} }

View File

@@ -17,14 +17,10 @@ public class VRInputPunch : MonoBehaviour
[SerializeField] private float hapticDuration = 0.1f; // 通常ヒットの振動の長さ [SerializeField] private float hapticDuration = 0.1f; // 通常ヒットの振動の長さ
[Header("パリィ設定")] [Header("パリィ設定")]
[Tooltip("パリィを成立させるために必要な最低限の手の速度 (m/s) ※構え中は速度に関係なく成功します")] [SerializeField] private float minParrySpeed = 1.0f; // パリィできるパンチとして判定する最低速度 (m/s)
[SerializeField] private float minParrySpeed = 1.0f; [SerializeField] private float parryStunDuration = 3.0f; // スタン時間(秒)
[Tooltip("パリィ成功時に敵がスタン(行動不能)になる時間 (秒)")] [SerializeField] private float parryHapticAmplitude = 0.9f; // パリィ成功時の振動の強さ
[SerializeField] private float parryStunDuration = 3.0f; [SerializeField] private float parryHapticDuration = 0.25f; // パリィ成功時の振動の長さ
[Tooltip("パリィ成功時の強力な振動の強さ (0.0 1.0)")]
[SerializeField] private float parryHapticAmplitude = 0.9f;
[Tooltip("パリィ成功時の強力な振動の長さ (秒)")]
[SerializeField] private float parryHapticDuration = 0.25f;
// ───────────────────────────────────────── // ─────────────────────────────────────────
private void OnEnable() private void OnEnable()
@@ -57,7 +53,7 @@ public class VRInputPunch : MonoBehaviour
Vector3 velocity = velocityAction.action.ReadValue<Vector3>(); Vector3 velocity = velocityAction.action.ReadValue<Vector3>();
float speed = velocity.magnitude; float speed = velocity.magnitude;
// ─── ★新設:【パリィ判定】当たったオブジェクトが敵の拳だった場合 ─── //【パリィ判定】当たったオブジェクトが敵の拳だった場合
if (other.CompareTag("EnemyFist")) if (other.CompareTag("EnemyFist"))
{ {
Debug.Log($"🛡️ [パリィチェック] 敵の拳と接触。プレイヤーの手の速度: {speed:F2} m/s / 構え状態: {poseDetector.IsPosing}"); Debug.Log($"🛡️ [パリィチェック] 敵の拳と接触。プレイヤーの手の速度: {speed:F2} m/s / 構え状態: {poseDetector.IsPosing}");
@@ -72,7 +68,7 @@ public class VRInputPunch : MonoBehaviour
// 敵の攻撃コンボを強制中断し、スタン状態にする // 敵の攻撃コンボを強制中断し、スタン状態にする
enemyAI.TriggerParryStun(parryStunDuration); enemyAI.TriggerParryStun(parryStunDuration);
// パリィ成功用の強力な振動(手応え)をプレイヤーに返す // パリィ成功用の強力な振動をプレイヤーに返す
TriggerHaptics(parryHapticAmplitude, parryHapticDuration); TriggerHaptics(parryHapticAmplitude, parryHapticDuration);
Debug.Log($"🛡️ 【ジャストパリィ成功!】 敵の体勢を崩しました。スタン時間: {parryStunDuration}秒"); Debug.Log($"🛡️ 【ジャストパリィ成功!】 敵の体勢を崩しました。スタン時間: {parryStunDuration}秒");
@@ -88,7 +84,7 @@ public class VRInputPunch : MonoBehaviour
// ──────────────────────────────────────────────────────────────────────── // ────────────────────────────────────────────────────────────────────────
// ─── 以下は従来の【パンチ攻撃の処理(変更なし・ログのバグ修正のみ) ─── // パンチ攻撃の処理
Debug.Log($"[InputSystem接触] {other.name} に触れました。センサー速度: {speed:F2} m/s"); Debug.Log($"[InputSystem接触] {other.name} に触れました。センサー速度: {speed:F2} m/s");
if (speed >= minPunchSpeed) if (speed >= minPunchSpeed)
@@ -98,6 +94,7 @@ public class VRInputPunch : MonoBehaviour
if (damageble != null) if (damageble != null)
{ {
DamageInfo info = new DamageInfo(); DamageInfo info = new DamageInfo();
// 構えからパンチするとダメージ2倍、ゲージ取得度2倍
if (poseDetector.IsPosing) if (poseDetector.IsPosing)
{ {
info.amount = (speed * damageMultiplier) * 2f; info.amount = (speed * damageMultiplier) * 2f;
@@ -115,9 +112,13 @@ public class VRInputPunch : MonoBehaviour
info.hitPosition = other.transform.position; info.hitPosition = other.transform.position;
info.punchDirection = velocity.normalized; info.punchDirection = velocity.normalized;
if(PlayerStatusManager.Instance != null)
{
info.amount *= PlayerStatusManager.Instance.CurrentAttackMultiplier;
}
damageble.TakeDamage(info); damageble.TakeDamage(info);
// ※元のコードのログ出力の記述バグ($の付け忘れ)を修正しました
Debug.Log($"パンチ成功 ダメージ: {info.amount:F1}"); Debug.Log($"パンチ成功 ダメージ: {info.amount:F1}");
// 通常ヒットの振動を発生 // 通常ヒットの振動を発生
@@ -126,14 +127,11 @@ public class VRInputPunch : MonoBehaviour
} }
else else
{ {
// ※元のコードのログ出力の記述バグ($の付け忘れ)を修正しました
Debug.Log($"スピードが足りません。必要: {minPunchSpeed} / 現在: {speed:F2}"); Debug.Log($"スピードが足りません。必要: {minPunchSpeed} / 現在: {speed:F2}");
} }
} }
/// <summary>
/// 引数に応じて指定された強さと長さでコントローラーを振動させる /// 引数に応じて指定された強さと長さでコントローラーを振動させる
/// </summary>
private void TriggerHaptics(float amplitude, float duration) private void TriggerHaptics(float amplitude, float duration)
{ {
UnityEngine.XR.InputDevice device = InputDevices.GetDeviceAtXRNode(controllerNode); UnityEngine.XR.InputDevice device = InputDevices.GetDeviceAtXRNode(controllerNode);

View File

@@ -0,0 +1,79 @@
using UnityEngine;
// World Space Canvas をプレイヤーの真正面に移動させ、開いている間はプレイヤーの視点に滑らかに追従させるスクリプト
public class VRUIDoorFaceFollow : MonoBehaviour
{
[SerializeField] private Transform vrCameraTransform;
[Header("配置・追従のパラメータ")]
[SerializeField] private float forwardDistance = 0.5f;
[SerializeField] private float heightOffset = -0.1f;
[SerializeField] private float followSpeed = 5.0f;
// 画面がアクティブ(表示)になった瞬間を検知するためのフラグ
private bool wasActiveLastFrame = false;
private void Start()
{
// カメラが未設定の場合は、シーン内からメインカメラを自動取得
if (vrCameraTransform == null && Camera.main != null)
{
vrCameraTransform = Camera.main.transform;
}
}
// 全体の時間が止まっているTime.timeScale = 0間でも動作させるため、カメラ移動の後に実行される LateUpdate を使用します
private void LateUpdate()
{
if (vrCameraTransform == null) return;
// このオブジェクトUI画面が有効化された「最初のフレーム」の処理
if (!wasActiveLastFrame)
{
// 開いた瞬間は、プレイヤーの今の向きの「完全な正面」に瞬間移動させる(遅れてついてくるのを防ぐため)
SetInitialPosition();
wasActiveLastFrame = true;
return;
}
// 毎フレームの滑らかな追従処理
SmoothFollowPlayer();
}
private void OnDisable()
{
// 画面が閉じられたらフラグをリセットする
wasActiveLastFrame = false;
}
/// 画面が開いた瞬間に、プレイヤーの正面の正しい位置・向きに強制配置する
private void SetInitialPosition()
{
// カメラの位置から、カメラが向いている正面方向に一定距離進んだ座標を計算
Vector3 targetPosition = vrCameraTransform.position + (vrCameraTransform.forward * forwardDistance);
targetPosition.y += heightOffset; // 高さを微調整
transform.position = targetPosition;
// 画面の向きをプレイヤー(カメラ)の方向に向ける(背を向けないようにする)
// UIパネルがプレイヤー側を正面にするよう、LookAtの後に180度回転させて裏返りを防ぎます
transform.LookAt(vrCameraTransform.position);
transform.Rotate(0, 180, 0);
}
/// プレイヤーが首を動かしたり移動したりした際、画面を滑らかについてこさせる
private void SmoothFollowPlayer()
{
// 目的地(目標座標)の計算
Vector3 targetPosition = vrCameraTransform.position + (vrCameraTransform.forward * forwardDistance);
targetPosition.y += heightOffset;
// Time.timeScale = 0 でも動かすため、Time.unscaledDeltaTime を使用
// 現在位置から目標位置まで滑らかに補間移動Lerpさせる
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.unscaledDeltaTime * followSpeed);
// 向きも滑らかに補間Slerpしてプレイヤーの方を向かせ続ける
Quaternion targetRotation = Quaternion.LookRotation(transform.position - vrCameraTransform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.unscaledDeltaTime * followSpeed);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 97e7b0ef50eb0934e84c6f6f7c3ed536

View File

@@ -1179,8 +1179,8 @@ MonoBehaviour:
features: features:
- {fileID: 7011443450567333355} - {fileID: 7011443450567333355}
- {fileID: -671281728444007487} - {fileID: -671281728444007487}
- {fileID: -901939997048047619} - {fileID: 6956056911768161135}
- {fileID: -1734471456787174204} - {fileID: -6387251413244805544}
- {fileID: 8980318060753866109} - {fileID: 8980318060753866109}
- {fileID: -6559185765804338520} - {fileID: -6559185765804338520}
- {fileID: -4756202077021157709} - {fileID: -4756202077021157709}
@@ -1191,7 +1191,7 @@ MonoBehaviour:
- {fileID: 348827886137839178} - {fileID: 348827886137839178}
- {fileID: -7499073031166464939} - {fileID: -7499073031166464939}
- {fileID: 7666556398442971420} - {fileID: 7666556398442971420}
- {fileID: -7343570946846779558} - {fileID: -142859899272520151}
- {fileID: 3985858319333531581} - {fileID: 3985858319333531581}
- {fileID: -6511185071715886993} - {fileID: -6511185071715886993}
- {fileID: -4363231183632145407} - {fileID: -4363231183632145407}