private void CreateAnimations() { for (int i = CurrentInstructionIndex; i < CurrentProgram.Instructions.Count; i++) { Instruction instruction = CurrentProgram.Instructions[i]; switch (instruction.InstructionType) { case Instruction.Type.Forward: animations.Add(GetMoveAnimation(instruction.Repeat)); UpdatePosition(); break; case Instruction.Type.TurnLeft: animations.Add(GetTurnAnimation(-90)); CurrentOrientation.TurnLeft(); break; case Instruction.Type.TurnRight: animations.Add(GetTurnAnimation(90)); CurrentOrientation.TurnRight(); break; case Instruction.Type.ReadSensor: animations.Add(GetSensorAnimation()); break; } } CurrentPosition = new Position(InitialPosition.X, InitialPosition.Y); CurrentOrientation = new Compass(InitialOrientation.Orientation); }
private void CreateAnimations() { for (int i = CurrentInstructionIndex; i < CurrentProgram.Instructions.Count; i++) { Instruction instruction = CurrentProgram.Instructions[i]; switch (instruction.InstructionType) { case Instruction.Type.Forward: animations.Add(GetMoveAnimation(instruction.Repeat)); break; case Instruction.Type.TurnLeft: animations.Add(GetTurnAnimation(-90)); CurrentOrientation.TurnLeft(); break; case Instruction.Type.TurnRight: animations.Add(GetTurnAnimation(90)); CurrentOrientation.TurnRight(); break; } } }
private void TurnLeftAnimation_Completed(object sender, EventArgs e) { CurrentOrientation.TurnLeft(); }