Exemplo n.º 1
0
    public IEnumerator throwAwayThings()
    {
        childRB.gameObject.transform.SetParent(transform.parent);
        yield return(new WaitForSeconds(0.6f)); // waits 0.3 seconds

        HoldingSomething = false;

        socket.Emit(socketID, "gyroOff"); // tell phone-node that the fruit is alreay thrown away
    }
Exemplo n.º 2
0
    public void SendData(JSONObject obj)
    {
        print("<color=#32D51CFF>SEND :</color> " + obj.Print());
        JSONObject newData = new JSONObject();
        string     tempstr = AESEncrypt(obj.Print(), ENCKEY, ENCIV);

        newData.AddField("data", tempstr);
        socket.Emit("req", newData);
    }
    void Update()
    {
        // // Collect Data from the Car
        Dictionary <string, string> data = new Dictionary <string, string>();

        data["image"]           = Convert.ToBase64String(CameraHelper.CaptureFrame(FrontFacingCamera));
        data["lane_line_image"] = Convert.ToBase64String(CameraHelper.CaptureFrame(FrontFacingCamera));
        _socket.Emit("telemetry", new JSONObject(data));
    }
Exemplo n.º 4
0
    ///////////////////////////////////
    // Methods Related to Any Player //
    ///////////////////////////////////

    // KILL: Emit kill message when any player is killed
    public static void Kill(string playerID, float xPosition, float zPosition)
    {
        var j = new JSONObject();

        j.AddField("id", playerID);
        j.AddField("x_position", xPosition);
        j.AddField("z_position", zPosition);
        socket.Emit("kill_player", j);
    }
Exemplo n.º 5
0
    public void Join()
    {
        Dictionary <string, string> data = new Dictionary <string, string>();

        data.Add("userNickname", GameManager.instance.UserNickname);
        JSONObject jSONObject = new JSONObject(data);

        socket.Emit("join", jSONObject);
    }
Exemplo n.º 6
0
    public void JoinMsg()
    {
        Dictionary <string, string> data = new Dictionary <string, string>();

        data.Add("userName", GameManager.instance.GetUserName());
        JSONObject jObject = new JSONObject(data);

        socket.Emit("join", jObject);
    }
Exemplo n.º 7
0
    public void SendBacteriaPos(Vector2 bacteriaPos, int bacteriaId)
    {
        Dictionary <string, string> enemyPosData = new Dictionary <string, string>();

        enemyPosData["posx"] = bacteriaPos.x.ToString();
        enemyPosData["posy"] = bacteriaPos.y.ToString();
        enemyPosData["id"]   = bacteriaId.ToString();
        socket.Emit("BACTERIA_POS", new JSONObject(enemyPosData));
    }
    public void send()
    {
        JSONObject jSONObject = new JSONObject(JSONObject.Type.OBJECT);

        jSONObject.AddField("name", name.text);
        jSONObject.AddField("number", number.text);
        socket.Emit("msg.send", jSONObject);
        Debug.Log("send" + jSONObject);
    }
Exemplo n.º 9
0
    void OnCommandMove(Vector3 vec3)
    {
        Dictionary <string, string> data = new Dictionary <string, string>();
        Vector3 position = new Vector3(vec3.x, vec3.y, vec3.z);

        data["position"] = position.x + "," + position.y + "," + position.z;
        socket.Emit("MOVE", new JSONObject(data));
        Debug.Log("Get the message from server in OnCommandMove");
    }
    public static void FoodEaten(string playerId, string foodId)
    {
        var foodData = new JSONObject();

        foodData.AddField("food_id", foodId);
        foodData.AddField("player_id", playerId);

        socket.Emit("eat", foodData);
    }
Exemplo n.º 11
0
    public void OnClickJoin(Button button)
    {
        button.interactable = false;

        JSONObject data = new JSONObject();

        data.AddField("clientId", clientInfo.clientId);
        socket.Emit("req_joinroom", data);
    }
