Camera Shake, Panning speed decreased, Hit Effect, Stamina UI

dev-main-mobile
Ali Sharoz 3 days ago
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);
}
}

@ -65,7 +65,7 @@ Material:
- _MainTex:
m_Texture: {fileID: 2800000, guid: 71f14d5f7422f9346af23185b106a77b, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: -0.8490444, y: -0.8490444}
m_Offset: {x: 0, y: 0}
- _MainTexture:
m_Texture: {fileID: 2800000, guid: 71f14d5f7422f9346af23185b106a77b, type: 3}
m_Scale: {x: 1, y: 1}

@ -5182,7 +5182,7 @@ SphereCollider:
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Radius: 0.8
m_Radius: 0.5
m_Center: {x: 0.006566055, y: 0.029529523, z: 0.005648941}
--- !u!1 &7383387755399559723
GameObject:

File diff suppressed because it is too large Load Diff

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

@ -2,7 +2,6 @@ using System.Collections;
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using UnityEngine;
using Unity.Netcode;
using Unity.Netcode.Components;
[CreateAssetMenu(menuName = "Abilities/DashNCrash")]
public class DashNCrashAbility : Ability
@ -11,35 +10,51 @@ public class DashNCrashAbility : Ability
public float dashSpeed = 10f;
public float dashDuration = 0.5f;
public override void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation)
{
Debug.Log($"Executing DashNCrash for character {character.OwnerClientId} at {targetPosition}.");
// Start the dash
// Start the dash movement
character.Movement.StartDash(targetPosition, dashSpeed, dashDuration);
// Ensure the crowModel exists and has a NetworkAnimator0
if (character.crowModel != null)
// Ensure the crowModel exists and has an Animator
if (character.crowModel != null && character.crowModel.TryGetComponent<Animator>(out var animator))
{
NetworkAnimator networkAnimator = character.crowModel.GetComponentInChildren<NetworkAnimator>();
if (networkAnimator != null)
{
Debug.Log("Triggering Dive animation for crow model.");
networkAnimator.Animator.SetTrigger("Dive");
}
else
{
Debug.LogError("NetworkAnimator component missing on crow model!");
}
Debug.Log("Triggering Dive animation for crow model.");
TriggerDiveAnimationClientRpc(character.NetworkObjectId);
}
else
{
Debug.LogError("Crow model is not assigned!");
Debug.LogError("Crow model is not assigned or is missing an Animator component!");
}
// Delay spawning the slow zone until after the dash
character.StartCoroutine(SpawnSlowZoneAfterDash(character, targetPosition));
}
/// <summary>
/// ClientRpc to trigger the Dive animation on all clients.
/// </summary>
[ClientRpc]
private void TriggerDiveAnimationClientRpc(ulong objectId)
{
if (!NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(objectId, out var netObj))
{
Debug.LogError($"[Client] NetworkObject with ID {objectId} not found in SpawnedObjects.");
return;
}
if (netObj.TryGetComponent<Animator>(out var animator))
{
animator.SetTrigger("Dive");
Debug.Log($"[Client] Dive animation triggered for {netObj.name}");
}
else
{
Debug.LogError($"[Client] Animator not found on {netObj.name}.");
}
}
private IEnumerator SpawnSlowZoneAfterDash(ServerCharacter character, Vector3 position)
{
yield return new WaitForSeconds(dashDuration + 0.25f);
@ -63,3 +78,70 @@ public class DashNCrashAbility : Ability
}
}
}
//using System.Collections;
//using Unity.BossRoom.Gameplay.GameplayObjects.Character;
//using UnityEngine;
//using Unity.Netcode;
//using Unity.Netcode.Components;
//[CreateAssetMenu(menuName = "Abilities/DashNCrash")]
//public class DashNCrashAbility : Ability
//{
// [Header("Dash Settings")]
// public float dashSpeed = 10f;
// public float dashDuration = 0.5f;
// public override void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation)
// {
// Debug.Log($"Executing DashNCrash for character {character.OwnerClientId} at {targetPosition}.");
// // Start the dash
// character.Movement.StartDash(targetPosition, dashSpeed, dashDuration);
// // Ensure the crowModel exists and has a NetworkAnimator0
// if (character.crowModel != null)
// {
// NetworkAnimator networkAnimator = character.crowModel.GetComponent<NetworkAnimator>();
// if (networkAnimator != null)
// {
// Debug.Log("Triggering Dive animation for crow model.");
// networkAnimator.SetTrigger("Dive");
// }
// else
// {
// Debug.LogError("NetworkAnimator component missing on crow model!");
// }
// }
// else
// {
// Debug.LogError("Crow model is not assigned!");
// }
// // Delay spawning the slow zone until after the dash
// character.StartCoroutine(SpawnSlowZoneAfterDash(character, targetPosition));
// }
// private IEnumerator SpawnSlowZoneAfterDash(ServerCharacter character, Vector3 position)
// {
// yield return new WaitForSeconds(dashDuration + 0.25f);
// // Spawn the slow zone prefab at the dash's end position
// var prefab = GetPrefab();
// if (prefab != null)
// {
// GameObject instance = Instantiate(prefab, character.transform.position, Quaternion.identity);
// var networkObject = instance.GetComponent<NetworkObject>();
// if (networkObject != null)
// {
// networkObject.Spawn();
// Debug.Log($"Slow Zone spawned at {position}.");
// }
// else
// {
// Debug.LogError("Slow Zone prefab must have a NetworkObject component.");
// }
// }
// }
//}

