Beispiel #1
0
        public static bool TryParse(string texto, out CambiarMapaAccion accion)
        {
            string[] partes       = texto.Split('|');
            string   total_partes = partes[Extensiones.get_Nuevo_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);
        }
Beispiel #2
0
        public bool get_Cambiar_Mapa(MapaTeleportCeldas direccion)
        {
            if (cuenta.esta_ocupado || personaje.inventario.porcentaje_pods >= 100)
            {
                return(false);
            }

            List <Celda> celdas_teleport = cuenta.juego.mapa.celdas.Where(celda => celda.es_Teleport()).ToList();

            while (celdas_teleport.Count > 0)
            {
                Celda celda = celdas_teleport[Extensiones.get_Nuevo_Random(0, celdas_teleport.Count)];

                if (get_Cambiar_Mapa(direccion, celda))
                {
                    return(true);
                }

                celdas_teleport.Remove(celda);
            }
            return(false);
        }