Exemplo n.º 12
0
    public void SendMeshToClients(Mesh mesh)
    {
        SerializedMesh smesh     = new SerializedMesh(mesh);
        var            json_mesh = JSONObject.Create(JsonUtility.ToJson(smesh));

        socket.Emit("dm-update-mesh", json_mesh);

        meshes.meshes.Add(smesh);
    }
        /// <summary>
        /// Login to the Chat.
        /// </summary>
        /// <param name="userName">User name.</param>
        public void Login(string userName)
        {
            Message msg = new Message();

            msg.fromUser = userName;
            //Emite
            socket.Emit("login", msg.ToJson());
            Debug.Log("Login request sent");
        }
Exemplo n.º 14
0
    public void ChangeName(string playerName)
    {
        this.playerName = playerName;
        Dictionary <string, string> jsonData = new Dictionary <string, string> {
            { "playerName", playerName }
        };

        sIO.Emit(EVENT_SETNAME, new JSONObject(jsonData));
    }
Exemplo n.º 15
0
 public void DeleteGame()
 {
     ShowError("");
     socket.Emit("game:delete");
     foreach (GameObject instance in instantiatedGames)
     {
         Destroy(instance);
     }
     EmitGetGames();
 }
Exemplo n.º 16
0
    public void LogInToServer(string name)
    {
        if (gameCTR.isPlaying == false)
        {
            JSONobject = new JSONObject(JSONObject.Type.OBJECT);
            JSONobject.AddField("playerName", name);

            socket.Emit("login", JSONobject);
        }
    }
Exemplo n.º 17
0
    public void OnLogin()
    {
        Dictionary <string, string> data = new Dictionary <string, string>();

        data.Add("id", idText.text);
        data.Add("password", passwordField.text);
        JSONObject jSONObject = new JSONObject(data);

        socket.Emit("OnLogin", jSONObject);
    }
Exemplo n.º 18
0
    public IEnumerator Loadroom()
    {
        yield return(new WaitForSeconds(0.3f));

        var data = JsonUtility.ToJson(playerCon.player);

        Debug.Log(data);
        socket.Emit("LOAD", new JSONObject(data));
        Debug.Log("Sending");
    }
Exemplo n.º 19
0
    public void LeaveEvenIfJoined()
    {
        Dictionary <string, string> pairs = new Dictionary <string, string>();

        pairs.Add("code", myGameCode);
        pairs.Add("deviceId", SystemInfo.deviceUniqueIdentifier);
        GameManager.Inst.isNotYetJoin = false;
        socketIOComponent.Emit("leftGame", new JSONObject(pairs));
        StartCoroutine(CloseConfirmPanelAnimation(true));       //close confirm panel
    }
Exemplo n.º 20
0
    public void sendConnect()
    {
        JsonModel jm = new JsonModel();

        jm.sendStr = "connect";
        jm.result  = uuid;
        JSONObject jo = new JSONObject(JsonUtility.ToJson(jm));

        socket.Emit("send", jo);
    }
Exemplo n.º 21
0
    // send a "ping" message to NodeJS server
    public void SendPingToServer()
    {
        //create a data struct like  <key,value> to storage data
        Dictionary <string, string> pack = new Dictionary <string, string> ();

        pack["message"] = "ping!!!";

        //send to nodeJS server
        socket.Emit("PING", new JSONObject(pack));
    }
Exemplo n.º 22
0
 public void Update()
 {
     if (Input.GetKey("space"))
     {
         data         = new Dictionary <string, string> ();
         data ["msg"] = "noen";
         socket.Emit("fromclient", new JSONObject(data));
         login = false;
     }
 }
Exemplo n.º 23
0
    public void Join()
    {
        print("NetworkManager.Join()");
        Dictionary <string, string> data = new Dictionary <string, string>();

        data.Add("userName", GameManager.instance.userName);
        JSONObject jObject = new JSONObject(data);

        socket.Emit("join", jObject);
    }
Exemplo n.º 24
0
    // 새로운 메시지 이벤트 송신
    public void SendNewMsg(string msg)
    {
        Dictionary <string, string> data = new Dictionary <string, string>();

        data.Add("msg", msg);
        data.Add("userName", GameManager.instance.GetUserName());
        JSONObject jObject = new JSONObject(data);

        socket.Emit("newMsg", jObject);
    }
