Exemplo n.º 1
0
        /// <summary>
        /// Occurs as the animator leaves the state, cleans up instances, returning them to the pool.
        /// </summary>
        /// <param name="animator">Reference to the parent animator.</param>
        /// <param name="stateInfo">Information about the state.</param>
        /// <param name="layerIndex">Index of the current animator layer.</param>
        public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            // handle limb particle effects
            if (goLimb1_ParticleInstance)
            {                                                                                     // still have limb 1 particle?
                GlobalFuncs.ReturnToThePoolOrDestroy(iLimbPoolSlotID1, goLimb1_ParticleInstance); // return to the pool, or destroy it if no pool
                goLimb1_ParticleInstance = null;                                                  // ensure destroy the reference
            }
            if (goLimb2_ParticleInstance)
            {                                                                                         // still have limb 2 particle?
                if (SpellOptions.LimbParticleEffect2)
                {                                                                                     // did limb2 use a separate effect?
                    GlobalFuncs.ReturnToThePoolOrDestroy(iLimbPoolSlotID2, goLimb2_ParticleInstance); // return to the pool, or destroy it if no pool
                }
                else
                {                                                                                     // negative, return to the same pool as limb1
                    GlobalFuncs.ReturnToThePoolOrDestroy(iLimbPoolSlotID1, goLimb2_ParticleInstance); // return to the pool, or destroy it if no pool
                }
                goLimb2_ParticleInstance = null;                                                      // ensure destroy the reference
            }

            // remove spawned charged (non moving) particles
            if (SpellOptions.ChargeState)
            {                                                                                                    // was this the charge animator state
                foreach (SpawnerOptionsOverTime sootSpawnMe in SpellOptions.SpawnOverTime)
                {                                                                                                // process all spawns
                    GlobalFuncs.ReturnToThePoolOrDestroy(sootSpawnMe.PoolSlotId, sootSpawnMe.goSpawnedParticle); // destroy
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Collectable trigger via collider.
        /// </summary>
        /// <param name="col">Collider that has triggered the potential picup</param>
        void OnCollisionEnter(Collision col)
        {
            if ((TriggerLayers.value & 1 << col.gameObject.layer) == 1 << col.gameObject.layer)    // matching layer
            {
                CharacterBase levellingSystem = col.gameObject.GetComponent <CharacterBase>();
                if (levellingSystem)
                {
                    levellingSystem.Collectables[(int)Type].Value += Amount;
                    levellingSystem.ForceUpdateHUD();

                    // play audio
                    if (SourceOfAudio && PlayOnCollection)
                    {
                        SourceOfAudio.clip = PlayOnCollection;
                        SourceOfAudio.Play();
                    }

                    if (PrefabsToSpawn.Count > 0)
                    {
                        CoDelayedSpawn = StartCoroutine(GlobalFuncs.SpawnAllDelayed(PrefabsToSpawn, Delay, NoneSequential, transform, gameObject, iPoolSlotID, ForceFaceTrigger, Target));     // call shared spawner loop
                    }
                    else
                    {
                        // remove collectable from the game
                        GlobalFuncs.ReturnToThePoolOrDestroy(iPoolSlotID, gameObject);
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Occurs when the projectile collides with another collider.
 /// </summary>
 /// <param name="c">Collider that caused the collision event.</param>
 void OnCollisionEnter(Collision c)
 {
     if (((HeatSeekLayers.value | GlobalFuncs.targetingLayerMaskCollision.value) & 1 << c.gameObject.layer) == 1 << c.gameObject.layer)
     {  // valid collide target
         bool bFound = false;
         if (ChainEffectCount > 0)
         {  // chain spell to another target?
             List <Transform> listTargetsInRange = GlobalFuncs.FindAllTargetsWithinRange(transform.position, HeatSeekRange, HeatSeekLayers, HeatSeekTags, true, 1.5f, true);
             if (listTargetsInRange.Count > 0)
             {                                                       // found more in range
                 sChainedToAlready += "-" + c.gameObject.name + "-"; // unique character names required, append name of current collision
                 foreach (Transform t in listTargetsInRange)
                 {
                     if (!sChainedToAlready.Contains("-" + t.gameObject.name + "-"))
                     {                                                                                                                                         // found new target
                         DestroyGameObjectAndSpawn md = GetComponent <DestroyGameObjectAndSpawn>();                                                            //  attempt gray destroy n spawn
                         if (md)
                         {                                                                                                                                     // found
                             md.enabled = false;                                                                                                               // disable it
                         }
                         MagicPool_Return mr = GetComponent <MagicPool_Return>();                                                                              // attempt get the pool return component
                         if (mr)
                         {                                                                                                                                     // found
                             mr.enabled = false;                                                                                                               // disable
                             mr.enabled = true;                                                                                                                // re enable, resetting the count down
                         }
                         tSpellTarget  = t;                                                                                                                    // re target the projectile
                         v3SpellTarget = tSpellTarget.position;                                                                                                // update position of the transform
                         FollowTarget  = true;                                                                                                                 // ensure moving target is followed
                         bFound        = true;                                                                                                                 // flag don't destroy
                         if (ParticlesOnCollision.Count > 0)
                         {                                                                                                                                     // has spawns?
                             StartCoroutine(GlobalFuncs.SpawnAllDelayed(ParticlesOnCollision, SpawnDelay, NoneSequential, transform, null, 0, false, Target)); // spawn all but dont kill the projectile
                         }
                         ChainEffectCount -= 1;                                                                                                                // lower the chain count
                         break;                                                                                                                                // work complete
                     }
                 }
             }
         }
         if (!bFound)
         {                                                                                                                                                             // run out of chain-able enemies or chaining not enabled
             if (ParticlesOnCollision.Count > 0)
             {                                                                                                                                                         // has spawns?
                 if (gameObject.activeInHierarchy)
                 {                                                                                                                                                     // failsafe, not already returned to the pool
                     StartCoroutine(GlobalFuncs.SpawnAllDelayed(ParticlesOnCollision, SpawnDelay, NoneSequential, transform, gameObject, iPoolSlotID, false, Target)); // spawn all then kill the projectile
                 }
             }
             else
             {
                 GlobalFuncs.ReturnToThePoolOrDestroy(iPoolSlotID, gameObject);  // kill or return projectile to the pool
             }
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Apply the spawn settings to the instantiated game object
        /// </summary>
        /// <param name="Instance"></param>
        /// <param name="PhysicsInstance"></param>
        protected void SetSpawnOptions(ref GameObject Instance, PhysicsOptions PhysicsInstance)
        {
            Instance.SetActive(false);                                                                         // ensure not active
            if (!KeepParent)                                                                                   // some spells such as teleport DO NOT want this setting
            {
                Instance.transform.parent = null;                                                              // clear
            }
            if (Offset != Vector3.zero)                                                                        // offset needed?
            {
                Instance.transform.position = Instance.transform.position + Offset;                            // add in the offset
            }
            if (Angle != Vector3.zero)                                                                         // angular offset needed?
            {
                Instance.transform.localRotation = Quaternion.Euler(Angle) * Instance.transform.localRotation; // alter the angle
            }
            RandomSphere.Apply(ref Instance);                                                                  // spawn randomly within sphere radius?
            RandomRotate.Apply(ref Instance);                                                                  // apply random rotation to the enabled axis's
            PhysicsInstance.Apply(Instance, Target);                                                           // explode with force?
            if (CheckSpaceIsEmpty(Instance))                                                                   // spawned within an empty space checked ok?
            {
                if (DestructionTimeOut > 0)                                                                    // max length of instance enabled
                {
                    if (GlobalFuncs.MAGICAL_POOL && !DoNotPool)                                                // pool enabled?
                    {
                        MagicPool_Return mr = Instance.GetComponent <MagicPool_Return>();                      // attempt get the pool return component
                        mr.Delay = DestructionTimeOut;                                                         // set the return to pool timeout
                    }
                    else
                    {
                        UnityEngine.Object.Destroy(Instance, DestructionTimeOut);  // set to destroy in 5,4,3...
                    }
                }
            }
            else  // space not empty
            {
                GlobalFuncs.ReturnToThePoolOrDestroy(PoolSlotId, Instance);  // send back to the pool (if enabled)
            }

            // all options set activate
            Instance.SetActive(true);
        }  // set the spawn options
Exemplo n.º 5
0
        /// <summary>
        /// Teleport processing, called via coroutine.
        /// </summary>
        /// <returns>IEnumerator for the delay between take off and landing.</returns>
        public virtual IEnumerator TeleportAtTarget()
        {
            // Spawn the take off particle effect
            if (TakeOffParticle.Prefab)
            {                                       // if available
                TakeOffParticle.KeepParent = false; // ensure leave the particle at the takeoff location
                if (TakeOffParticle.NumberToSpawn == 0)
                {
                    TakeOffParticle.NumberToSpawn = 1;                           // failsafe
                }
                TakeOffParticle.Spawn(goTeleportMe.transform, SpawnTarget.Any);  // pull fx from the pool
            }

            // Delay time between particle effect and Teleport
            yield return(new WaitForSeconds(TeleportDelay));

            // move the individual to the telport location offset, facing the target
            goTeleportMe.transform.position = tSpellTarget.position + tSpellTarget.forward * Offset;
            Vector3 v3Temp = tSpellTarget.position;

            v3Temp.y = tSpellTarget.position.y + HeightAdjust;
            goTeleportMe.transform.LookAt(v3Temp);

            // Spawn the landing off particle effect
            if (LandingParticle.Prefab)
            {  // if available
                if (TakeOffParticle.NumberToSpawn == 0)
                {
                    TakeOffParticle.NumberToSpawn = 1;                           // failsafe
                }
                LandingParticle.Spawn(goTeleportMe.transform, SpawnTarget.Any);  // pull fx from the pool
            }

            // clean up
            yield return(new WaitForSeconds(TeleportDelay));

            GlobalFuncs.ReturnToThePoolOrDestroy(PoolSlotID, gameObject);  // kill or return teleport to the pool
        }
Exemplo n.º 6
0
        /// <summary>
        /// Delay then return to the magic pool (or destroy if pool not enabled).
        /// </summary>
        /// <returns>IEnujmerator until the delay has passed.</returns>
        IEnumerator DelayedReturnToPool()
        {
            yield return(new WaitForSeconds(Delay));                      // wait

            GlobalFuncs.ReturnToThePoolOrDestroy(PoolSlotID, gameObject); // send back to the pool
        }