@ -75,7 +75,7 @@ public class ExecutionerBox : NetworkBehaviour
if (other.TryGetComponent<ServerCharacter>(out var victim))
{
ulong ownerId = _owner.OwnerClientId;
victim.CameraShaker();
// Handle score changes
ScoreManager.Instance.AddPlayerScore(ownerId, 10,Color.yellow); // Add to owner
ScoreManager.Instance.SubtractPlayerScore(victim.OwnerClientId, 10,new Color(1,0.647f,0,1)); // Subtract from victim

@ -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:

@ -1,3 +1,4 @@
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using Unity.BossRoom.ConnectionManagement;
@ -355,11 +356,15 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
{
StartCoroutine(FreezeCoroutine(duration));
}
public void CameraShaker()
{
TriggerCameraShakeClientRpc(OwnerClientId);
}
private IEnumerator FreezeCoroutine(float duration)
{
Debug.Log($"{name} is frozen for {duration} seconds!");
Movement.SetSpeedModifier(0f); // Disable movement
CameraShaker();
IceEffectStarterClientRpc();
yield return new WaitForSeconds(duration);
IceEffectStopperClientRpc();
@ -424,7 +429,7 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
{
Vector3 senderPos = senderChar.transform.position;
Vector3 receiverPos = transform.position;
OnSwapRequested(senderId,OwnerClientId,senderPos,receiverPos);
OnSwapRequested(senderId, OwnerClientId, senderPos, receiverPos);
CrowManager.Instance.NotifyForesightSwap(senderChar.OwnerClientId, OwnerClientId, senderPos, receiverPos);
}
}
@ -713,9 +718,66 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
/// </summary>
/// <param name="inflicter">Person dishing out this damage/healing. Can be null. </param>
/// <param name="HP">The HP to receive. Positive value is healing. Negative is damage. </param>
// void ReceiveHP(ServerCharacter inflicter, int HP)
// {
// Debug.Log("ReceiveHP");
// //to our own effects, and modify the damage or healing as appropriate. But in this game, we just take it straight.
// if (HP > 0)
// {
// m_ServerActionPlayer.OnGameplayActivity(Action.GameplayActivity.Healed);
// float healingMod = m_ServerActionPlayer.GetBuffedValue(Action.BuffableValue.PercentHealingReceived);
// HP = (int)(HP * healingMod);
// }
// else
// {
//#if UNITY_EDITOR || DEVELOPMENT_BUILD
// // Don't apply damage if god mode is on
// if (NetLifeState.IsGodMode.Value)
// {
// return;
// }
//#endif
// m_ServerActionPlayer.OnGameplayActivity(Action.GameplayActivity.AttackedByEnemy);
// float damageMod = m_ServerActionPlayer.GetBuffedValue(Action.BuffableValue.PercentDamageReceived);
// HP = (int)(HP * damageMod);
// serverAnimationHandler.NetworkAnimator.SetTrigger("HitReact1");
// }
// HitPoints = Mathf.Clamp(HitPoints + HP, 0, CharacterClass.BaseHP.Value);
// if (m_AIBrain != null)
// {
// //let the brain know about the modified amount of damage we received.
// m_AIBrain.ReceiveHP(inflicter, HP);
// }
// //we can't currently heal a dead character back to Alive state.
// //that's handled by a separate function.
// if (HitPoints <= 0)
// {
// if (IsNpc)
// {
// if (m_KilledDestroyDelaySeconds >= 0.0f && LifeState != LifeState.Dead)
// {
// StartCoroutine(KilledDestroyProcess());
// }
// LifeState = LifeState.Dead;
// }
// else
// {
// LifeState = LifeState.Fainted;
// }
// m_ServerActionPlayer.ClearActions(false);
// }
// }
void ReceiveHP(ServerCharacter inflicter, int HP)
{
//to our own effects, and modify the damage or healing as appropriate. But in this game, we just take it straight.
Debug.Log("ReceiveHP");
if (HP > 0)
{
m_ServerActionPlayer.OnGameplayActivity(Action.GameplayActivity.Healed);
@ -725,11 +787,7 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
else
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
// Don't apply damage if god mode is on
if (NetLifeState.IsGodMode.Value)
{
return;
}
if (NetLifeState.IsGodMode.Value) return; // Ignore damage in God Mode
#endif
m_ServerActionPlayer.OnGameplayActivity(Action.GameplayActivity.AttackedByEnemy);
@ -737,18 +795,20 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
HP = (int)(HP * damageMod);
serverAnimationHandler.NetworkAnimator.SetTrigger("HitReact1");
// ** Trigger Camera Shake on the client that got hit **
CameraShaker();
//TriggerCameraShakeClientRpc(OwnerClientId);
}
HitPoints = Mathf.Clamp(HitPoints + HP, 0, CharacterClass.BaseHP.Value);
if (m_AIBrain != null)
{
//let the brain know about the modified amount of damage we received.
m_AIBrain.ReceiveHP(inflicter, HP);
}
//we can't currently heal a dead character back to Alive state.
//that's handled by a separate function.
if (HitPoints <= 0)
{
if (IsNpc)
@ -757,17 +817,41 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
{
StartCoroutine(KilledDestroyProcess());
}
LifeState = LifeState.Dead;
}
else
{
LifeState = LifeState.Fainted;
}
m_ServerActionPlayer.ClearActions(false);
}
}
EdgePanningController m_edgePanningController;
[ClientRpc]
private void TriggerCameraShakeClientRpc(ulong clientId)
{
if (NetworkManager.Singleton.LocalClientId == clientId)
{
ScreenHit.Instance?.ShowHitEffect();
if(m_edgePanningController==null)
{
m_edgePanningController=FindObjectOfType<EdgePanningController>();
}
else
{
m_edgePanningController.ShakeCamera(0.5f, 0.3f);
}
}
}
//[ClientRpc]
//private void TriggerCameraShakeClientRpc(ulong clientId)
//{
// if (NetworkManager.Singleton.LocalClientId == clientId)
// {
// CinemachineShake.Instance?.Shake(0.5f, 0.3f);
// }
//}
/// <summary>
/// Determines a gameplay variable for this character. The value is determined

