public void SetStepAnimation(IEnumerable <XElement> animationXmls) { stepAnimationList.Clear(); foreach (var animationXml in animationXmls) { StepAnimation stepAnimation = new StepAnimation(); stepAnimation.Path = animationXml.Attribute("Path").Value; stepAnimation.PlayAnimation = animationXml.Attribute("PlayAnimation").Value; stepAnimation.BeginOrEnd = animationXml.Attribute("BeginOrEnd").Value; stepAnimationList.Add(stepAnimation); } }
void Start() { numberOfPassengers = 0; originPosition = transform.localPosition; targetSpeed = speed; if (pathCreator == null) { if (transform.parent != null && transform.parent.tag == Constants.fullTrain) { UpdateChildCart(); } } if (pathCreator != null) { // Subscribed to the pathUpdated event so that we're notified if the path changes during the game distanceTravelled += extraSpace; pathCreator.pathUpdated += OnPathChanged; } if (transform.tag == Constants.trainCart) { foreach (Transform child in gameObject.transform) { if (child.gameObject.CompareTag(Constants.doorAnchorTag)) { doorAnchor = child.gameObject; //add doors foreach (Transform grandChild in child.transform) { if (grandChild.gameObject.CompareTag(Constants.doorTag)) { if (grandChild.name == ("Door")) { door = grandChild.GetComponent <DoorAnimation>(); } else if (grandChild.name == ("Door (1)")) { door1 = grandChild.GetComponent <DoorAnimation1>(); } else if (grandChild.name == ("Step")) { step = grandChild.GetComponent <StepAnimation>(); } } } } } } }
public Gesture(AssetData asset) { string input = asset.Data.FromUTF8Bytes(); input = input.Replace('\t', ' '); var lines = new List <string>(input.Split('\n')); using (var e = lines.GetEnumerator()) { if (!e.MoveNext()) { throw new NotAGestureFormatException(); } int i; if (!int.TryParse(e.Current, out i)) { throw new NotAGestureFormatException(); } if (i != 2) { throw new NotAGestureFormatException(); } if (!e.MoveNext()) { throw new NotAGestureFormatException(); } if (!byte.TryParse(e.Current, out TriggerKey)) { throw new NotAGestureFormatException(); } if (!e.MoveNext()) { throw new NotAGestureFormatException(); } if (!uint.TryParse(e.Current, out TriggerKeyMask)) { throw new NotAGestureFormatException(); } if (!e.MoveNext()) { throw new NotAGestureFormatException(); } Trigger = e.Current; if (!e.MoveNext()) { throw new NotAGestureFormatException(); } ReplaceWith = e.Current; if (!e.MoveNext()) { throw new NotAGestureFormatException(); } int count; if (!int.TryParse(e.Current, out count)) { throw new NotAGestureFormatException(); } if (count < 0) { throw new NotAGestureFormatException(); } for (int idx = 0; idx < count; ++idx) { if (!e.MoveNext()) { throw new NotAGestureFormatException(); } int intval; if (!int.TryParse(e.Current, out intval)) { throw new NotAGestureFormatException(); } switch ((StepType)intval) { case StepType.EndOfGesture: Sequence.Add(new StepEndOfGesture()); return; case StepType.Animation: { var step = new StepAnimation(); if (e.MoveNext()) { step.Name = e.Current; } if (e.MoveNext() && !UUID.TryParse(e.Current, out step.AssetID)) { throw new NotAGestureFormatException(); } if (e.MoveNext() && !int.TryParse(e.Current, out intval)) { throw new NotAGestureFormatException(); } step.AnimationStart = intval != 0; Sequence.Add(step); } break; case StepType.Sound: { var step = new StepSound(); if (e.MoveNext()) { step.Name = e.Current; } if (e.MoveNext() && !UUID.TryParse(e.Current, out step.AssetID)) { throw new NotAGestureFormatException(); } Sequence.Add(step); } break; case StepType.Chat: { var step = new StepChat(); if (e.MoveNext()) { step.Text = e.Current; } e.MoveNext(); Sequence.Add(step); } break; case StepType.Wait: { var step = new StepWait(); if (e.MoveNext() && !float.TryParse(e.Current, NumberStyles.Float, CultureInfo.InvariantCulture, out step.WaitTime)) { throw new NotAGestureFormatException(); } if (e.MoveNext()) { int flags; if (!int.TryParse(e.Current, out flags)) { throw new NotAGestureFormatException(); } step.WaitForTime = (flags & 0x01) != 0; step.WaitForAnimation = (flags & 0x02) != 0; } Sequence.Add(step); } break; default: throw new NotAGestureFormatException(); } } } }