public Movement.GenericMovement MovementFromString(string parameters) { Movement.MovementStruct movementStruct = ManeuverFromString(parameters); string[] arrParameters = parameters.Split('.'); int speed = int.Parse(arrParameters[0]); Movement.GenericMovement result = null; if (movementStruct.Bearing == Movement.ManeuverBearing.Straight) { result = new Movement.StraightMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.KoiogranTurn) { result = new Movement.KoiogranTurnMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Turn) { result = new Movement.TurnMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Bank) { result = new Movement.BankMovement(speed, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } return(result); }
public static Movement.GenericMovement MovementFromStruct(Movement.MovementStruct movementStruct) { Movement.GenericMovement result = null; if (movementStruct.Bearing == Movement.ManeuverBearing.Straight) { result = new Movement.StraightMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.KoiogranTurn) { result = new Movement.KoiogranTurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Turn) { result = new Movement.TurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Bank) { result = new Movement.BankMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.SegnorsLoop) { result = new Movement.SegnorsLoopMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.TallonRoll) { result = new Movement.TallonRollMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Stationary) { result = new Movement.StationaryMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } return(result); }
public static Movement.GenericMovement MovementFromStruct(Movement.ManeuverHolder movementStruct) { Movement.GenericMovement result = null; if (movementStruct.Bearing == Movement.ManeuverBearing.Straight) { result = new Movement.StraightMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.KoiogranTurn) { result = new Movement.KoiogranTurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Turn) { result = new Movement.TurnMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Bank) { result = new Movement.BankMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.SegnorsLoop) { result = new Movement.SegnorsLoopMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.SegnorsLoopUsingTurnTemplate) { result = new Movement.SegnorsLoopUsingTurnTemplateMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.TallonRoll) { result = new Movement.TallonRollMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Stationary) { result = new Movement.StationaryMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else if (movementStruct.Bearing == Movement.ManeuverBearing.Reverse) { if (movementStruct.Direction == Movement.ManeuverDirection.Forward) { result = new Movement.ReverseStraightMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } else { result = new Movement.ReverseBankMovement(movementStruct.SpeedInt, movementStruct.Direction, movementStruct.Bearing, movementStruct.ColorComplexity); } } return(result); }