//SpellPhaseContext CreatePhaseContext(SpellPhase phase, SpellPhaseContext sourcePhaseContext) { SpellPhaseContext CreatePhaseContext(SpellPhase phase, GameObject contextOwner, Vector3 position, Quaternion rotation) { var prefab = phase.Template.PhaseObjectPrefab; GameObject carrierObject; //bool isTemporaryPhaseObject = prefab != null; bool isTemporaryPhaseObject = true; prefab = prefab ?? SpellManager.Instance.DefaultPhasePrefab; if (prefab != null) { carrierObject = GameObjectManager.Instance.Obtain(prefab, position, rotation); } else { carrierObject = GameObjectManager.Instance.ObtainEmpty(phase.ToString(), position, rotation); } var context = SpellPhaseContext.CreatePhaseContext( carrierObject, phase, contextOwner ?? carrierObject, isTemporaryPhaseObject); phase.NotifyStart(context); return(context); }
public virtual void OnAuraStart(SpellPhaseContext context) { for (int i = 0; i < context.Targets.Count; ++i) { var target = context.Targets [i]; OnAuraStart(context, target); } }
public virtual void Pulse(SpellPhaseContext context) { for (int i = 0; i < context.Targets.Count; ++i) { var target = context.Targets [i]; Pulse(context, target); } }
public override void Apply(SpellPhaseContext context, GameObject target) { var unit = target.GetComponent <Unit> (); if (unit != null) { var damageInfo = ObjectManager.Instance.Obtain <DamageInfo>(); damageInfo.Value = Random.Range(DamageMin, DamageMax); damageInfo.SourceFactionType = FactionManager.GetFactionType(context.ContextOwner); unit.Damage(damageInfo); } }
void UpdateContextStatus(MultiContextPhase phase, int index, SpellPhaseContext context, ref int activeContextCount) { if (context == null || context.ContextOwner == null) { // context was active but carrier object or ContextOwner have been removed phase.CleanUp(index); } else if (context.TimeLeft <= 0) { // context expired phase.NotifyEnd(index); } else { // context is still active ++activeContextCount; } }
protected internal override void NotifyStart(SpellPhaseContext context) { ++ActiveContextCount; ++ContextCount; if (Contexts == null) { Contexts = new SpellPhaseContext[8]; contextActiveStatuses = new bool[8]; } else { if (ContextCount > contexts.Length) { System.Array.Resize(ref contexts, ContextCount); System.Array.Resize(ref contextActiveStatuses, ContextCount); } } context.Index = ContextCount - 1; Contexts[context.Index] = context; contextActiveStatuses [context.Index] = true; context.NotifyStart(); }
public virtual void OnAuraEnd(SpellPhaseContext context, GameObject target) { }
public virtual void Pulse(SpellPhaseContext context, GameObject target) { }
public virtual void Apply(SpellPhaseContext context, GameObject target) { }
protected internal override void NotifyStart(SpellPhaseContext context) { Context = context; isActive = true; context.NotifyStart(); }
protected internal abstract void NotifyStart(SpellPhaseContext context);
void InitializeProjectile(SpellPhaseContext context, GameObject target, Vector3 targetPosition) { // TODO: Set projectile target and impact callback }