@ -29,7 +29,9 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects
public bool IsDamageable()
{
return m_NetworkLifeState.LifeState.Value == LifeState.Alive;
//AliSharoz
//return m_NetworkLifeState.LifeState.Value == LifeState.Alive;
return true;
}
void OnCollisionEnter(Collision other)

@ -22,7 +22,8 @@
"VContainer",
"Unity.BossRoom.VisualEffects",
"Unity.BossRoom.CameraUtils",
"Unity.Multiplayer.Tools.NetworkSimulator.Runtime"
"Unity.Multiplayer.Tools.NetworkSimulator.Runtime",
"Cinemachine"
],
"includePlatforms": [],
"excludePlatforms": [],
@ -33,4 +34,4 @@
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
}

@ -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:

@ -874,7 +874,7 @@ PlayerSettings:
PS5: UNITY_POST_PROCESSING_STACK_V2;DOTWEEN
QNX: UNITY_POST_PROCESSING_STACK_V2;DOTWEEN
Stadia: UNITY_POST_PROCESSING_STACK_V2;DOTWEEN
Standalone: UNITY_POST_PROCESSING_STACK_V2;ENABLE_RELAY_SERVICE;DOTWEEN
Standalone: UNITY_POST_PROCESSING_STACK_V2;ENABLE_RELAY_SERVICE;DOTWEEN;CINEMACHINE_INSTALLED
VisionOS: UNITY_POST_PROCESSING_STACK_V2;DOTWEEN
WebGL: UNITY_POST_PROCESSING_STACK_V2;DOTWEEN
Windows Store Apps: UNITY_POST_PROCESSING_STACK_V2;DOTWEEN

Loading…
Cancel
Save