71 lines
4.5 KiB
C#
71 lines
4.5 KiB
C#
using Kryz.CharacterStats;
|
|
using Kryz.CharacterStats.Examples;
|
|
using Photon.Pun;
|
|
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;
|
|
|
|
private GameObject instantiatedMinion;
|
|
private CharacterStats ownerStats;
|
|
private CharacterStats minionStats;
|
|
|
|
public override void Execute(PhotonView user, Taggable userTag)
|
|
{
|
|
base.Execute(user, userTag);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
instantiatedMinion = PhotonNetwork.Instantiate("Abilities/" + minionPrefab.name, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
InitializeStatsBasedOnOwner(user);
|
|
}
|
|
|
|
public override void Execute(PhotonView user, Taggable userTag, Vector3 point)
|
|
{
|
|
base.Execute(user, userTag);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
instantiatedMinion = PhotonNetwork.Instantiate("Abilities/" + minionPrefab.name, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
InitializeStatsBasedOnOwner(user);
|
|
}
|
|
|
|
public override void Execute(PhotonView user, Taggable userTag, Transform target)
|
|
{
|
|
base.Execute(user, userTag);
|
|
|
|
//Debug.Log($"Player {user.name} casted {this.name} and spent {manaCost} mana.");
|
|
|
|
instantiatedMinion = PhotonNetwork.Instantiate("Abilities/" + minionPrefab.name, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.position, user.GetComponentInChildren<ProjectileSpawnLocationController>().transform.rotation);
|
|
InitializeStatsBasedOnOwner(user);
|
|
}
|
|
|
|
private void InitializeStatsBasedOnOwner(PhotonView user)
|
|
{
|
|
ownerStats = user.GetComponent<CharacterStats>();
|
|
minionStats = instantiatedMinion.GetComponent<CharacterStats>();
|
|
|
|
minionStats.Strength.AddModifier(new StatModifier(ownerStats.Strength.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.Agility.AddModifier(new StatModifier(ownerStats.Agility.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.Intelligence.AddModifier(new StatModifier(ownerStats.Intelligence.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.Spirit.AddModifier(new StatModifier(ownerStats.Spirit.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.Vitality.AddModifier(new StatModifier(ownerStats.Vitality.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
|
|
minionStats.AttackDamage.AddModifier(new StatModifier(ownerStats.AttackDamage.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.SpellDamage.AddModifier(new StatModifier(ownerStats.SpellDamage.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
|
|
minionStats.CritChance.AddModifier(new StatModifier(ownerStats.CritChance.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.CritDamage.AddModifier(new StatModifier(ownerStats.CritDamage.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
|
|
minionStats.MaxHealth.AddModifier(new StatModifier(ownerStats.MaxHealth.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.Armor.AddModifier(new StatModifier(ownerStats.Armor.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
minionStats.MagicResistance.AddModifier(new StatModifier(ownerStats.MagicResistance.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
|
|
|
minionStats.onUpdateStatValues.Invoke();
|
|
}
|
|
}
|