57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
using System;
|
|
using Cielonos.MainGame.Characters;
|
|
using Cielonos.MainGame.Inventory;
|
|
using DamageNumbersPro;
|
|
using Lean.Pool;
|
|
using UnityEngine;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace Cielonos.MainGame
|
|
{
|
|
public class AttackSubmodule : AttackAreaSubmoduleBase
|
|
{
|
|
public bool isOverridingHitEffect;
|
|
public GameObject hitVFXPrefab;
|
|
public DamageNumber damageNumberRegularPrefab;
|
|
public DamageNumber damageNumberCriticalPrefab;
|
|
|
|
public AttackUnit attackUnit;
|
|
public AttackValue attackValue;
|
|
|
|
public Action<GameObject, CharacterBase> modifyHitEffectAction;
|
|
|
|
public AttackSubmodule(AttackAreaBase attackArea, AttackUnit attackUnit, GameObject hitVFXPrefab) : base(attackArea)
|
|
{
|
|
this.attackUnit = attackUnit;
|
|
this.attackValue = attackUnit.GetAttackValue(owner.creator);
|
|
this.isOverridingHitEffect = false;
|
|
this.hitVFXPrefab = hitVFXPrefab;
|
|
|
|
AttackType attackType = attackValue.attackType;
|
|
|
|
this.damageNumberRegularPrefab = MainGameManager.BasePrefabs.GetHudTextPrefab(attackType, false);
|
|
this.damageNumberCriticalPrefab = MainGameManager.BasePrefabs.GetHudTextPrefab(attackType, true);
|
|
}
|
|
|
|
public GameObject SpawnHitVFX(CharacterBase creator, Vector3 position, Vector3 direction = default)
|
|
{
|
|
if (isOverridingHitEffect) return null;
|
|
|
|
if (hitVFXPrefab != null)
|
|
{
|
|
direction = direction == default ? direction : Vector3.up;
|
|
GameObject hitEffect = VFXObject.Spawn(hitVFXPrefab, creator, position, Quaternion.LookRotation(direction));
|
|
return hitEffect;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public void SpawnDamageNumber(Vector3 position, bool isCritical, float finalDamage)
|
|
{
|
|
DamageNumber finalDN = isCritical ? damageNumberCriticalPrefab : damageNumberRegularPrefab;
|
|
DamageNumber damageNumber = finalDN.Spawn(position, finalDamage);
|
|
damageNumber.spamGroup = attackArea.areaName;
|
|
}
|
|
}
|
|
} |