Exemplo n.º 25
0
    public void ClickSend()
    {
        Debug.Log("Sended");

        JSONObject jSONObject = new JSONObject(JSONObject.Type.OBJECT);

        jSONObject.AddField("name", inputName.text);
        jSONObject.AddField("number", inputNumber.text);
        socketIO.Emit("message", jSONObject);
    }
Exemplo n.º 26
0
    IEnumerator ConnectToServer()
    {
        socket.Emit("connect");
        yield return(new WaitForSeconds(0.5f));

        socket.Emit("add user", JSONObject.CreateStringObject("MyName"));
        yield return(new WaitForSeconds(0.5f));

        socket.Emit("new message", JSONObject.CreateStringObject("MyMessage"));
    }
Exemplo n.º 27
0
    // public variables
    public void Login(string username, string password)
    {
        Debug.Log("Logging in");
        Dictionary <string, string> data = new Dictionary <string, string> ();

        data ["username"] = username;
        data ["password"] = password;

        socket.Emit("login", new JSONObject(data));
    }
Exemplo n.º 28
0
    // /** socket open될때 connect 소켓 보냄 */
    // public void sendConnect() {

    //  JsonModel jm = new JsonModel();
    //  jm.sendStr = "connect";
    //  jm.result = uuid;
    //  JSONObject jo = new JSONObject(JsonUtility.ToJson(jm) );
    //  socket.Emit("send", jo );
    // }

    // public void sendSuccess() {

    //  JsonModel jm = new JsonModel();
    //  jm.sendStr = "success";
    //  JSONObject jo = new JSONObject(JsonUtility.ToJson(jm) );
    //  socket.Emit("send", jo );
    // }

    public void sendDrawing(Vector2 v2)
    {
        JsonModel jm = new JsonModel();

        jm.sendStr = "drawing";
        jm.result  = v2.ToString();
        JSONObject jo = new JSONObject(JsonUtility.ToJson(jm));

        socket.Emit("send", jo);
    }
Exemplo n.º 29
0
    public void LoadData()
    {
        if (socket == null)
        {
            Connect();
        }

        Debug.Log("Loading Data");
        socket.Emit("loadData");
    }
Exemplo n.º 30
0
    public void setgame(SocketIOEvent obj)
    {
        i++;
        Debug.Log(i);
        correctTxt.gameObject.SetActive(false);
        wrongTxt.gameObject.SetActive(false);
        Debug.Log("Game Set" + obj.data);
        QuestionModel question = JsonUtility.FromJson <QuestionModel>(obj.data.ToString());

        Debug.Log(question.question);
        qnumbertxt.text  = "Question " + i;
        questiontxt.text = question.question;
        Debug.Log(question.answer);
        List <QuestionModel.Choices> choices = new List <QuestionModel.Choices>();

        choices = question.choices;
        RemoveChoicesButton();

        foreach (var item in choices)
        {
            GameObject choicesController = answerButtonObjectPool.GetObject();
            choicesController.transform.SetParent(choicesPanel);
            choicesList.Add(choicesController);
            ChoicesController choice = choicesController.GetComponent <ChoicesController>();
            choice.Setup(item);
            timeLeft       = maxTime;
            choice.Isclick = false;
            Button ans = choice.GetComponent <Button>();
            ans.onClick.AddListener(() => {
                if (choice.Isclick == false)
                {
                    Debug.Log("Onclick" + choice.choices.text);
                    if (choice.choices.value == true)
                    {
                        Debug.Log("Correct");
                        choice.Isclick = true;
                        correctTxt.gameObject.SetActive(true);
                        var data = JsonUtility.ToJson(playerCon.player);
                        socket.Emit("Answer", new JSONObject(data));
                        Debug.Log("Sending");
                    }
                    else
                    {
                        Debug.Log("Wrong");
                        choice.Isclick = true;
                        wrongTxt.gameObject.SetActive(true);
                    }
                }
                else
                {
                    Debug.Log("Cannot ans again!!");
                }
            });
        }
    }