Added Freeze Throw Ability
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:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9c332b27cf965044b8d1499bfcd9059
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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:
|
Loading…
Reference in New Issue