public For(int start, int end, Func<int, Instruction> getBody) { this.i = start; this.start = start; this.end = end; this.getBody = getBody; this.body = getBody(i); }
public override InstructionResult Execute(float dt) { switch (body.Execute(dt)) { case InstructionResult.Done: body = body.Reset(); return InstructionResult.Running; case InstructionResult.DoneAndCreateAsteroid: body = body.Reset(); return InstructionResult.RunningAndCreateAsteroid; case InstructionResult.Running: return InstructionResult.Running; case InstructionResult.RunningAndCreateAsteroid: return InstructionResult.RunningAndCreateAsteroid; } return InstructionResult.Running; }
public override InstructionResult Execute(float dt) { if (i >= end) return InstructionResult.Done; else { switch (body.Execute(dt)) { case InstructionResult.Done: i++; body = getBody(i); return InstructionResult.Running; case InstructionResult.DoneAndCreateAsteroid: i++; body = getBody(i); return InstructionResult.RunningAndCreateAsteroid; case InstructionResult.Running: return InstructionResult.Running; case InstructionResult.RunningAndCreateAsteroid: return InstructionResult.RunningAndCreateAsteroid; } return InstructionResult.Done; } }
public Repeat(Instruction body) { this.body = body; }
public Semicolon(Instruction A, Instruction B) { this.A = A; this.B = B; }