Example #1
0
 public void draw(int fontSize)
 {
     GUILayout.BeginVertical("box");
     GUI.skin.button.fontSize = fontSize;
     //Show the name, and whose turn
     GUILayout.Label(sc.senderName + ": " + (myTurn?"My Turn":"Their Turn"));
     //show the board
     clicked = GUILayout.SelectionGrid(clicked, xos, 3);
     if (gameOver)         //show reset on Game Over
     {
         GUILayout.Label("Game Over");
         if (GUILayout.Button("Reset"))
         {
             boardState = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
             xos        = new string[] { "\t\t\t", "", "", "", "", "", "", "", "\t\t\t" };
             gameOver   = false;
             myTurn     = true;
         }
     }
     GUILayout.EndVertical();
     //check if there was a valid board selection
     if (clicked != -1)
     {
         if (myTurn && boardState[clicked] == 0)
         {
             //make move
             sc.sendMessage("move:" + clicked.ToString());
             move(clicked, true);
             myTurn = false;
         }
         clicked = -1;
     }
 }
Example #2
0
    public void sendMgs()
    {
        Debug.Log(Mgs.text);
        sc.message = Mgs.text;
        sc.sendMessage();
        sc.message = "";
        Mgs.transform.parent.GetComponent <InputField> ().text = "";

        /*sync para notificaciones*/

        /*string[] fields = {"usuarios_id", "amigos_id", "texto"};
         * string[] values = {GMS.userData.id.ToString(), GMS.amigoData.id, Mgs.text};
         * GMS.insert_sync(fields, values, "notificacion_chat");*/

        Debug.Log("mgs enviado..");
    }
Example #3
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();
    }
Example #4
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
     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")){
         sc.sendMessage();
         sc.message = "";
     }
     GUILayout.EndHorizontal();
     GUILayout.EndVertical();
     GUILayout.EndArea();
 }
Example #5
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 });
    }