private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec) { var varexec = DefaultLanguageNodes.Variable.Execute(reader, scope, true); var identifier = varexec.ExecuteNext() as string; reader.ReadNext(); if (!reader.LastKeyword.Equals(DefaultLanguageKeywords.EachKeyword)) { throw new SyntaxException(reader, "In loop each declaration, the variable name should be folowed by the each keyword"); } reader.ReadNext(); var sourceexec = DefaultLanguageNodes.Operation.Execute(reader, scope, skipExec); object lastValue = null; foreach (var o in sourceexec) { lastValue = o; yield return(o); } if (lastValue is ICollection == false) { throw new OperationException(reader, "Each loop source is not a collection"); } var source = (lastValue as ICollection).GetEnumerator(); LoopCondition cond = () => Condition(identifier, source, scope); yield return(cond); }
private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec) { if (!IsStartOfNode(reader.LastKeyword, scope)) { throw new SyntaxException(reader, "While declaration should start with while keyword."); } reader.ReadNext(); var conditionReader = new LoopedSourceReader(reader); LoopCondition cond = () => Condition(conditionReader, scope, skipExec); yield return(cond); }
private IEnumerator boneMove(bool reverse) { LoopCondition condition = () => { if (reverse) { return(progress > 0.0f); } else { return(progress < 1.0f); } }; while (condition()) { progress += (0.01f * this.animationSpeed * ((reverse) ? (-1.0f) : (1.0f))); float effectiveProgress; if (reverse) { effectiveProgress = reverseAnimationCurve.Evaluate(progress); } else { effectiveProgress = animationCurve.Evaluate(progress); } bone.localRotation = Quaternion.Lerp( Quaternion.Euler(restBoneRot.x, restBoneRot.y, restBoneRot.z), Quaternion.Euler(operBoneRot.x, operBoneRot.y, operBoneRot.z), effectiveProgress); //meshRenderer.SetBlendShapeWeight(0, 100.0f * animationCurve.Evaluate(Mathf.Clamp(progress, 0.0f, 1.0f))); yield return(new WaitForSeconds(0.0166f)); } running = false; }
public async Task ParseAsync() { int index = 0; var context = new Context(Context); context.Variables = new LoopVariables(Context.Self, 0, null); do { IStruct @struct = await BaseType.Resolve(context); if (@struct != null) { await @struct.ParseAsync(); } Items.Add(@struct); var vars = new LoopVariables(Context.Self, ++index, @struct); context.Variables = vars; } while (!(await LoopCondition.Resolve(context))); }
/// <summary> /// The create loop condition. /// </summary> /// <returns> /// The <see cref="LoopCondition"/>. /// </returns> public LoopCondition CreateLoopCondition() { var myLoopCondition = new LoopCondition(); return(myLoopCondition); }