/// <summary> /// Append animation paths to the controller /// </summary> /// <param name="flags">Append path flags</param> /// <param name="paths">Paths to append</param> private void AppendPaths(AppendFlagTypes flags, AnimationPlan paths) { var clonedPaths = new AnimationPath[paths.Count]; for (int i = 0; i < paths.Count; i++) { clonedPaths[i] = paths[i].Clone(); } if (this.animationPaths.Count > 0) { AnimationPath last; AnimationPath next; if (flags == AppendFlagTypes.ClearCurrent) { last = this.animationPaths[this.animationPaths.Count - 1]; next = clonedPaths[0]; //Clear all paths this.animationPaths.Clear(); } else if (flags == AppendFlagTypes.EndsCurrent && this.CurrentIndex < this.animationPaths.Count) { last = this.animationPaths[this.CurrentIndex]; next = clonedPaths[0]; //Remove all paths from current to end if (this.CurrentIndex + 1 < this.animationPaths.Count) { this.animationPaths.RemoveRange( this.CurrentIndex + 1, this.animationPaths.Count - (this.CurrentIndex + 1)); } //Mark current path for ending last.End(); } else { last = this.animationPaths[this.animationPaths.Count - 1]; next = clonedPaths[0]; } //Adds transitions from current path item to the first added item last.ConnectTo(next); } this.animationPaths.AddRange(clonedPaths); if (this.CurrentIndex < 0) { this.CurrentIndex = 0; } }
/// <summary> /// Connects the specified path to the current path adding transitions between them /// </summary> /// <param name="animationPath">Animation path to connect with current path</param> public void ConnectTo(AnimationPath animationPath) { var lastItem = this.items[this.items.Count - 1]; var nextItem = animationPath.items[0]; if (lastItem.ClipName != nextItem.ClipName) { var newItem = new AnimationPathItem(lastItem.ClipName + nextItem.ClipName, false, 1, 1f, true); animationPath.items.Insert(0, newItem); } }