Ejemplo n.º 1
0
        /// <summary>
        /// Occurs when the parent game object collider is triggered by another collider.
        /// </summary>
        /// <param name="c">Collider to potentially apply the healing to.</param>
        private void OnTriggerEnter(Collider c)
        {
            if (HealedAlready)
            {
                return;                 // prevent double heal due to multiple colliders hit on the same character
            }
            if ((HealTargetLayers.value & 1 << c.gameObject.layer) == 1 << c.gameObject.layer)
            {                                                                                        // valid heal target
                CharacterBase LevellingSystem = c.gameObject.GetComponentInParent <CharacterBase>(); // levelling system on root?
                if (LevellingSystem)
                {                                                                                    // sure
                    LevellingSystem.CurrentLife += Amount;                                           // increase HP
                    LevellingSystem.ForceUpdateHUD();                                                // update HUD

                    // handle heal radius ability
                    if (Radius > 0)
                    {                                                                                                                                                               // enabled
                        List <Transform> listTargetsInRange = GlobalFuncs.FindAllTargetsWithinRange(transform.position, Radius, HealTargetLayers, HealTargetTags, false, 1f, true); // find all within range
                        foreach (Transform Target in listTargetsInRange)
                        {
                            CharacterBase TargetLevellingSystem = Target.GetComponentInParent <CharacterBase>(); // levelling system on root?
                            if (TargetLevellingSystem && LevellingSystem.gameObject.name != TargetLevellingSystem.gameObject.name)
                            {                                                                                    // found and not self
                                TargetLevellingSystem.CurrentLife += Amount;                                     // increase HP
                                TargetLevellingSystem.ForceUpdateHUD();                                          // update HUD
                            }
                        }
                    }

                    // work complete
                    HealedAlready = true;
                }
            }
        }
Ejemplo n.º 2
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
             }
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Process all potential reanimate dead within the radius.
        /// </summary>
        /// <returns>IEnumerator whilst delaying.</returns>
        public IEnumerator Start()
        {
            if (InitialDelay > 0)
            {                                                   // initial delay enabled
                yield return(new WaitForSeconds(InitialDelay)); // wait
            }
            yield return(new WaitForSeconds(InitialDelay));     // wait

            int        iReAnimatedSoFar = 0;
            bool       AllDone          = false;
            GameObject goMinion;

            while (!AllDone)
            {                                                                                                                                                             // scan loop for when all bones are tagged rather than just the parent
                AllDone = true;                                                                                                                                           // enable drop out
                if (MaxToReAnimate == 0 || iReAnimatedSoFar < MaxToReAnimate)
                {                                                                                                                                                         // limit how many get reanimated?
                    List <Transform> ltTargetsInRange = GlobalFuncs.FindAllTargetsWithinRange(transform.localPosition, Range, Layers, Tags, LineOfSightCheck, 0f, false); // search for deaders
                    if (ltTargetsInRange.Count > 0)
                    {                                                                                                                                                     // deaders found?
                        foreach (Transform tPotentialDeader in ltTargetsInRange)
                        {                                                                                                                                                 // process all transforms found
                            MagicAI mai = tPotentialDeader.GetComponentInParent <MagicAI>();                                                                              // attempt grab magic ai component
                            if (mai)
                            {                                                                                                                                             // found magic ai?
                                if (mai.MinionPrefab)
                                {                                                                                                                                         // valid is raise?
                                    if (GlobalFuncs.MAGICAL_POOL)
                                    {
                                        goMinion = GlobalFuncs.SpawnBasic(mai.MinionPrefab, 1, mai.transform, new RandomSphereOptions()
                                        {
                                        }, SpawnTarget.Any)[0];
                                    }
                                    else
                                    {
                                        goMinion = Instantiate(mai.MinionPrefab, mai.transform); // attempt spawn from transform
                                        goMinion.transform.SetParent(null);                      // unparent
                                    }
                                    var Agent = goMinion.GetComponent <NavMeshAgent>();
                                    if (Agent)
                                    {
                                        Agent.enabled = true;
                                    }
#if !VANILLA
                                    var vAI = goMinion.GetComponent <v_AICompanion>();
                                    if (vAI)
                                    {
                                        vAI.companion = GlobalFuncs.FindPlayerInstance().transform;
                                        vAI.Init();
                                        vAI.companionState = v_AICompanion.CompanionState.Follow;
                                        vAI.enabled        = true;
                                    }
#endif
                                    DestroyImmediate(mai.transform.gameObject); // kill original lying on the floor
                                    iReAnimatedSoFar += 1;                      // we have raised another, mwahahaha
                                    AllDone           = false;
                                    break;                                      // force rescan area
                                }
                            }
                        }
                    }
                }
            }
            if (DestroyDelay > 0)
            {                                                   // destruction enabled
                yield return(new WaitForSeconds(DestroyDelay)); // wait

                Destroy(gameObject);                            // destruct
            }
        }