Added Freeze Throw Ability

dev-hazim
Hazim Bin Ijaz 3 weeks ago
parent 94c5a3845b
commit 698b189e05

@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 8c1371d9d978b1e4dbf2d6385a724a55, type: 3}
m_Name: FreezeThrow
m_EditorClassIdentifier:
abilityKey: FreezeThrow
abilityName: Freeze Throw
abilityRadius: 3
abilityMagnitude: 3
abilityDuration: 3
abilityCooldownTime: 3
prefab: {fileID: 6216300034370971352, guid: f9c332b27cf965044b8d1499bfcd9059, type: 3}
projectileSpeed: 10

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6c697d5efda1b0147b0c3f4088ee62f9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

@ -74,3 +74,8 @@ MonoBehaviour:
SourcePrefabToOverride: {fileID: 0} SourcePrefabToOverride: {fileID: 0}
SourceHashToOverride: 0 SourceHashToOverride: 0
OverridingTargetPrefab: {fileID: 0} OverridingTargetPrefab: {fileID: 0}
- Override: 0
Prefab: {fileID: 6216300034370971352, guid: f9c332b27cf965044b8d1499bfcd9059, type: 3}
SourcePrefabToOverride: {fileID: 0}
SourceHashToOverride: 0
OverridingTargetPrefab: {fileID: 0}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f9c332b27cf965044b8d1499bfcd9059
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -193,7 +193,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3} - target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: GlobalObjectIdHash propertyPath: GlobalObjectIdHash
value: 3177087589 value: 3737985212
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3} - target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: PrefabHashGenerator propertyPath: PrefabHashGenerator
@ -762,6 +762,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
abilities: abilities:
- {fileID: 11400000, guid: e4794e2f71f66a74486c797344695ce7, type: 2} - {fileID: 11400000, guid: e4794e2f71f66a74486c797344695ce7, type: 2}
- {fileID: 11400000, guid: 6c697d5efda1b0147b0c3f4088ee62f9, type: 2}
currentAbilityIndicator: {fileID: 92142163933926358} currentAbilityIndicator: {fileID: 92142163933926358}
--- !u!114 &4321537148236331373 --- !u!114 &4321537148236331373
MonoBehaviour: MonoBehaviour:

