Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        PreferenciasPartida prefs = GameObject.FindGameObjectWithTag("Prefs").GetComponent <PreferenciasPartida> ();
        string texto_victoria;

        if (prefs.victoria == Constantes.VICTORIA_J1)
        {
            texto_victoria = "JUGADOR 1 ES EL NUEVO TLATOANI";
        }
        else if (prefs.victoria == Constantes.VICTORIA_J2)
        {
            if (prefs.tipoPartida == Constantes.SINGLE)
            {
                texto_victoria = "SERA UNA INTELIGENCIA ARTIFICIAL\nQUIEN GOBIERNE";
            }
            else
            {
                texto_victoria = "JUGADOR 1 ES EL NUEVO TLATOANI";
            }
        }
        else if (prefs.victoria == Constantes.EMPATE)
        {
            texto_victoria = "\\[T]/ EMPATE \\[T]/";
        }
        else
        {
            texto_victoria = "ERROR DE CONEXION DE RED";
        }
        uitext_victoria.text = texto_victoria;
        prefs.personajes [0] = 0;
        prefs.personajes [1] = 0;
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        //de forma temporal en Start pues no hay escena de seleccion de personaje aun
        GameObject tmp = GameObject.FindGameObjectWithTag("Prefs");

        prefs = tmp.GetComponent <PreferenciasPartida>();
        //decision de como seleccionara personajes, automatico un jugador y multijugador local
        //conexion con el otro cliente para seleccion en modo multijugador en red

        /*switch (prefs.tipoPartida) {
         * case Constantes.SINGLE:
         *      prefs.personajes [0] = Constantes.AMLO;
         *      prefs.personajes [1] = Constantes.MEADE;
         *      break;
         * case Constantes.MULTI_LOCAL:
         *      prefs.personajes [0] = Constantes.AMLO;
         *      prefs.personajes [1] = Constantes.MEADE;
         *      break;
         * case Constantes.MULTI_RED_HOST:
         *      prefs.personajes [0] = Constantes.MEADE; // host siempre es el 1
         *      //prefs.server.SendBytesTo (1, (byte[])prefs.personajes [0], 4, 0);
         *      prefs.server.Enviar (prefs.personajes [0].ToString ());
         *      prefs.esperado = Constantes.SELECCION_JUGADOR;
         *      //aqui es donde debera esperar por la seleccion dle cliente
         *      break;
         * case Constantes.MULTI_RED_CLI:
         *      //solo configura su personaje
         *      prefs.personajes [1] = Constantes.ANAYA; // el cliente siempre es el jugador 2
         *      break;
         * }
         * if(prefs.tipoPartida!=Constantes.MULTI_RED_HOST && prefs.tipoPartida!=Constantes.MULTI_RED_CLI)
         *      UnityEngine.SceneManagement.SceneManager.LoadScene ("Partida");*/
    }
Ejemplo n.º 3
0
    void OnMouseDown()
    {
        GameObject          tmp   = GameObject.FindGameObjectWithTag("Prefs");
        PreferenciasPartida prefs = tmp.GetComponent <PreferenciasPartida>();

        prefs.tipoPartida = Constantes.MULTI_RED_HOST;
        UnityEngine.SceneManagement.SceneManager.LoadScene("Conexion_Host");
    }
    public void OnClick()
    {
        GameObject          tmp   = GameObject.FindGameObjectWithTag("Prefs");
        PreferenciasPartida prefs = tmp.GetComponent <PreferenciasPartida>();

        prefs.client = prefs.gameObject.AddComponent <Cliente> ();
        prefs.client.IniCliente(ip.text);
    }
Ejemplo n.º 5
0
    void OnMouseDown()
    {
        GameObject          tmp   = GameObject.FindGameObjectWithTag("Prefs");
        PreferenciasPartida prefs = tmp.GetComponent <PreferenciasPartida>();

        prefs.tipoPartida = Constantes.SINGLE;
        UnityEngine.SceneManagement.SceneManager.LoadScene("Seleccion_Personaje");
    }
Ejemplo n.º 6
0
    void OnMouseDown()
    {
        Debug.Log("se pusho el boton local");
        GameObject          tmp   = GameObject.FindGameObjectWithTag("Prefs");
        PreferenciasPartida prefs = tmp.GetComponent <PreferenciasPartida>();

        prefs.tipoPartida = Constantes.MULTI_LOCAL;
        UnityEngine.SceneManagement.SceneManager.LoadScene("Seleccion_Personaje");
    }
Ejemplo n.º 7
0
    public int IniServer()
    {
        // Initializing the Transport Layer with no arguments (default settings)
        NetworkTransport.Init();
        ConnectionConfig config = new ConnectionConfig();

        myReliableChannelId = config.AddChannel(QosType.Reliable);
        HostTopology topology = new HostTopology(config, 1);

        socketId = NetworkTransport.AddHost(topology, Constantes.PUERTO);
        Debug.Log("Socket abierto. SocketId es: " + socketId);
        GameObject tmp = GameObject.FindGameObjectWithTag("Prefs");

        prefs = tmp.GetComponent <PreferenciasPartida>();
        return(socketId);
    }
Ejemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        turno               = 0;
        numero_ronda        = 1;
        juega1              = false;
        ListaRepeticiones   = new List <int> ();
        Sujetos             = new List <ComponenteInsulto> ();
        InsultosSimples     = new List <ComponenteInsulto> ();
        InsultosContinuados = new List <ComponenteInsulto> ();

        //gameobject de preferencias de partida
        GameObject tmp = GameObject.FindGameObjectWithTag("Prefs");

        preferencias = tmp.GetComponent <PreferenciasPartida> ();

        //logs de preferencias
        Debug.Log("tipo de partida :" + preferencias.tipoPartida);
        Debug.Log("personaje 1 :" + preferencias.personajes [0]);
        Debug.Log("personaje 2 :" + preferencias.personajes [1]);

        //obtener los gameobjects pertenecientes a cada jugador
        Jugadores = new List <GameObject> (GameObject.FindGameObjectsWithTag("Player"));
        //invertir lista pues unity regresa la lista de objetos en orden de
        //el ultimo agregado es el primero en la lista
        Jugadores.Reverse();
        //carga las animaciones correspondientes a cada jugador
        int i = 0;

        foreach (GameObject jugador in Jugadores)
        {
            jugador.GetComponent <Jugador> ().CargarPersonaje(preferencias.personajes [i]);
            i++;
        }
        //cargar las listas de diccionarios desde el archivo
        Carga_Diccionarios();
        //ListasLog ();//log temporal
        //obtener objetos componente de la escena
        ListaCompartida = new List <GameObject>(GameObject.FindGameObjectsWithTag("ComponentePublico"));
        Jugadores[0].GetComponent <Jugador>().componentesAux = new List <GameObject>(GameObject.FindGameObjectsWithTag("ComponentePrivadoJ1"));
        Jugadores[1].GetComponent <Jugador>().componentesAux = new List <GameObject>(GameObject.FindGameObjectsWithTag("ComponentePrivadoJ2"));
        BotonesComponentes = new List <GameObject>(GameObject.FindGameObjectsWithTag("BotonComponente"));
        //GameObject.FindGameObjectWithTag ("POW1").SetActive (false);
        //GameObject.FindGameObjectWithTag ("POW2").SetActive (false);
        InicializarRonda();
    }
    void Awake()
    {
        //revisa si ya existe una instancia
        if (instancia == null)
        {
            //si no existe referencia a esta instancia al ser creada
            instancia = this;
        }
        //si ya existe y no es esta la destruye
        else if (instancia != this)
        {
            Destroy(gameObject);
        }


        //configura que esta instancia no se destruya al cargar otra escena
        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 10
0
    void OnMouseDown()
    {
        Debug.Log("regresando al menu de red");
        GameObject          tmp   = GameObject.FindGameObjectWithTag("Prefs");
        PreferenciasPartida prefs = tmp.GetComponent <PreferenciasPartida>();

        if (prefs.tipoPartida == Constantes.MULTI_RED_CLI && prefs.client != null)
        {
            prefs.client.closeClient();
            Destroy(prefs.client);
        }
        else if (prefs.tipoPartida == Constantes.MULTI_RED_HOST && prefs.server != null)
        {
            prefs.server.closeServer();
            Destroy(prefs.server);
        }
        UnityEngine.SceneManagement.SceneManager.LoadScene("Menu_Red");
    }
Ejemplo n.º 11
0
    public void OnClick()
    {
        GameObject          tmp   = GameObject.FindGameObjectWithTag("Prefs");
        PreferenciasPartida prefs = tmp.GetComponent <PreferenciasPartida>();

        Destroy(prefs.server);
        Destroy(prefs.client);
        prefs.server = prefs.gameObject.AddComponent <Server> ();
        if (prefs.server.IniServer() >= 0)
        {
            texto.text = "server iniciado,esperando conexion\nIP: " + Network.player.ipAddress;
        }
        else
        {
            texto.text = "no se pudo iniciar el server";
        }

        //pasar a la siguiente escena
    }
Ejemplo n.º 12
0
    public void IniCliente(string direccionIP)
    {
        if (direccionIP == "localhost")
        {
            direccionIP = "127.0.0.1";
        }
        //inicializacion de socketId
        NetworkTransport.Init();
        ConnectionConfig config = new ConnectionConfig();

        myReliableChannelId = config.AddChannel(QosType.Reliable);

        HostTopology topology = new HostTopology(config, 1);

        socketId = NetworkTransport.AddHost(topology, 0);        //puerto arbitrario
        //conexion
        connectionId = NetworkTransport.Connect(socketId, direccionIP, Constantes.PUERTO, 0, out error);
        //ConnectionSimulatorConfig sim = new ConnectionSimulatorConfig(30,45,31,44,0.02F);
        //connectionId = NetworkTransport.ConnectWithSimulator(socketId, direccionIP, Constantes.PUERTO, 0, out error,sim);
        GameObject tmp = GameObject.FindGameObjectWithTag("Prefs");

        prefs = tmp.GetComponent <PreferenciasPartida>();
        //Debug.Log("Connected, error:" + error.ToString());
    }