init 1.1.2
This commit is contained in:
+77
@@ -0,0 +1,77 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using EmeraldAI.Utility;
|
||||
using System.Linq;
|
||||
|
||||
namespace EmeraldAI
|
||||
{
|
||||
public class AreaOfEffect : MonoBehaviour
|
||||
{
|
||||
public LayerMask Enemies;
|
||||
AreaOfEffectAbility CurrentAbilityData;
|
||||
GameObject Owner;
|
||||
EmeraldSystem EmeraldComponent;
|
||||
|
||||
public void Initialize (GameObject owner, Transform AttackTransform, AreaOfEffectAbility abilityData)
|
||||
{
|
||||
EmeraldComponent = owner.GetComponent<EmeraldSystem>();
|
||||
Enemies = EmeraldComponent.DetectionComponent.DetectionLayerMask;
|
||||
CurrentAbilityData = abilityData;
|
||||
Owner = owner;
|
||||
IntitailizeInternal(Owner, AttackTransform);
|
||||
}
|
||||
|
||||
void IntitailizeInternal (GameObject Owner, Transform AttackTransform)
|
||||
{
|
||||
List<Collider> DetectedAOETargets = Physics.OverlapSphere(AttackTransform.position, CurrentAbilityData.AreaOfEffectSettings.Radius, Enemies).ToList(); //Only looks for targets that have the same layer as the layers from the AI's DetectionLayerMask.
|
||||
DetectedAOETargets.Remove(Owner.GetComponent<Collider>()); //Remove the owner's collider if it happens to be detected.
|
||||
|
||||
for (int i = 0; i < DetectedAOETargets.Count; i++)
|
||||
{
|
||||
//Only damage targets that the Owner has an Enemy Relation Type with.
|
||||
if (EmeraldAPI.Faction.GetTargetFactionRelation(EmeraldComponent, DetectedAOETargets[i].transform) == "Enemy")
|
||||
{
|
||||
ICombat m_ICombat = DetectedAOETargets[i].GetComponent<ICombat>();
|
||||
|
||||
if (CurrentAbilityData.AreaOfEffectSettings.HitTargetEffect != null)
|
||||
{
|
||||
if (m_ICombat != null && !m_ICombat.IsDodging() && !m_ICombat.IsBlocking() && DetectedAOETargets[i].transform.localScale != Vector3.one * 0.003f)
|
||||
EmeraldObjectPool.SpawnEffect(CurrentAbilityData.AreaOfEffectSettings.HitTargetEffect, DetectedAOETargets[i].GetComponent<ICombat>().DamagePosition(), DetectedAOETargets[i].transform.rotation, CurrentAbilityData.AreaOfEffectSettings.HitTargetEffectTimeoutSeconds);
|
||||
}
|
||||
|
||||
DamageTarget(DetectedAOETargets[i].gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Damaes the projectile's StartingTarget, given that it has a IDamageable.
|
||||
/// </summary>
|
||||
void DamageTarget(GameObject Target)
|
||||
{
|
||||
if (Target.transform.localScale == Vector3.one * 0.003f) return;
|
||||
|
||||
if (CurrentAbilityData.StunnedSettings.Enabled && CurrentAbilityData.StunnedSettings.RollForStun())
|
||||
{
|
||||
var m_ICombat = Target.GetComponentInParent<ICombat>();
|
||||
if (m_ICombat != null) m_ICombat.TriggerStun(CurrentAbilityData.StunnedSettings.StunLength);
|
||||
}
|
||||
|
||||
//Only cause damage if it's enabled
|
||||
if (!CurrentAbilityData.DamageSettings.Enabled) return;
|
||||
|
||||
var m_IDamageable = Target.GetComponent<IDamageable>();
|
||||
if (m_IDamageable != null)
|
||||
{
|
||||
bool IsCritHit = CurrentAbilityData.DamageSettings.GenerateCritHit();
|
||||
m_IDamageable.Damage(CurrentAbilityData.DamageSettings.GenerateDamage(IsCritHit), Owner.transform, CurrentAbilityData.DamageSettings.BaseDamageSettings.RagdollForce, IsCritHit);
|
||||
CurrentAbilityData.DamageSettings.DamageTargetOverTime(CurrentAbilityData, CurrentAbilityData.DamageSettings, Owner, Target);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log(Target.gameObject + " is missing a IDamageable and/or ICombat Component, apply one");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00899966b59ef584dbb3699e4352d2e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using EmeraldAI.Utility;
|
||||
using System.Linq;
|
||||
|
||||
namespace EmeraldAI
|
||||
{
|
||||
[CreateAssetMenu(fileName = "Area of Effect Ability", menuName = "Emerald AI/Ability/Area of Effect Ability")]
|
||||
public class AreaOfEffectAbility : EmeraldAbilityObject
|
||||
{
|
||||
public AbilityData.ChargeSettingsData ChargeSettings;
|
||||
public AbilityData.CreateSettingsData CreateSettings;
|
||||
public AbilityData.AreaOfEffectData AreaOfEffectSettings;
|
||||
public AbilityData.StunnedData StunnedSettings;
|
||||
public AbilityData.DamageData DamageSettings;
|
||||
|
||||
public override void ChargeAbility(GameObject Owner, Transform AttackTransform = null)
|
||||
{
|
||||
ChargeSettings.SpawnChargeEffect(Owner, AttackTransform);
|
||||
}
|
||||
|
||||
public override void InvokeAbility(GameObject Owner, Transform AttackTransform = null)
|
||||
{
|
||||
MonoBehaviour OwnerMonoBehaviour = Owner.GetComponent<MonoBehaviour>();
|
||||
Transform Target = GetTarget(Owner, AbilityData.TargetTypes.CurrentTarget);
|
||||
CreateSettings.SpawnCreateEffect(Owner, AttackTransform);
|
||||
OwnerMonoBehaviour.StartCoroutine(StartAOE(Owner, AttackTransform));
|
||||
}
|
||||
|
||||
IEnumerator StartAOE (GameObject Owner, Transform AttackTransform = null)
|
||||
{
|
||||
yield return new WaitForSeconds(AreaOfEffectSettings.Delay);
|
||||
|
||||
Vector3 SpawnPosition = new Vector3(AttackTransform.position.x, Owner.transform.position.y, AttackTransform.position.z) + Vector3.up * AreaOfEffectSettings.HeightOffset;
|
||||
GameObject SpawnedAbility = AreaOfEffectSettings.SpawnAOEEffect(Owner, SpawnPosition);
|
||||
AssignScript(SpawnedAbility).Initialize(Owner, AttackTransform, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assign the AreaOfEffect script on the newly spawned AOE effect.
|
||||
/// </summary>
|
||||
public AreaOfEffect AssignScript(GameObject SpawnedAbility)
|
||||
{
|
||||
var areaOfEffect = SpawnedAbility.GetComponent<AreaOfEffect>();
|
||||
if (areaOfEffect == null) areaOfEffect = SpawnedAbility.AddComponent<AreaOfEffect>();
|
||||
return areaOfEffect;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bffe9c5d4821ade4f9493c7cb29686d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user