Exemplo n.º 1
0
        private async void ProcessMove(Creature creature, Skill skill)
        {
            bool checkIntersections = creature is Player && skill.Type != SkillType.Evade;

            AnimSeq anim = null;

            skill.Actions.Map(action => action.StageList.Map(stage => stage.AnimationList.Map(animation =>
            {
                if (anim != null)
                {
                    return;
                }

                if (animation.With(a => a.Animation).With(a => a.Distance).Get(d => d[6], 0f) < 1)
                {
                    return;
                }

                anim = animation;
            })));

            if (anim == null)
            {
                return;
            }

            short heading = (short)(creature.Position.Heading + anim.Animation.Dir);

            int stepTime = (int)((anim.Animation.Duraction / skill.TimeRate) / 7);

            float movedDistance = 0f;

            for (int l = 0; l < 7; l++)
            {
                await Task.Delay(stepTime);

                if (creature.LifeStats.IsDead())
                {
                    return;
                }

                float stepDistance = anim.Animation.Distance[l] * anim.RootMotionXYRate - movedDistance;

                if (stepDistance <= 0.0)
                {
                    continue;
                }

                movedDistance += stepDistance;

                Point3D moved = Geom.GetNormal(heading).Multiple(stepDistance);

                if (checkIntersections && anim.Animation.Dir != 32768)
                {
                    float koef = SeUtils.CheckIntersections(creature, heading, moved, stepDistance);
                    moved.X *= koef;
                    moved.Y *= koef;
                }

                creature.Position.X += moved.X;
                creature.Position.Y += moved.Y;
            }
        }