Camera Shake, Panning speed decreased, Hit Effect, Stamina UI
parent
7883131a7d
commit
ed53396e04
@ -0,0 +1,366 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &108676305740267431
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 9177040301879258186}
|
||||
- component: {fileID: 4873889555389619246}
|
||||
- component: {fileID: 7147008565852266751}
|
||||
m_Layer: 0
|
||||
m_Name: HitSprite
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &9177040301879258186
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 108676305740267431}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 227.2355, y: 122.83, z: 122.83}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 516877461761749120}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!212 &4873889555389619246
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 108676305740267431}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 21300000, guid: 839adabbc5de26041bac66450214a831, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 0.04, y: 0.04}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!114 &7147008565852266751
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 108676305740267431}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ee158225ee1e59f4791627785501d950, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
shaderTypes: 0
|
||||
normalStrength: 5
|
||||
normalSmoothing: 1
|
||||
computingNormal: 0
|
||||
--- !u!1 &1532039423350917361
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1621535022542027897}
|
||||
- component: {fileID: 222258470646128693}
|
||||
- component: {fileID: 6337608741754376225}
|
||||
m_Layer: 0
|
||||
m_Name: Animated
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!4 &1621535022542027897
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1532039423350917361}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -4.447157, z: 0}
|
||||
m_LocalScale: {x: 1.2457023, y: 1.2457023, z: 1.2457023}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 516877461761749120}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &222258470646128693
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1532039423350917361}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: a4e6a5491519adb45919dc87eff28e55, type: 3}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!102 &6337608741754376225
|
||||
TextMesh:
|
||||
serializedVersion: 3
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1532039423350917361}
|
||||
m_Text: (Has Animation)
|
||||
m_OffsetZ: -1.5
|
||||
m_CharacterSize: 0.075
|
||||
m_LineSpacing: 1
|
||||
m_Anchor: 4
|
||||
m_Alignment: 0
|
||||
m_TabSize: 4
|
||||
m_FontSize: 100
|
||||
m_FontStyle: 0
|
||||
m_RichText: 1
|
||||
m_Font: {fileID: 12800000, guid: a4e6a5491519adb45919dc87eff28e55, type: 3}
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
--- !u!1 &5329390946827052200
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8631732782121668261}
|
||||
- component: {fileID: 7313882439284011823}
|
||||
- component: {fileID: 6127487664652077170}
|
||||
m_Layer: 0
|
||||
m_Name: Title
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8631732782121668261
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5329390946827052200}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: -3.1267126, z: 0}
|
||||
m_LocalScale: {x: 1.2457023, y: 1.2457023, z: 1.2457023}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 516877461761749120}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &7313882439284011823
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5329390946827052200}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: a4e6a5491519adb45919dc87eff28e55, type: 3}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!102 &6127487664652077170
|
||||
TextMesh:
|
||||
serializedVersion: 3
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5329390946827052200}
|
||||
m_Text: Screen Hit
|
||||
m_OffsetZ: -1.5
|
||||
m_CharacterSize: 0.075
|
||||
m_LineSpacing: 1
|
||||
m_Anchor: 4
|
||||
m_Alignment: 0
|
||||
m_TabSize: 4
|
||||
m_FontSize: 100
|
||||
m_FontStyle: 0
|
||||
m_RichText: 1
|
||||
m_Font: {fileID: 12800000, guid: a4e6a5491519adb45919dc87eff28e55, type: 3}
|
||||
m_Color:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
--- !u!1 &8024604998774400320
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 516877461761749120}
|
||||
- component: {fileID: 1950512066271761892}
|
||||
- component: {fileID: 4431182916468833469}
|
||||
m_Layer: 0
|
||||
m_Name: ScreenHit
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &516877461761749120
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8024604998774400320}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 200, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.80276, y: 0.80276, z: 0.80276}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 9177040301879258186}
|
||||
- {fileID: 8631732782121668261}
|
||||
- {fileID: 1621535022542027897}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1950512066271761892
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8024604998774400320}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 98b644315d7a92842b89e04f55c48e02, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!95 &4431182916468833469
|
||||
Animator:
|
||||
serializedVersion: 5
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8024604998774400320}
|
||||
m_Enabled: 1
|
||||
m_Avatar: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000, guid: 1220612ba20667d46a6e8356073b69b0, type: 2}
|
||||
m_CullingMode: 0
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_LinearVelocityBlending: 0
|
||||
m_StabilizeFeet: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e74146e0c4e4b7f4bbbe0782e5773fd1
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,40 +0,0 @@
|
||||
using UnityEngine;
|
||||
using Cinemachine;
|
||||
|
||||
public class EdgePanningController: MonoBehaviour
|
||||
{
|
||||
public CinemachineFreeLook virtualCamera;
|
||||
private CinemachineCameraOffset cameraOffset;
|
||||
|
||||
public float edgeThreshold = 50f; // Edge detection distance
|
||||
public float panSpeed = 0.1f; // How much to offset per frame
|
||||
|
||||
private Vector3 defaultOffset;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cameraOffset = virtualCamera.GetComponent<CinemachineCameraOffset>();
|
||||
defaultOffset = cameraOffset.m_Offset; // Store default offset
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 newOffset = defaultOffset;
|
||||
Vector3 mousePos = Input.mousePosition;
|
||||
|
||||
float screenWidth = Screen.width;
|
||||
float screenHeight = Screen.height;
|
||||
|
||||
// Left Edge
|
||||
if (mousePos.x <= edgeThreshold) newOffset.x -= panSpeed;
|
||||
// Right Edge
|
||||
if (mousePos.x >= screenWidth - edgeThreshold) newOffset.x += panSpeed;
|
||||
// Bottom Edge
|
||||
if (mousePos.y <= edgeThreshold) newOffset.y -= panSpeed;
|
||||
// Top Edge
|
||||
if (mousePos.y >= screenHeight - edgeThreshold) newOffset.y += panSpeed;
|
||||
|
||||
// Smooth transition
|
||||
cameraOffset.m_Offset = Vector3.Lerp(cameraOffset.m_Offset, newOffset, Time.deltaTime * 5f);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Cinemachine;
|
||||
public class CinemachineShake : MonoBehaviour
|
||||
{
|
||||
public static CinemachineShake Instance { get; private set; }
|
||||
private CinemachineFreeLook freeLookCamera;
|
||||
private Coroutine shakeCoroutine;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
freeLookCamera = GetComponent<CinemachineFreeLook>();
|
||||
|
||||
if (freeLookCamera == null)
|
||||
{
|
||||
Debug.LogError("[FreeLookCameraShake] No Cinemachine FreeLook Camera found!");
|
||||
}
|
||||
}
|
||||
|
||||
public void Shake(float duration = 0.3f, float magnitude = 0.2f)
|
||||
{
|
||||
if (shakeCoroutine != null)
|
||||
{
|
||||
StopCoroutine(shakeCoroutine);
|
||||
}
|
||||
shakeCoroutine = StartCoroutine(ShakeRoutine(duration, magnitude));
|
||||
}
|
||||
|
||||
private IEnumerator ShakeRoutine(float duration, float magnitude)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
float originalX = freeLookCamera.m_XAxis.Value;
|
||||
float originalY = freeLookCamera.m_YAxis.Value;
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
freeLookCamera.m_XAxis.Value = originalX + Random.Range(-magnitude, magnitude);
|
||||
freeLookCamera.m_YAxis.Value = originalY + Random.Range(-magnitude, magnitude);
|
||||
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
freeLookCamera.m_XAxis.Value = originalX; // Reset horizontal shake
|
||||
freeLookCamera.m_YAxis.Value = originalY; // Reset vertical shake
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a090d81c65001304d94c78781406d1c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,123 @@
|
||||
using UnityEngine;
|
||||
using Cinemachine;
|
||||
using System.Collections;
|
||||
|
||||
public class EdgePanningController : MonoBehaviour
|
||||
{
|
||||
public CinemachineFreeLook virtualCamera;
|
||||
private CinemachineCameraOffset cameraOffset;
|
||||
|
||||
public float edgeThreshold = 50f; // Edge detection distance
|
||||
public float panSpeed = 0.1f; // How much to offset per frame
|
||||
|
||||
private Vector3 defaultOffset;
|
||||
private Coroutine shakeCoroutine;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cameraOffset = virtualCamera.GetComponent<CinemachineCameraOffset>();
|
||||
if (cameraOffset == null)
|
||||
{
|
||||
Debug.LogError("[EdgePanningController] No CinemachineCameraOffset component found! Add it to the FreeLook Camera.");
|
||||
return;
|
||||
}
|
||||
|
||||
defaultOffset = cameraOffset.m_Offset; // Store default offset
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
HandleEdgePanning();
|
||||
}
|
||||
|
||||
private void HandleEdgePanning()
|
||||
{
|
||||
Vector3 newOffset = defaultOffset;
|
||||
Vector3 mousePos = Input.mousePosition;
|
||||
|
||||
float screenWidth = Screen.width;
|
||||
float screenHeight = Screen.height;
|
||||
|
||||
// Left Edge
|
||||
if (mousePos.x <= edgeThreshold) newOffset.x -= panSpeed;
|
||||
// Right Edge
|
||||
if (mousePos.x >= screenWidth - edgeThreshold) newOffset.x += panSpeed;
|
||||
// Bottom Edge
|
||||
if (mousePos.y <= edgeThreshold) newOffset.y -= panSpeed;
|
||||
// Top Edge
|
||||
if (mousePos.y >= screenHeight - edgeThreshold) newOffset.y += panSpeed;
|
||||
|
||||
// Smooth transition
|
||||
cameraOffset.m_Offset = Vector3.Lerp(cameraOffset.m_Offset, newOffset, Time.deltaTime * 3f);
|
||||
}
|
||||
|
||||
public void ShakeCamera(float duration = 0.3f, float magnitude = 0.2f)
|
||||
{
|
||||
if (shakeCoroutine != null)
|
||||
{
|
||||
StopCoroutine(shakeCoroutine);
|
||||
}
|
||||
shakeCoroutine = StartCoroutine(ShakeRoutine(duration, magnitude));
|
||||
}
|
||||
|
||||
private IEnumerator ShakeRoutine(float duration, float magnitude)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
Vector3 originalOffset = defaultOffset;
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
float x = Random.Range(-1f, 1f) * magnitude;
|
||||
float y = Random.Range(-1f, 1f) * magnitude;
|
||||
float z = Random.Range(-1f, 1f) * magnitude;
|
||||
|
||||
cameraOffset.m_Offset = originalOffset + new Vector3(x, y, z);
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
cameraOffset.m_Offset = originalOffset; // Reset to default offset
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//using UnityEngine;
|
||||
//using Cinemachine;
|
||||
|
||||
//public class EdgePanningController: MonoBehaviour
|
||||
//{
|
||||
// public CinemachineFreeLook virtualCamera;
|
||||
// private CinemachineCameraOffset cameraOffset;
|
||||
|
||||
// public float edgeThreshold = 50f; // Edge detection distance
|
||||
// public float panSpeed = 0.1f; // How much to offset per frame
|
||||
|
||||
// private Vector3 defaultOffset;
|
||||
|
||||
// private void Start()
|
||||
// {
|
||||
// cameraOffset = virtualCamera.GetComponent<CinemachineCameraOffset>();
|
||||
// defaultOffset = cameraOffset.m_Offset; // Store default offset
|
||||
// }
|
||||
|
||||
// private void Update()
|
||||
// {
|
||||
// Vector3 newOffset = defaultOffset;
|
||||
// Vector3 mousePos = Input.mousePosition;
|
||||
|
||||
// float screenWidth = Screen.width;
|
||||
// float screenHeight = Screen.height;
|
||||
|
||||
// // Left Edge
|
||||
// if (mousePos.x <= edgeThreshold) newOffset.x -= panSpeed;
|
||||
// // Right Edge
|
||||
// if (mousePos.x >= screenWidth - edgeThreshold) newOffset.x += panSpeed;
|
||||
// // Bottom Edge
|
||||
// if (mousePos.y <= edgeThreshold) newOffset.y -= panSpeed;
|
||||
// // Top Edge
|
||||
// if (mousePos.y >= screenHeight - edgeThreshold) newOffset.y += panSpeed;
|
||||
|
||||
// // Smooth transition
|
||||
// cameraOffset.m_Offset = Vector3.Lerp(cameraOffset.m_Offset, newOffset, Time.deltaTime * 3f);
|
||||
// }
|
||||
//}
|
@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
public class ScreenHit : MonoBehaviour
|
||||
{
|
||||
public static ScreenHit Instance { get; private set; } // Singleton instance
|
||||
|
||||
private Image hitImage;
|
||||
private Coroutine fadeCoroutine;
|
||||
public float fadeDuration = 0.3f; // Time to fade in and out
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
hitImage = GetComponent<Image>();
|
||||
|
||||
if (hitImage == null)
|
||||
{
|
||||
Debug.LogError("[ScreenHit] No Image component found! Make sure it's attached to a UI Image.");
|
||||
}
|
||||
|
||||
// Start fully transparent
|
||||
Color color = hitImage.color;
|
||||
color.a = 0;
|
||||
hitImage.color = color;
|
||||
}
|
||||
|
||||
public void ShowHitEffect()
|
||||
{
|
||||
if (fadeCoroutine != null)
|
||||
{
|
||||
StopCoroutine(fadeCoroutine);
|
||||
}
|
||||
fadeCoroutine = StartCoroutine(FadeEffect());
|
||||
}
|
||||
|
||||
private IEnumerator FadeEffect()
|
||||
{
|
||||
float halfDuration = fadeDuration / 2f;
|
||||
Color color = hitImage.color;
|
||||
|
||||
// Fade in
|
||||
float elapsed = 0f;
|
||||
while (elapsed < halfDuration)
|
||||
{
|
||||
color.a = Mathf.Lerp(0, 1, elapsed / halfDuration);
|
||||
hitImage.color = color;
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Fade out
|
||||
elapsed = 0f;
|
||||
while (elapsed < halfDuration)
|
||||
{
|
||||
color.a = Mathf.Lerp(1, 0, elapsed / halfDuration);
|
||||
hitImage.color = color;
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
color.a = 0; // Fully transparent
|
||||
hitImage.color = color;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c90604c00a8a6a468ca644094c69dd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Unity.Netcode;
|
||||
|
||||
public class StaminaUI : MonoBehaviour
|
||||
{
|
||||
private StaminaManager localStaminaManager;
|
||||
private Image staminaBar;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
staminaBar = GetComponent<Image>();
|
||||
|
||||
if (staminaBar == null)
|
||||
{
|
||||
Debug.LogError("[StaminaUI] No Image component found on this GameObject!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait for the player to be assigned
|
||||
InvokeRepeating(nameof(FindLocalPlayerStaminaManager), 0f, 1f);
|
||||
}
|
||||
|
||||
private void FindLocalPlayerStaminaManager()
|
||||
{
|
||||
foreach (var player in FindObjectsOfType<StaminaManager>())
|
||||
{
|
||||
if (player.TryGetComponent<NetworkObject>(out var networkObject) && networkObject.IsOwner)
|
||||
{
|
||||
localStaminaManager = player;
|
||||
CancelInvoke(nameof(FindLocalPlayerStaminaManager)); // Stop checking once found
|
||||
Debug.Log("[StaminaUI] Found local player's StaminaManager.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (localStaminaManager != null && staminaBar != null)
|
||||
{
|
||||
staminaBar.fillAmount = localStaminaManager.CurrentStamina / localStaminaManager.MaxStamina;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0ee75241fb7875418243e23770f9480
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue