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 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); }
private void SetManeuverIcon(GameObject button, KeyValuePair <string, Movement.ManeuverColor> maneuverData) { Movement.MovementStruct movement = Game.Movement.ManeuverFromString(maneuverData.Key); string imageName = ""; if ((movement.Direction == Movement.ManeuverDirection.Forward) && (movement.Bearing == Movement.ManeuverBearing.Straight)) { imageName += "Straight"; } if ((movement.Direction == Movement.ManeuverDirection.Forward) && (movement.Bearing == Movement.ManeuverBearing.KoiogranTurn)) { imageName += "Koiogran"; } if (movement.Bearing == Movement.ManeuverBearing.Bank) { imageName += "Bank"; } if (movement.Bearing == Movement.ManeuverBearing.Turn) { imageName += "Turn"; } if (movement.Direction == Movement.ManeuverDirection.Left) { imageName += "Left"; } if (movement.Direction == Movement.ManeuverDirection.Right) { imageName += "Right"; } if (maneuverData.Value == Movement.ManeuverColor.Green) { imageName += "Green"; } if (maneuverData.Value == Movement.ManeuverColor.White) { imageName += "White"; } if (maneuverData.Value == Movement.ManeuverColor.Red) { imageName += "Red"; } Sprite image = Game.PrefabsList.ImageStorageDirections.transform.Find(imageName).GetComponent <Image>().sprite; button.GetComponent <Image>().sprite = image; }
public static Movement.GenericMovement MovementFromString(string parameters, Ship.GenericShip ship = null) { Movement.MovementStruct movementStruct = new Movement.MovementStruct(parameters, ship); return(MovementFromStruct(movementStruct)); }
public Movement.MovementStruct ManeuverFromString(string parameters) { string[] arrParameters = parameters.Split('.'); Movement.ManeuverSpeed speed = Movement.ManeuverSpeed.Speed1; switch (arrParameters[0]) { case "1": speed = Movement.ManeuverSpeed.Speed1; break; case "2": speed = Movement.ManeuverSpeed.Speed2; break; case "3": speed = Movement.ManeuverSpeed.Speed3; break; case "4": speed = Movement.ManeuverSpeed.Speed4; break; case "5": speed = Movement.ManeuverSpeed.Speed5; break; } Movement.ManeuverDirection direction = Movement.ManeuverDirection.Forward; switch (arrParameters[1]) { case "F": direction = Movement.ManeuverDirection.Forward; break; case "L": direction = Movement.ManeuverDirection.Left; break; case "R": direction = Movement.ManeuverDirection.Right; break; } Movement.ManeuverBearing bearing = Movement.ManeuverBearing.Straight; switch (arrParameters[2]) { case "S": bearing = Movement.ManeuverBearing.Straight; break; case "R": bearing = Movement.ManeuverBearing.KoiogranTurn; break; case "B": bearing = Movement.ManeuverBearing.Bank; break; case "T": bearing = Movement.ManeuverBearing.Turn; break; } Movement.ManeuverColor color = Selection.ThisShip.GetColorComplexityOfManeuver(parameters); Movement.MovementStruct result = new Movement.MovementStruct(); result.Speed = speed; result.Direction = direction; result.Bearing = bearing; result.ColorComplexity = color; return(result); }
public Movement.GenericMovement MovementFromString(string parameters) { Movement.MovementStruct movementStruct = new Movement.MovementStruct(parameters); return(MovementFromStruct(movementStruct)); }