public static bool TryParse(string texto, out CambiarMapaAccion accion) { string[] partes = texto.Split('|'); string total_partes = partes[Randomize.get_Random(0, partes.Length)]; Match match = Regex.Match(total_partes, @"(?<move>top|right|bottom|left)\((?<cell>\d{1,3})\)"); if (match.Success) { accion = new CambiarMapaAccion((MapaTeleportCeldas)Enum.Parse(typeof(MapaTeleportCeldas), match.Groups["move"].Value, true), short.Parse(match.Groups["cell"].Value)); return(true); } else { match = Regex.Match(total_partes, @"(?<move>top|right|bottom|left)"); if (match.Success) { accion = new CambiarMapaAccion((MapaTeleportCeldas)Enum.Parse(typeof(MapaTeleportCeldas), match.Groups["move"].Value, true), -1); return(true); } else { match = Regex.Match(total_partes, @"(?<cell>\d{1,3})"); if (match.Success) { accion = new CambiarMapaAccion(MapaTeleportCeldas.NINGUNO, short.Parse(match.Groups["cell"].Value)); return(true); } } } accion = null; return(false); }
public static bool TryParse(string texto, out CambiarMapaAccion accion) { string[] partes = texto.Split('|'); string total_partes = partes[Randomize.get_Random(0, partes.Length)]; Match match = Regex.Match(total_partes, @"(?<direccion>arriba|derecha|abajo|izquierda)\((?<celda>\d{1,3})\)"); if (match.Success) { accion = new CambiarMapaAccion((MapaTeleportCeldas)Enum.Parse(typeof(MapaTeleportCeldas), match.Groups["direccion"].Value, true), short.Parse(match.Groups["celda"].Value)); return(true); } else { match = Regex.Match(total_partes, @"(?<direccion>arriba|derecha|abajo|izquierda)"); if (match.Success) { accion = new CambiarMapaAccion((MapaTeleportCeldas)Enum.Parse(typeof(MapaTeleportCeldas), match.Groups["direccion"].Value, true), -1); return(true); } else { match = Regex.Match(total_partes, @"(?<celda>\d{1,3})"); if (match.Success) { accion = new CambiarMapaAccion(MapaTeleportCeldas.NINGUNO, short.Parse(match.Groups["celda"].Value)); return(true); } } } accion = null; return(false); }