Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 3
0
 private void TurnRightAnimation_Completed(object sender, EventArgs e)
 {
     CurrentOrientation.TurnRight();
 }