Пример #1
0
        public override void Update(ManagerHelper mH)
        {
            if (nextPulseCounter >= nextPulseSpeed)
            {
                if (pulseCounter < pulseLength)
                {
                    Pulse(mH);
                    AnimatePulse(mH);
                    pulseCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;

                    for (int i = 0; i < affectedNPCList.Count; i++)
                    {
                        if (PathHelper.Distance(this.GetOriginPosition(), affectedNPCList[i].GetOriginPosition()) > 200)
                        {
                            affectedNPCList[i].speed = new Vector2(affectedNPCList[i].movementSpeed);
                            affectedNPCList[i].path  = affectedNPCList[i].NewPath(mH);

                            affectedNPCList.Remove(affectedNPCList[i]);
                            i--;
                        }
                    }
                }

                else
                {
                    foreach (NPC a in affectedNPCList)
                    {
                        a.speed = new Vector2(a.movementSpeed);
                        a.path  = a.NewPath(mH);
                    }

                    affectedNPCList.Clear();

                    pulseCounter     = 0;
                    nextPulseCounter = 0;
                }
            }

            else
            {
                nextPulseCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
            }

            Animate(mH);

            base.Update(mH);
            pulse.Update(mH);
        }