/// <summary> /// Occurs on activation, sets up the projectile for targeting. /// </summary> void OnEnable() { sChainedToAlready = ""; // reset chain list if (!player) { player = GlobalFuncs.FindPlayerInstance(); // grab the player } if (player) { // found? if (Target == SpawnTarget.Enemy) { // is the source the player if (LockOnHasPriority) { // attempt to use the lock on target tSpellTarget = GlobalFuncs.GetLockOn(); // take the target if any } if (!tSpellTarget && EnableHeatSeeking) { // no lock on and heat seeking mode enabled tSpellTarget = GlobalFuncs.GetTargetWithinRange(transform.position, HeatSeekRange, HeatSeekLayers, HeatSeekTags, HeatSeekNearest, true, 1.5f, true); } } else if (EnableHeatSeeking) { // enemy spell tSpellTarget = player.transform; // that homes on the player } // update the local target seek if (tSpellTarget) { // target found? v3SpellTarget = tSpellTarget.position; // update the seek position v3SpellTarget.y += HeightAdjust; // update height (avoid hiting target feet) } } }
/// <summary> /// Occurs when enabled by the magical pool, sets up the teleport. /// </summary> public virtual void OnEnable() { if (TargetTags != null) { // ensure creating pool master copy doesnt activate it // set gameobject to teleport if (transform.parent) { // if run via the vMagicAttackBehaviour class then set the KeepParent flag goTeleportMe = transform.parent.transform.parent.gameObject; // take the individual to teleport to, enemy or player goTeleportMe.transform.parent = null; // unparent } else { // no parent so assume player as fallback goTeleportMe = GlobalFuncs.FindPlayerInstance(); // find the player gameobject } // init the teleport if (goTeleportMe) { // failsafe, should always be true if (goTeleportMe.tag == "Player") { // am i the player tSpellTarget = GlobalFuncs.GetLockOn(); // do i have a lock } if (!tSpellTarget) { // no lock or enemy ai tSpellTarget = GlobalFuncs.GetTargetWithinRange(goTeleportMe.transform.position, MaxDistance, TargetLayers, TargetTags, NearestTarget, false, 0f, true); } // lets go, unless no target if (tSpellTarget) { // valid? CoTeleport = StartCoroutine(TeleportAtTarget()); // beam me up } } } }