private static AnimSeq ParseAnimSeq(Dictionary <string, object> data) { AnimSeq anim = new AnimSeq(); string animSet = data["animSet"].ToString().ToLower(); string animName = data["animName"].ToString().ToLower().Replace("_(test)", ""); if (!string.IsNullOrEmpty(animName) && !string.IsNullOrEmpty(animSet)) { if (Animations[animSet].ContainsKey(animName)) { anim.Animation = Animations[animSet][animName]; } } if (data.ContainsKey("movingAnimName")) { animName = data["movingAnimName"].ToString().ToLower().Replace("_(test)", ""); if (animName.Length > 0 && Animations[animSet].ContainsKey(animName)) { anim.MovingAnimation = Animations[animSet][animName]; } } if (data.ContainsKey("waitAnimName")) { animName = data["waitAnimName"].ToString().ToLower().Replace("_(test)", ""); if (animName.Length > 0 && Animations[animSet].ContainsKey(animName)) { anim.MovingAnimation = Animations[animSet][animName]; } } anim.Duration = int.Parse(data["duration"].ToString()); anim.BlendInTime = int.Parse(data["blendInTime"].ToString()); anim.Rate = float.Parse(data["animRate"].ToString()); anim.Looping = bool.Parse(data["bAnimLooping"].ToString()); if (data.ContainsKey("loopingRate")) { anim.LoopingRate = float.Parse(data["loopingRate"].ToString()); } anim.RootMotionXYRate = data.GetValueOrDefault("rootMotionXYRate").Map(x => float.Parse(x.ToString())); anim.RootMotionZRate = float.Parse(data["rootMotionZRate"].ToString()); if (data.ContainsKey("animMotionId")) { anim.MotionId = int.Parse(data["animMotionId"].ToString()); } return(anim); }
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; } }