@ -0,0 +1,51 @@
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using Unity.Netcode;
using UnityEngine;
[CreateAssetMenu(menuName = "Abilities/FreezeThrow")]
public class FreezeThrowAbility : Ability
{
[Header("FreezeThrow Settings")]
public float projectileSpeed = 10f;
public override void Execute(ServerCharacter character, Vector3 targetPosition)
{
if (!NetworkManager.Singleton.IsServer)
{
Debug.LogError("[FreezeThrowAbility] Execute should only be called on the server.");
return;
}
if (character == null)
{
Debug.LogError("[FreezeThrowAbility] ServerCharacter is null.");
return;
}
// Spawn the projectile
var spawnPosition = character.transform.position + character.transform.forward * 1.5f;
var direction = (targetPosition - spawnPosition).normalized;
GameObject projectileInstance = Instantiate(prefab, spawnPosition, Quaternion.LookRotation(direction));
if (projectileInstance.TryGetComponent(out NetworkObject networkObject))
{
networkObject.Spawn();
if (projectileInstance.TryGetComponent(out FreezeThrowPrefab freezeProjectile))
{
freezeProjectile.Initialize(character, direction, projectileSpeed, abilityDuration);
Debug.Log($"[FreezeThrowAbility] Projectile launched by {character.name}.");
}
else
{
Debug.LogError("[FreezeThrowAbility] The projectile prefab does not have a FreezeProjectile component.");
Destroy(projectileInstance);
}
}
else
{
Debug.LogError("[FreezeThrowAbility] Prefab must have a NetworkObject component.");
Destroy(projectileInstance);
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8c1371d9d978b1e4dbf2d6385a724a55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,48 @@
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using UnityEngine;
using Unity.Netcode;
public class FreezeThrowPrefab : NetworkBehaviour
{
private Vector3 direction;
private float speed;
private float freezeDuration;
private ServerCharacter owner;
public void Initialize(ServerCharacter character, Vector3 direction, float speed, float freezeDuration)
{
this.owner = character;
this.direction = direction.normalized;
this.speed = speed;
this.freezeDuration = freezeDuration;
}
private void Update()
{
if (IsServer)
{
transform.position += direction * speed * Time.deltaTime;
// Check for collision or expiry
if (Vector3.Distance(transform.position, owner.transform.position) > 20f)
{
NetworkObject.Despawn();
}
}
}
private void OnTriggerEnter(Collider other)
{
if (!IsServer) return;
if (other.TryGetComponent(out ServerCharacter target))
{
if (target != owner)
{
Debug.Log($"[FreezeProjectile] Hit {target.name}. Applying freeze for {freezeDuration} seconds.");
target.Freeze(freezeDuration);
NetworkObject.Despawn();
}
}
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c50774b2618009240b2ec9ed41e7454f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -290,6 +290,20 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
} }
} }
public void Freeze(float duration)
{
StartCoroutine(FreezeCoroutine(duration));
}
private IEnumerator FreezeCoroutine(float duration)
{
Debug.Log($"{name} is frozen for {duration} seconds!");
Movement.SetSpeedModifier(0f); // Disable movement
yield return new WaitForSeconds(duration);
Movement.ResetSpeedModifier(); // Restore movement
Debug.Log($"{name} is no longer frozen.");
}
private void HandleOccupiedPlatform(Platform currentPlatform) private void HandleOccupiedPlatform(Platform currentPlatform)
{ {

@ -4,6 +4,7 @@ using Unity.BossRoom.Gameplay.Actions;
using Unity.BossRoom.Gameplay.Configuration; using Unity.BossRoom.Gameplay.Configuration;
using Unity.BossRoom.Gameplay.GameplayObjects.Character; using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
using Action = Unity.BossRoom.Gameplay.Actions.Action; using Action = Unity.BossRoom.Gameplay.Actions.Action;
namespace Unity.BossRoom.Gameplay.GameplayObjects namespace Unity.BossRoom.Gameplay.GameplayObjects
@ -81,7 +82,8 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects
public Action DropActionPrototype => m_DropActionPrototype; public Action DropActionPrototype => m_DropActionPrototype;
public Action PickUpActionPrototype => m_PickUpActionPrototype; public Action PickUpActionPrototype => m_PickUpActionPrototype;
public string SlowDownAbilityKey = "DashNCrash"; public string DashNCrashAbilityKey = "DashNCrash";
public string FreezeThrowAbilityKey = "FreezeThrow";
List<Action> m_AllActions; List<Action> m_AllActions;

@ -502,7 +502,7 @@ namespace Unity.BossRoom.Gameplay.UserInput
if (m_ServerCharacter.IsCrow) // Ensure only the crow can activate the ability if (m_ServerCharacter.IsCrow) // Ensure only the crow can activate the ability
{ {
m_UIMessageFeed.DisplayMessage("Activated Ability mode"); m_UIMessageFeed.DisplayMessage("Activated Ability mode");
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.SlowDownAbilityKey); m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.DashNCrashAbilityKey);
} }
else else
{ {
@ -515,6 +515,18 @@ namespace Unity.BossRoom.Gameplay.UserInput
Debug.Log("Cannot activate ability mode while swap mode is active."); Debug.Log("Cannot activate ability mode while swap mode is active.");
} }
} }
if (Input.GetKeyDown(KeyCode.R))
{
if (!IsSwapModeActive) // Prevent ability mode if swap mode is active
{
m_UIMessageFeed.DisplayMessage("Activated Ability mode");
m_AbilitySystem.ActivateAbilityByKey(GameDataSource.Instance.FreezeThrowAbilityKey);
}
else
{
Debug.Log("Cannot activate ability mode while swap mode is active.");
}
}
if (m_AbilitySystem.IsAbilityModeActive()) return; if (m_AbilitySystem.IsAbilityModeActive()) return;
if (!IsSwapModeActive) // Prevent other inputs if swap mode is active if (!IsSwapModeActive) // Prevent other inputs if swap mode is active
{ {
@ -525,10 +537,10 @@ namespace Unity.BossRoom.Gameplay.UserInput
} }
if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null) if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null)
{ {
if (Input.GetMouseButtonDown(1)) // if (Input.GetMouseButtonDown(1))
{ // {
RequestAction(CharacterClass.Skill1.ActionID, SkillTriggerStyle.MouseClick); // RequestAction(CharacterClass.Skill1.ActionID, SkillTriggerStyle.MouseClick);
} // }
if (IsSwapModeActive && Input.GetMouseButtonDown(0)) // Left-click to request swap if (IsSwapModeActive && Input.GetMouseButtonDown(0)) // Left-click to request swap
{ {
HandleSwapRequest(); HandleSwapRequest();

Loading…
Cancel
Save