コード例 #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);
        }
コード例 #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;
                }
            }
        }
コード例 #3
0
 private void TurnRightAnimation_Completed(object sender, EventArgs e)
 {
     CurrentOrientation.TurnRight();
 }