using Photon.Pun; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Template_RuntimeInstance { public class AbilityInstance { public string id; public BaseAbility template; public float currentCooldown; public float currentManaCost; public float currentHealthCost; public float currentClassResourceCost; public List currentEffects; public List currentModifiers; public IAbilityProperties properties; public AbilityInstance(BaseAbility template) { this.id = System.Guid.NewGuid().ToString(); this.template = template; this.currentCooldown = template.cooldown; this.currentManaCost = template.manaCost; this.currentHealthCost = template.healthCost; this.currentClassResourceCost = template.classResourceCost; this.currentEffects = new List(template.abilityEffects); this.currentModifiers = new List(); this.properties = template.CreateProperties(); this.properties.Initialize(template); } public void AddModifier(IAbilityModifier abilityModifier) { currentModifiers.Add(abilityModifier); } public void RemoveModifier(IAbilityModifier abilityModifier) { currentModifiers.Remove(abilityModifier); } public void Execute(PhotonView user, Taggable userTag, Vector3 targetPosition, Taggable targetTag) { AbilityExecutionContext context = new AbilityExecutionContext { User = user, UserTag = userTag, TargetPosition = targetPosition, TargetTag = targetTag, Cooldown = currentCooldown, ManaCost = currentManaCost, HealthCost = currentHealthCost, ClassResourceCost = currentClassResourceCost, Effects = currentEffects, Modifiers = currentModifiers }; SpendResourcesNecessary(user); properties.ModifiedExecution(context); /*foreach (var effect in context.Effects) { effect.ApplyEffect(context.UserTag, new List { context.TargetTag }); } currentCooldown = context.Cooldown; currentManaCost = context.ManaCost; currentHealthCost = context.HealthCost; currentClassResourceCost = context.ClassResourceCost;*/ } public void SpendResourcesNecessary(PhotonView user) { user.GetComponent().ChangeValue(-currentManaCost); user.GetComponent().ChangeValue(-currentHealthCost); user.GetComponent()?.ChangeValue(-currentClassResourceCost); } } }