135 lines
6.4 KiB
C#
135 lines
6.4 KiB
C#
using Kryz.CharacterStats;
|
|
using Kryz.CharacterStats.Examples;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(fileName = "SummonAbility", menuName = "RiftMayhem/AbilitySystem/Abilities/Summon Ability", order = 0)]
|
|
public class SummonAbility : BaseAbility
|
|
{
|
|
public GameObject minionPrefab;
|
|
|
|
public int numberOfSpawns = 1;
|
|
public bool instantlyReady = false;
|
|
public bool isImage = false;
|
|
|
|
[Space]
|
|
|
|
[Space]
|
|
public float AttackDamagePercentFromMaster;
|
|
public float SpellDamagePercentFromMaster;
|
|
public float AttackSpeedPercentFromMaster;
|
|
public float CritChancePercentFromMaster;
|
|
public float CritDamagePercentFromMaster;
|
|
|
|
public float MaxHealthPercentFromMaster;
|
|
public float HealthRegenPercentFromMaster;
|
|
public float MaxManaPercentFromMaster;
|
|
public float ManaRegenPercentFromMaster;
|
|
|
|
public float ArmorPercentFromMaster;
|
|
public float MagicResistancePercentFromMaster;
|
|
|
|
public float AreaEffectivenessFromMaster;
|
|
public float AuraPowerFromMaster;
|
|
|
|
|
|
|
|
private GameObject instantiatedMinion;
|
|
private CharacterStats ownerStats;
|
|
private CharacterStats minionStats;
|
|
private MinionSpiritPowerReleaseController minionSpiritPowerReleaseController;
|
|
|
|
public override void Execute(Taggable user)
|
|
{
|
|
base.Execute(user);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
for (int i = 0; i < numberOfSpawns; i++)
|
|
{
|
|
instantiatedMinion = Instantiate(minionPrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position + Vector3.one * i, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
InitializeStatsBasedOnOwner(user);
|
|
SetupMinionSpiritPowerReleaseController(user);
|
|
}
|
|
}
|
|
|
|
public override void Execute(Taggable user, Vector3 point)
|
|
{
|
|
base.Execute(user);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
for (int i = 0; i < numberOfSpawns; i++)
|
|
{
|
|
instantiatedMinion = Instantiate(minionPrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position + Vector3.one * i, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
InitializeStatsBasedOnOwner(user);
|
|
SetupMinionSpiritPowerReleaseController(user);
|
|
}
|
|
}
|
|
|
|
public override void Execute(Taggable user, Transform target)
|
|
{
|
|
base.Execute(user);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
for (int i = 0; i < numberOfSpawns; i++)
|
|
{
|
|
instantiatedMinion = Instantiate(minionPrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position + Vector3.one * i, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
InitializeStatsBasedOnOwner(user);
|
|
SetupMinionSpiritPowerReleaseController(user);
|
|
}
|
|
}
|
|
|
|
public void AutoSummonOnSceneLoad(Taggable user)
|
|
{
|
|
instantiatedMinion = Instantiate(minionPrefab, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
InitializeStatsBasedOnOwner(user);
|
|
SetupMinionSpiritPowerReleaseController(user);
|
|
}
|
|
|
|
private void SetupMinionSpiritPowerReleaseController(Taggable owner)
|
|
{
|
|
minionSpiritPowerReleaseController = instantiatedMinion.GetComponentInChildren<MinionSpiritPowerReleaseController>();
|
|
if (minionSpiritPowerReleaseController == null) return;
|
|
|
|
minionSpiritPowerReleaseController.OwnerSpiritPower = owner.GetComponent<SpiritPower>();
|
|
minionSpiritPowerReleaseController.spiritPowerReserved = spiritPowerReserveCost;
|
|
}
|
|
|
|
private void InitializeStatsBasedOnOwner(Taggable user)
|
|
{
|
|
ownerStats = user.GetComponent<CharacterStats>();
|
|
minionStats = instantiatedMinion.GetComponent<CharacterStats>();
|
|
//TODO: FIX MINION STAT SCALE
|
|
//minionStats.AttackDamage.AddModifier(new StatModifier(ownerStats.AttackDamage.Value * AttackDamagePercentFromMaster, StatModType.Flat, ownerStats));
|
|
//minionStats.SpellDamage.AddModifier(new StatModifier(ownerStats.SpellDamage.Value * SpellDamagePercentFromMaster, StatModType.Flat, ownerStats));
|
|
//
|
|
//minionStats.AttackSpeed.AddModifier(new StatModifier(ownerStats.AttackSpeed.Value * AttackSpeedPercentFromMaster, StatModType.Flat, ownerStats));
|
|
//
|
|
//minionStats.CritChance.AddModifier(new StatModifier(ownerStats.CritChance.Value * CritChancePercentFromMaster, StatModType.Flat, ownerStats));
|
|
//minionStats.CritDamage.AddModifier(new StatModifier(ownerStats.CritDamage.Value * CritDamagePercentFromMaster, StatModType.Flat, ownerStats));
|
|
//
|
|
//minionStats.MaxHealth.AddModifier(new StatModifier(ownerStats.MaxHealth.Value * MaxHealthPercentFromMaster, StatModType.Flat, ownerStats));
|
|
//minionStats.HealthRegen.AddModifier(new StatModifier(ownerStats.HealthRegen.Value * HealthRegenPercentFromMaster, StatModType.Flat, ownerStats));
|
|
//minionStats.MaxMana.AddModifier(new StatModifier(ownerStats.MaxMana.Value * MaxManaPercentFromMaster, StatModType.Flat, ownerStats));
|
|
//minionStats.ManaRegen.AddModifier(new StatModifier(ownerStats.ManaRegen.Value * ManaRegenPercentFromMaster, StatModType.Flat, ownerStats));
|
|
//
|
|
//
|
|
//minionStats.Armor.AddModifier(new StatModifier(ownerStats.Armor.Value * ArmorPercentFromMaster, StatModType.Flat, ownerStats));
|
|
//minionStats.MagicResistance.AddModifier(new StatModifier(ownerStats.MagicResistance.Value * MagicResistancePercentFromMaster, StatModType.Flat, ownerStats));
|
|
//
|
|
//minionStats.AreaEffectiveness.AddModifier(new StatModifier(ownerStats.AreaEffectiveness.Value * AreaEffectivenessFromMaster, StatModType.Flat, ownerStats));
|
|
//minionStats.AuraPower.AddModifier(new StatModifier(ownerStats.AuraPower.Value * AuraPowerFromMaster, StatModType.Flat, ownerStats));
|
|
|
|
minionStats.onUpdateStatValues.Invoke();
|
|
|
|
instantiatedMinion.GetComponent<MinionNPCController>().owner = user;
|
|
|
|
if (instantlyReady)
|
|
{
|
|
instantiatedMinion.GetComponent<MinionNPCController>().SetMinionReadyWithoutAnimation();
|
|
}
|
|
}
|
|
}
|