Пример #1
0
        public virtual void Update(float dt)
        {
            if (isInterrupted)
            {
                return;
            }
            if (pauseDuration > 0)
            {
                pauseDuration -= dt;
                pauseDuration  = Mathf.Max(0, pauseDuration);
                if (pauseDuration > 0)
                {
                    return;
                }
            }

            elapsed      += dt;
            phaseElapsed += dt;
            TriggerEventFrame(dt);
//			DLog.LogError(this.GetType()+" "+BattleUtils.frame+" "+BattleUtils.time);

            for (int kIndex = loopableElements.Count - 1; kIndex >= 0; kIndex--)
            {
                Loopable loopableElement = loopableElements[kIndex];
                if (loopableElement.IsFinished())
                {
                    loopableElements.RemoveAt(kIndex);
                    if (loopableElement is Jump)
                    {
                        jumps.Remove((Jump)loopableElement);
                    }
                    else if (loopableElement is Vfxs.Vfx)
                    {
                        vfxs.Remove((Vfxs.Vfx)loopableElement);
                    }
                    continue;
                }

                loopableElement.Update(dt);
            }

            OnUpdate(dt);
        }
Пример #2
0
        public void Update(float dt)
        {
            if (spawnPosition.Equals(new Vector3(-1, -1, -1)))
            {
                spawnPosition = Position();
            }
            foreach (SkillCastingRequirement skillCastingRequirement in skillCastingRequirements.Values)
            {
                skillCastingRequirement.Update(dt);
            }
//			DLog.LogError(this.GetType()+" "+BattleUtils.frame+" "+BattleUtils.time);
            CleanupSkillsThatAreFinished();
            for (int i = ongoingSkills.Count - 1; i >= 0; i--)
            {
                Skill skill = ongoingSkills[i];
                skill.Update(dt);
            }

            foreach (SkillId skillId in queuedInterruptSkills)
            {
                InterruptSkill(skillId);
            }
            queuedInterruptSkills.Clear();

            if (isUnderChanneling && channelingSkill.IsChannelingFinish())
            {
                isUnderChanneling = false;
            }

            for (int i = ongoingModifiers.Count - 1; i >= 0; i--)
            {
                Modifier modifier = ongoingModifiers[i];
                modifier.Update(dt);
                if (modifier.IsFinish())
                {
                    ongoingModifiers.RemoveAt(i);
                    modifier.OnDetach(this);
                    NotifyModifierDetachment(modifier);
                }
            }
            List <Modifier> ongoingModifiersCauseStateChange = new List <Modifier>();

            foreach (Modifier modifier in ongoingModifiers)
            {
                if (modifier.IsBuff())
                {
                    continue;
                }
                if (IsDebuffWithoutStateChangeContains(modifier.Type()))
                {
                    continue;
                }

                ongoingModifiersCauseStateChange.Add(modifier);
            }
            if (ongoingModifiersCauseStateChange.Count < 1 && State() != CharacterState.Default)
            {
                ChangeToState(CharacterState.Default);
            }

            for (int i = loopables.Count - 1; i >= 0; i--)
            {
                Loopable loopable = loopables[i];
                loopable.Update(dt);
                if (loopable.IsFinished())
                {
                    loopables.RemoveAt(i);
                }
            }
        }