//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 static SpellPhaseContext CreatePhaseContext( GameObject carrierObject, SpellPhase spellPhase, GameObject contextOwner, bool isTemporaryPhaseObject) { var phaseContext = GameObjectManager.Instance.AddComponent <SpellPhaseContext>(carrierObject); phaseContext.Phase = spellPhase; phaseContext.ContextOwner = contextOwner; phaseContext.IsTemporaryPhaseObject = isTemporaryPhaseObject; return(phaseContext); }
/// <summary> /// Find all spell targets, then either send out projectiles to or impact on each of them. /// </summary> void StartCriticalPhase(SpellPhase phase, Action <GameObject> goCb, Action <Vector3> posCb) { Targets.FindTargets(SpellCastContext.Spell.Targets); // handle position target if (Targets.TargetPosition != null) { posCb(Targets.TargetPosition.Value); } // handle object target for (var i = 0; i < Targets.Count; ++i) { var target = Targets[i]; goCb(target); } }