Exemplo n.º 1
0
	void Start(){
		//set chat group name
		newGroup1 = group1;
		newGroup2 = group2;
		//randomly select two different fake names
		int s = Random.Range(0,names.Length),s2=Random.Range(0,names.Length);
		n1 = names[s];
		while(s==s2){s2 = Random.Range(0,names.Length);}
		n2 = names[s2];
		//initialize the SimChat objects
		sc = new SimChat("default","hat",gameObject.GetComponent<MonoBehaviour>(),n1);
		sc2 = new SimChat("default","hatalso",gameObject.GetComponent<MonoBehaviour>(),n2);
		//tell the SimChat Objects to continuously check for new messages
		sc.continueCheckMessages();
		sc2.continueCheckMessages();
		//set the functions to call when a new message is received
		sc.setReceiveFunction(receiveMessage1);
		sc2.setReceiveFunction(receiveMessage2);
		//set the new password values to the current password values
		newPass1 = sc.password;
		newPass2 = sc2.password;
		//initialize the word filter
		TextAsset wd = Resources.Load("words", typeof(TextAsset)) as TextAsset;
		if(wd==null)
			UnityEngine.Debug.LogWarning("File Not Found 'words'");	
		wf = new TWordFilter(wd.text);
	}
Exemplo n.º 2
0
    void displayChat(Rect area, SimChat sc, Vector2 sp)
    {
        sp.y = Mathf.Infinity;
        GUILayout.BeginArea(area);

        GUILayout.BeginVertical("box");
        sp = GUILayout.BeginScrollView(sp);
        Color c = GUI.contentColor;

        //loop through each of the messages contained in allMessages
        foreach (SimpleMessage sm in sc.allMessages)
        {
            GUILayout.BeginHorizontal();
            //check if the sender had the same name as me, and change the color
            if (sm.sender == sender)
            {
                GUI.contentColor = Color.red;
                GUILayout.FlexibleSpace();
                GUILayout.Label(sm.message);
            }
            else
            {
                GUI.contentColor = Color.green;
                GUILayout.Label(sm.sender + ": " + sm.message);
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
        }
        GUI.contentColor = c;
        GUILayout.EndScrollView();

        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
Exemplo n.º 3
0
	void displayChat(Rect area,SimChat sc,Vector2 sp){
		sp.y = Mathf.Infinity;
		GUILayout.BeginArea(area);
		
		GUILayout.BeginVertical("box");
		sp = GUILayout.BeginScrollView(sp);
		Color c = GUI.contentColor;
		//loop through each of the messages contained in allMessages
		foreach(SimpleMessage sm in sc.allMessages){
			GUILayout.BeginHorizontal();
			//check if the sender had the same name as me, and change the color
			if(sm.sender == sender){
				GUI.contentColor = Color.red;
				GUILayout.FlexibleSpace();
				GUILayout.Label(sm.message);
			}else{
				GUI.contentColor = Color.green;
				GUILayout.Label(sm.sender+": "+sm.message);
				GUILayout.FlexibleSpace();
			}
			GUILayout.EndHorizontal();
		}
		GUI.contentColor = c;
		GUILayout.EndScrollView();
		
		GUILayout.EndVertical();
		GUILayout.EndArea();
	}
Exemplo n.º 4
0
    void Start()
    {
        //set chat group name
        newGroup1 = group1;
        newGroup2 = group2;
        //randomly select two different fake names
        int s = Random.Range(0, names.Length), s2 = Random.Range(0, names.Length);

        n1 = names[s];
        while (s == s2)
        {
            s2 = Random.Range(0, names.Length);
        }
        n2 = names[s2];
        //initialize the SimChat objects
        sc  = new SimChat("default", "hat", gameObject.GetComponent <MonoBehaviour>(), n1);
        sc2 = new SimChat("default", "hatalso", gameObject.GetComponent <MonoBehaviour>(), n2);
        //tell the SimChat Objects to continuously check for new messages
        sc.continueCheckMessages();
        sc2.continueCheckMessages();
        //set the functions to call when a new message is received
        sc.setReceiveFunction(receiveMessage1);
        sc2.setReceiveFunction(receiveMessage2);
        //set the new password values to the current password values
        newPass1 = sc.password;
        newPass2 = sc2.password;
        //initialize the word filter
        TextAsset wd = Resources.Load("words", typeof(TextAsset)) as TextAsset;

        if (wd == null)
        {
            UnityEngine.Debug.LogWarning("File Not Found 'words'");
        }
        wf = new TWordFilter(wd.text);
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        //amigoData = new UserData();
        GameObject GM = GameObject.Find("MainController");

        GMS = GM.GetComponent <MainController>();

        string amigoId = PlayerPrefs.GetString("chatUserId");

        chatImage.sprite = GMS.spriteSquareFromFile(GMS.amigoData.foto);
        chatNombre.text  = GMS.amigoData.nombre;

        /*GMS.db.OpenDB("millasperrunas.db");
         * ArrayList result = GMS.db.BasicQueryArray ("select familia.id, familia.email, familia.nombre, familia.foto, perros_usuarios.chat_group from familia " +
         *                                         "inner join perros_usuarios on perros_usuarios.usuarios_id = familia.id where familia.id = "+amigoId+" ");
         * GMS.db.CloseDB ();*/

        //Debug.Log ("amigo id: " + ((string[])result [0]) [0]);

        /*amigoData.id = GMS.amigoData.id;
         * amigoData.email = GMS.amigoData.email;
         * amigoData.nombre = GMS.amigoData.nombre;
         * amigoData.foto =  GMS.amigoData.foto;*/

        amigoImage = GMS.spriteSquareFromFile(GMS.amigoData.foto);
        userImage  = GMS.spriteSquareFromFile(GMS.userData.foto);

        Application.runInBackground = true;
        //string chatGroup = ((string[])result [0]) [4];

        string chatGroup = GMS.amigoData.chat_group;

        /*Debug.Log ("chat group vals: " + ((string[])result [0]) [4] + " | " + GMS.perro.chat_group);
         * Debug.Log ("chat group: " + chatGroup);*/

        sender = GMS.userData.nombre;
        sc     = new SimChat(chatGroup, gameObject.GetComponent <MonoBehaviour>(), sender);

        sc.continueCheckMessages();
        sc.setReceiveFunction(receiveMessage1);

        chatYo.SetActive(false);
        chatEl.SetActive(false);
        //displayChat2 ();

        //myScrollRect.verticalNormalizedPosition = 0.5f;
        yChatCount = chatYo.transform.position.y;
        //RectTransform rectTransform = GetComponent<RectTransform>();
        //rectTransform.pivot = new Vector2(transform.pivot.x, 0);
    }
Exemplo n.º 6
0
	// Use this for initialization
	void Start () {
		GameObject GM = GameObject.Find ("MainController");
		GMS = GM.GetComponent<MainController>();

		string chatGroup = GMS.amigoData.chat_group;

		sender = GMS.userData.nombre/* + "-" + GMS.userData.id*/;
		sc = new SimChat(chatGroup, gameObject.GetComponent<MonoBehaviour>(), sender);
		
		sc.continueCheckMessages();
		sc.setReceiveFunction(receiveMessage1);

		chatNombre.text = GMS.amigoData.nombre;
		chatImage.sprite = GMS.spriteFromFile (GMS.amigoData.foto);
	}
Exemplo n.º 7
0
	// Use this for initialization
	void Start () {
		//amigoData = new UserData();
		GameObject GM = GameObject.Find ("MainController");
		GMS = GM.GetComponent<MainController>();
		
		string amigoId = PlayerPrefs.GetString ("chatUserId");

		chatImage.sprite = GMS.spriteSquareFromFile ( GMS.amigoData.foto );
		chatNombre.text = GMS.amigoData.nombre;
		
		/*GMS.db.OpenDB("millasperrunas.db");
		ArrayList result = GMS.db.BasicQueryArray ("select familia.id, familia.email, familia.nombre, familia.foto, perros_usuarios.chat_group from familia " +
		                                           "inner join perros_usuarios on perros_usuarios.usuarios_id = familia.id where familia.id = "+amigoId+" ");
		GMS.db.CloseDB ();*/
		
		//Debug.Log ("amigo id: " + ((string[])result [0]) [0]);
		
		/*amigoData.id = GMS.amigoData.id;
		amigoData.email = GMS.amigoData.email;
		amigoData.nombre = GMS.amigoData.nombre;
		amigoData.foto =  GMS.amigoData.foto;*/
		
		amigoImage = GMS.spriteSquareFromFile ( GMS.amigoData.foto );
		userImage = GMS.spriteSquareFromFile ( GMS.userData.foto );
		
		Application.runInBackground = true;
		//string chatGroup = ((string[])result [0]) [4];
		
		string chatGroup = GMS.amigoData.chat_group;
		
		/*Debug.Log ("chat group vals: " + ((string[])result [0]) [4] + " | " + GMS.perro.chat_group);
		Debug.Log ("chat group: " + chatGroup);*/
		
		sender = GMS.userData.nombre;
		sc = new SimChat(chatGroup, gameObject.GetComponent<MonoBehaviour>(), sender);
		
		sc.continueCheckMessages();
		sc.setReceiveFunction(receiveMessage1);
		
		chatYo.SetActive (false);
		chatEl.SetActive (false);
		//displayChat2 ();
		
		//myScrollRect.verticalNormalizedPosition = 0.5f;
		yChatCount = chatYo.transform.position.y;
		//RectTransform rectTransform = GetComponent<RectTransform>();
		//rectTransform.pivot = new Vector2(transform.pivot.x, 0);
	}
Exemplo n.º 8
0
    //helper function to display the SimChat
    public void displayChat(Rect area, SimChat sc, Vector2 sp, string sender)
    {
        sp.y = Mathf.Infinity;
        GUILayout.BeginArea(area);
        GUILayout.BeginHorizontal("box");
        GUILayout.Label("Name: " + sender);
        GUILayout.EndHorizontal();
        GUILayout.BeginVertical("box");
        sp = GUILayout.BeginScrollView(sp);
        Color c = GUI.contentColor;

        //loop through each of the messages contained in allMessages
        GUI.skin.label.wordWrap = true;
        foreach (SimpleMessage sm in sc.allMessages)
        {
            GUILayout.BeginHorizontal();
            //check if the sender had the same name as me, and change the color
            if (sm.sender == sender)
            {
                GUI.contentColor = Color.red;
                GUILayout.FlexibleSpace();
                GUILayout.Label(sm.message);
            }
            else
            {
                GUI.contentColor = Color.green;
                GUILayout.Label(sm.sender + ": " + sm.message);
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
        }
        GUI.contentColor = c;
        GUILayout.EndScrollView();
        GUILayout.BeginHorizontal();
        //send a new message
        sc.message = GUILayout.TextField(sc.message);
        if (GUILayout.Button("Send"))
        {
            //filter words from the string
            wf.cleanString(ref sc.message);
            sc.sendMessage();
            sc.message = "";
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        GameObject GM = GameObject.Find("MainController");

        GMS = GM.GetComponent <MainController>();

        string chatGroup = GMS.amigoData.chat_group;

        sender = GMS.userData.nombre /* + "-" + GMS.userData.id*/;
        sc     = new SimChat(chatGroup, gameObject.GetComponent <MonoBehaviour>(), sender);

        sc.continueCheckMessages();
        sc.setReceiveFunction(receiveMessage1);

        chatNombre.text  = GMS.amigoData.nombre;
        chatImage.sprite = GMS.spriteFromFile(GMS.amigoData.foto);
    }
Exemplo n.º 10
0
    public networkTicTacToe(string group, string password, MonoBehaviour mono, string name)
    {
        //initialize the SimChat
        sc = new SimChat("%" + group, password, mono, name);    // "%" is used so people using the example online can not spam a message stream (unless the message stream group starts with % and they knew that)
        //Continue to check for new messages
        sc.continueCheckMessages();
        //set the receive function
        sc.setReceiveFunction(receive);
        //used as a starting message, used to ensure that firstInfo is triggered
        sc.sendMessage("Start");
        //set the delay between checking for new messages, default is 0.5;
        sc.delay = 0.1f;

        //paths to check for victory
        victoryPaths.Add(new int[] { 0, 1, 2 });
        victoryPaths.Add(new int[] { 3, 4, 5 });
        victoryPaths.Add(new int[] { 6, 7, 8 });
        victoryPaths.Add(new int[] { 0, 3, 6 });
        victoryPaths.Add(new int[] { 1, 4, 7 });
        victoryPaths.Add(new int[] { 2, 5, 8 });
        victoryPaths.Add(new int[] { 0, 4, 8 });
        victoryPaths.Add(new int[] { 6, 4, 2 });
    }
Exemplo n.º 11
0
    void Start()
    {
        //set chat group name
        newGroup = chatGroup;
        //randomly select two different fake names
        int s = Random.Range(0, names.Length), s2 = Random.Range(0, names.Length);

        n1 = names[s];
        while (s == s2)
        {
            s2 = Random.Range(0, names.Length);
        }
        n2 = names[s2];
        //initialize the SimChat objects
        sc  = new SimChat("default", gameObject.GetComponent <MonoBehaviour>(), n1);
        sc2 = new SimChat("default", gameObject.GetComponent <MonoBehaviour>(), n2);
        //tell the SimChat Objects to continuously check for new messages
        sc.continueCheckMessages();
        sc2.continueCheckMessages();
        //set the functions to call when a new message is received
        sc.setReceiveFunction(receiveMessage1);
        sc2.setReceiveFunction(receiveMessage2);
    }
Exemplo n.º 12
0
 void Start()
 {
     //set chat group name
     newGroup = chatGroup;
     //randomly select two different fake names
     int s = Random.Range(0,names.Length),s2=Random.Range(0,names.Length);
     n1 = names[s];
     while(s==s2){s2 = Random.Range(0,names.Length);}
     n2 = names[s2];
     //initialize the SimChat objects
     sc = new SimChat("default",gameObject.GetComponent<MonoBehaviour>(),n1);
     sc2 = new SimChat("default",gameObject.GetComponent<MonoBehaviour>(),n2);
     //tell the SimChat Objects to continuously check for new messages
     sc.continueCheckMessages();
     sc2.continueCheckMessages();
     //set the functions to call when a new message is received
     sc.setReceiveFunction(receiveMessage1);
     sc2.setReceiveFunction(receiveMessage2);
 }
Exemplo n.º 13
0
	//helper function to display the SimChat
	public void displayChat(Rect area,SimChat sc,Vector2 sp,string sender){
		sp.y = Mathf.Infinity;
		GUILayout.BeginArea(area);
		GUILayout.BeginHorizontal("box");
			GUILayout.Label("Name: "+sender);
		GUILayout.EndHorizontal();
		GUILayout.BeginVertical("box");
		sp = GUILayout.BeginScrollView(sp);
		Color c = GUI.contentColor;
		//loop through each of the messages contained in allMessages
		GUI.skin.label.wordWrap = true;
		foreach(SimpleMessage sm in sc.allMessages){
			GUILayout.BeginHorizontal();
			//check if the sender had the same name as me, and change the color
			if(sm.sender == sender){
				GUI.contentColor = Color.red;
				GUILayout.FlexibleSpace();
				GUILayout.Label(sm.message);
			}else{
				GUI.contentColor = Color.green;
				GUILayout.Label(sm.sender+": "+sm.message);
				GUILayout.FlexibleSpace();
			}
			GUILayout.EndHorizontal();
		}
		GUI.contentColor = c;
		GUILayout.EndScrollView();
		GUILayout.BeginHorizontal();
		//send a new message
		sc.message = GUILayout.TextField(sc.message);
		if(GUILayout.Button("Send")){
			//filter words from the string
			wf.cleanString(ref sc.message);
			sc.sendMessage();
			sc.message = "";
		}
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		GUILayout.EndArea();
	}