Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (Dying.isDying(gameObject))
        {
            return;
        }
        else
        {
            float delta = Time.deltaTime;
            //foreach (DelayedAbility delayedAbility in delayedAbilities)
            //{
            //    if (delayedAbility.remainingDuration <= 0)
            //    {
            //        usingAbility.UseAbility(delayedAbility.ability, delayedAbility.target, false, false, true);
            //    }
            //}

            for (int i = delayedAbilities.Count - 1; i >= 0; i--)
            {
                if (delayedAbilities[i].remainingDuration <= 0)
                {
                    usingAbility.UseAbility(delayedAbilities[i].ability, delayedAbilities[i].target, false, false, true);
                }
            }


            delayedAbilities.RemoveAll(x => x.remainingDuration <= 0);
            foreach (DelayedAbility delayedAbility in delayedAbilities)
            {
                delayedAbility.remainingDuration -= delta;
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (sceneLoader)
     {
         // this happens when loading starts
         if (sceneLoader.sceneLoading && !summonsAreChildren)
         {
             summonsAreChildren = true;
             SummonTracker tracker = GetComponent <SummonTracker>();
             if (tracker)
             {
                 // make all summons children of the player so that they become persistent
                 for (int i = 0; i < tracker.summons.Count; i++)
                 //foreach (Summoned summon in tracker.summons)
                 {
                     // don't add dying summons
                     if (!Dying.isDying(tracker.summons[i].gameObject))
                     {
                         tracker.summons[i].transform.parent = transform;
                     }
                     // delete old dying summons
                     else
                     {
                         Destroy(tracker.summons[i]);
                     }
                 }
             }
         }
         // this happens once a scene has loaded
         if (!sceneLoader.sceneLoading && summonsAreChildren)
         {
             summonsAreChildren = false;
             SummonTracker tracker = GetComponent <SummonTracker>();
             if (tracker)
             {
                 // put all the summons at the players position and set their parent to null
                 foreach (Summoned summon in tracker.summons)
                 {
                     // do not set their parent to null if they attach to the parent
                     if (!summon.GetComponent <AttachToSummoner>())
                     {
                         bool         navmeshEnabled = false;
                         NavMeshAgent agent          = summon.GetComponent <NavMeshAgent>();
                         if (agent)
                         {
                             navmeshEnabled = agent.enabled;
                             agent.enabled  = false;
                         }
                         summon.transform.position = transform.position + randomPositionOnRing(0.5f);
                         summon.transform.parent   = null;
                         if (agent && navmeshEnabled)
                         {
                             agent.enabled = true;
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
 // Update is called once per frame
 void Update()
 {
     if (target && abilityMover && !Dying.isDying(targetGo))
     {
         targetPosition = target.position;
         newDirection   = Vector3.Normalize(new Vector3(target.position.x, target.position.y + 1.2f, target.position.z) - transform.position);
         if (Time.deltaTime * homingSpeed > 1)
         {
             abilityMover.SetDirection(newDirection, changeFacingDirection);
         }
         else
         {
             abilityMover.SetDirection(newDirection * Time.deltaTime * homingSpeed + abilityMover.positionDelta * (1 - Time.deltaTime * homingSpeed), changeFacingDirection);
         }
     }
 }