// Use this for initialization
 void Start()
 {
     socket.On("match:joined", (SocketIOEvent e) =>
     {
         Debug.Log("[SocketIO] LFM Request successfull.");
         StartCoroutine(InitializeMatch(e.data));
         socket.On("endMatch", (SocketIOEvent ev) =>
         {
             if (SceneManager.GetActiveScene().buildIndex != 1)
             {
                 socket.Off("spell:result", (SocketIOEvent evnt) =>
                 {
                     SpellResult(evnt.data);
                 });
                 socket.Off("spell:pending", (SocketIOEvent evnt) =>
                 {
                     SpellPending(evnt.data);
                 }); socket.Off("spell:blocked", (SocketIOEvent evnt) =>
                 {
                     SpellBlocked(evnt.data);
                 });
                 SceneManager.LoadScene(1);
             }
         });
     });
 }
Beispiel #2
0
 void Start()
 {
     StartCoroutine(ConnectToServer());
     socket.On("USER_CONNECTED", OnUserConnected);
     socket.On("startGame_SUCCESS", startGame_SUCCESS);
     socket.On("LocationSetUp_SUCCESS", LocationSetUp_SUCCESS);
 }
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     socket = GetComponent <SocketIOComponent>();
     socket.On("connected", OnConnect);
     socket.On("hideform", OnHideForm);
     userList.SetActive(false);
 }
Beispiel #4
0
    // here we find all the WheelColliders down in the hierarchy
    public void Start()
    {
        _socket = GameObject.Find("SocketIO").GetComponent <SocketIOComponent>();
        _socket.On("open", OnOpen);
        _socket.On("move", OnMove);

        wheels = GetComponentsInChildren <WheelCollider>();

        for (int i = 0; i < wheels.Length; ++i)
        {
            var wheel = wheels [i];

            // create wheel shapes only when needed
            if (wheelShape != null)
            {
                var ws = GameObject.Instantiate(wheelShape);
                ws.transform.parent = wheel.transform;

                if (wheel.transform.localPosition.x < 0f)
                {
                    ws.transform.localScale = new Vector3(ws.transform.localScale.x * -1f, ws.transform.localScale.y, ws.transform.localScale.z);
                }
            }
        }
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(transform.gameObject);
        go     = GameObject.Find("SocketIO");
        socket = go.GetComponent <SocketIOComponent>();

        controlobject    = GameObject.FindWithTag("unitychan");
        anim             = controlobject.GetComponent <Animator> ();
        unitychancontrol = controlobject.GetComponent <UnityChanControlScriptWithRgidBody> ();

        headview      = GameObject.FindWithTag("head");
        cardboardhead = headview.GetComponent <CardboardHead> ();
        hit           = new RaycastHit();

        cardboardobject = GameObject.FindWithTag("cardboardmain");
        cardboard       = cardboardobject.GetComponent <Cardboard> ();

        Debug.Log(socket);
        if (socket == null)
        {
            Debug.Log("f**k you!");
        }

        socket.On("connection", Connection);
        socket.On("toclient", Controler);
    }
Beispiel #6
0
 void Start()
 {
     randomInt = Random.Range(0, GameUtils.nameList.Length);
     socket.On("open", Receive_Open);
     socket.On("error", Receive_Error);
     socket.On("close", Receive_Close);
 }
Beispiel #7
0
  // Start is called before the first frame update
  void Start()
  {
      socket = GetComponent <SocketIOComponent>();
      socket.On("open", OnConnected);

      socket.On("message.send", OnListenerMessage);
  }
        void Start()
        {
            var socketComponent = GetComponent <SocketIOComponent>();
            var hostAddress     = PlayerPrefs.GetString(PlayerPrefsKeys.HOST_ADDRESS) + SocketInfo.SUFFIX_ADDRESS;

            Debug.Log("Host address is: " + hostAddress);
            socketComponent.url = hostAddress;
            socketComponent.Start();
            socketComponent.Connect();

            _Socket = GetComponent <SocketIOComponent>();

            _Socket.On(Command.CONNECT, e =>
            {
                Debug.Log("Connected to server");
                IsConnectedToServer = true;
                OnConnected?.Invoke();
            });
            _Socket.On(Command.DISCONNECT, e =>
            {
                Debug.LogError("Disconnected from server");
                IsConnectedToServer = false;
                OnDisconnected?.Invoke();
            });

            _Socket.On(Command.MESSAGE, OnMessage);

            LobbyStart();
            GameStart();
        }
Beispiel #9
0
 // Update is called once per frame
 void Update()
 {
     socket.On("win", OnWinCondition);
     socket.On("winID", OnWinID);
     socket.On("lose", OnLose);
     socket.On("Wrong", Wrong);
 }
Beispiel #10
0
    JSONObject jdata1, jdata2;                                            // JSONObject = SocketIO for Unity에서 제공하는 JSON 전송 객체

    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();

        socket.On("open", TestOpen);          // 서버와 연결되면 발생하는 이벤트
        socket.On("boop", TestBoop);
        socket.On("broadMSG", TestBroadMSG);
        socket.On("error", TestError);
        socket.On("close", TestClose);          // 서버와 접속이 끊어지면 발생하는 이벤트

        StartCoroutine(ConnectToServer());

        #region JSON 타입의 전송 객체에 데이터 넣기
        // JSON 전송방법 1
        data.Add("hi", "Node Server");
        data.Add("hello", "World");
        jdata1 = new JSONObject(data);

        // JSON 전송방법 2
        JSONData myObject = new JSONData(1, 45.5f, "lee dong yun");
        //myObject.level = 1;
        //myObject.timeElapsed = 45.5f;
        //myObject.playerName = "lee dong yun";
        string jsonData = JsonUtility.ToJson(myObject);  // object를 JSON string으로 변환
        //print($"jsonData: {jsonData}");
        jdata2 = new JSONObject(jsonData);
        #endregion
    }
Beispiel #11
0
 void Start()
 {
     StartCoroutine(ConnectToServer());
     //socket.Emit("USER_CONNECT");
     socket.On("USER_CONNECTED", OnUserConnected);
     socket.On("getFollowersList", OnGetFollowersList);
 }
Beispiel #12
0
 public void Start()
 {
     socket.On("open", TestOpen);
     socket.On("boop", TestBoop);
     socket.On("error", TestError);
     socket.On("close", TestClose);
 }
Beispiel #13
0
    void Start()
    {
        SocketIOComponent socket = GameObject.Find("SocketIO").GetComponent <SocketIOComponent>();

        socket.On("PLAYER_JOINED", PlayerJoined);
        socket.On("LOAD_MSG_TO_CHAT", LoadMSG);
    }
 void InitSocket()
 {
     socket = GetComponent <SocketIOComponent>();
     socket.On("open", OnConnectionOpen);
     socket.On("error", OnConnectionError);
     socket.On("close", OnConnectionClose);
 }
Beispiel #15
0
 void Start()
 {
     leftArrow.SetActive(false);
     rightArrow.SetActive(false);
     mySock = (SocketIOComponent)socketObj.GetComponent(typeof(SocketIOComponent));
     mySock.On("say", (SocketIOEvent e) => {
         int num = int.Parse(e.data.GetField("label").ToString());
         if (sounds [num] != null)
         {
             AudioSource.PlayClipAtPoint(sounds [num], transform.position);
         }
     });
     mySock.On("sound", (SocketIOEvent e) => {
         string dir = e.data.GetField("dir").ToString();
         if (dir.Equals("left"))
         {
             leftArrow.SetActive(true);
             isLeftActive   = true;
             leftActiveTime = Time.time;
         }
         else if (dir.Equals("right"))
         {
             rightArrow.SetActive(true);
             isRightActive   = true;
             rightActiveTime = Time.time;
         }
     });
 }
    void Start()
    {
        socket = GetComponent <SocketIOComponent>();

        socket.On("connect", ConnectSuccess);
        socket.On("state", State);
    }
 void SktInit()
 {
     SktIO.On("open", OpenMob);
     SktIO.On("req", ReceiveMob);
     SktIO.On("error", ErrorMob);
     SktIO.On("close", CloseMob);
 }
Beispiel #18
0
    private void Login()
    {
        ShowError("");
        ShowSuccess("");
        ToggleSpinner(true);
        Dictionary <string, string> data = new Dictionary <string, string>();

        data["email"]    = email.text;
        data["password"] = password.text;

        socket.Emit("setup:login", new JSONObject(data));

        socket.On("setup:login-complete", (SocketIOEvent e) =>
        {
            string a           = e.data.GetField("response").ToString();
            JSONNode res       = JSON.Parse(a);
            Static.userId      = res["userId"].Value;
            Static.userAddress = res["userAddress"].Value;
            Static.balance     = res["balance"].AsDouble / 1e6;
            ShowSuccess(res["msg"].Value);
            ToggleSpinner(false);
            StartCoroutine(LoadScene());
        });

        socket.On("issue", (SocketIOEvent e) =>
        {
            ShowError(e.data.GetField("msg").str);
            ToggleSpinner(false);
        });
    }
    // Start is called before the first frame update
    void Start()
    {
        #if (UNITY_2018_3_OR_NEWER)
        if (Permission.HasUserAuthorizedPermission(Permission.Microphone))
        {
        }
        else
        {
            Permission.RequestUserPermission(Permission.Microphone);
        }
        #endif

        meditationSessionStarted = false;

        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent <SocketIOComponent>();

        socket.On("open", OpenSocket);
        socket.On("error", ErrorSocket);
        socket.On("close", CloseSocket);
        socket.On("authenticate", AuthenticateSocket);
        socket.On("authenticated", AuthenticatedSocket);
        socket.On("created-meditation-room", CreatedMeditationRoomSocket);
        socket.On("meditation-room-not-full", MeditationRoomNotFullSocket);
        socket.On("meditation-room-is-full", MeditationRoomIsFullSocket);
        socket.On("got-student-data", GotStudentDataSocket);
        socket.On("instructor-left-room", InstructorLeftRoomSocket);

        socket.Connect();
    }
Beispiel #20
0
    public void JoinRoom(string roomID, PlayerVO playerVO)
    {
        //TODO: implement functionality:
        //send user's data to server
        //wait for commands from server:
        //ServerCommand.ADD_PLAYERS
        //ServerCommand.REMOVE_PLAYERS
        //ServerCommand.START_GAME

        //Dictionary<string, string> data = new Dictionary<string, string>();
        //data["message"] = "hello server!";

        //socket.Connect();

        JoinRoomCommandVO commandVO = new JoinRoomCommandVO
        {
            roomID   = roomID,
            playerVO = playerVO
        };

        socket.On(ServerCommand.ADD_PLAYERS, OnAddPlayers);
        socket.On(ServerCommand.START_MATCH, OnStartGame);
        socket.On(ServerCommand.ROUND_RESULTS, OnRoundResults);
        string json = JsonUtility.ToJson(commandVO);

        socket.Emit(ServerCommands.JOIN_ROOM, new JSONObject(json));
    }
Beispiel #21
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();

        socket.On("open", (SocketIOEvent e) => {
        });
        socket.On("error", (SocketIOEvent e) => {
        });
        socket.On("close", (SocketIOEvent e) => {
        });
        socket.On("id", (SocketIOEvent e) => {
            id = e.data.GetField("id").ToString();
        });
        socket.On("gensoldier", (SocketIOEvent e) => {
            Debug.Log(e.data);
            if (id == e.data.GetField("id").ToString())
            {
                Instantiate(soldiers[int.Parse(e.data.GetField("enid").ToString())]);
                point1.text = e.data.GetField("health").ToString();
            }
            else if (e.data.GetField("id").ToString() != null)
            {
                Instantiate(enemies[int.Parse(e.data.GetField("enid").ToString())]);
                point2.text = e.data.GetField("health").ToString();
            }
        });
    }
Beispiel #22
0
    void Start()
    {
        soc.On("Input Button", (soc) =>
        {
            button = (string)soc.data.GetField("Button Pressed");
        });

        soc.On("Input Tilt", (soc) =>
        {
            tilt.x = soc.data.GetField("X").f;
            tilt.y = soc.data.GetField("Y").f;
            tilt.z = soc.data.GetField("Z").f;
        });

        soc.On("Input Direction", (soc) =>
        {
            direction.x = soc.data.GetField("X").f;
            direction.y = soc.data.GetField("Y").f;
        });

        soc.On("Input Swipe", (soc) =>
        {
            swipe = (string)soc.data.GetField("Swipe Registered");
        });
    }
Beispiel #23
0
 // Start is called before the first frame update
 void Start()
 {
     socket = GetComponent <SocketIOComponent>();
     socket.On("open", OnConnected);
     socket.On("spawn", OnSpawned);
     socket.On("move", OnMove);
 }
Beispiel #24
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();

        socket.On("boop", TestBoop);
        socket.On("error", TestError);
        socket.On("close", TestClose);
        socket.On("broadMSG", TestBreadMSG);

        // JSON 전송방법 1
        data.Add("hi", "Node Server");
        data.Add("hello", "World");
        jdata1 = new JSONObject(data);

        // JSON 전송방법 2
        JSONData myObject = new JSONData();

        myObject.level       = 1;
        myObject.timeElapsed = 45.5f;
        myObject.playerName  = "lee dong yun";
        string jsonData = JsonUtility.ToJson(myObject);

        jdata2 = new JSONObject(jsonData);

        StartCoroutine(BeepBoop());
    }
    // Start is called before the first frame update
    void Start()
    {
        //Get terrain size
        var terrainData = terrain.terrainData;

        _terrainWidth  = terrainData.size.x;
        _terrainLength = terrainData.size.z;

        //Get terrain position
        var position = terrain.transform.position;

        _xTerrainPos = position.x;
        _zTerrainPos = position.z;

        GameObject go = GameObject.Find("SocketIO");

        _socket      = go.GetComponent <SocketIOComponent>();
        _gameService = new GameService(_socket);

        SetNameHandler();
        _socket.On(OpenEvent, OpenHandler);
        _socket.On(PlayerEvent, HandlePlayer);
        _socket.On(ConnectedPlayerEvent, HandleOpen);
        _socket.On(ExistAnotherPlayerEvent, HandleExistAnotherPlayer);
        /*_socket.On(NpcEvent, HandleNpc);*/
        _socket.On("expand", HandleExpand);

        StartCoroutine("ExistExecuteEvents");
    }
    void Start()
    {
        rb    = GetComponent <Rigidbody>();
        euler = transform.eulerAngles;

        GameObject go = GameObject.Find("SocketIO");

        if (go == null)
        {
            Debug.Log("go is null: " + go);
        }
        else
        {
            Debug.Log("go is not null: " + go);
        }

        socket = go.GetComponent <SocketIOComponent>();

        if (androidEnabled)
        {
            socket.On("open", TestOpen);
            socket.On("nodeToUnity", TestBoop);
            socket.On("error", TestError);
            socket.On("close", TestClose);

            //StartCoroutine("BeepBoop");
        }
    }
Beispiel #27
0
 private void Start()
 {
     SocketIO      = GameObject.Find("SetupSocketConnectionToGame").GetComponent <SocketIOComponent>();
     myJsonParaser = new JSONParser();
     SocketIO.On("currentPasswordWrong", OnPasswordWrong);
     SocketIO.On("passwordChanged", OnPasswordChanged);
 }
Beispiel #28
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        team   = GameObject.FindWithTag("team");


        socket.Emit("disconnect", JSONObject.CreateStringObject(team.GetComponent <TeamInfo>().name));

        socket.On("onDisconnectTeamResponse", (E) =>
        {
            Debug.Log(E.data.ToString() + "en el desconectar");
            TeamCollection[] equipo = JsonHelper.FromJson <TeamCollection>(E.data.ToString());

            llenarCampos(equipo.Length, equipo);
            Navegar navegar = new Navegar();
            navegar.navegarSala();
        });

        socket.On("onStartGame", (E) =>
        {
            StartCoroutine(Camera.main.GetComponent <CountDownController>().CountDownStart());
        });



        socket.On("getTeams", (E) =>
        {
            Debug.Log(E.data.ToString() + "en el get teams");
            TeamCollection[] equipo = JsonHelper.FromJson <TeamCollection>(E.data.ToString());
            llenarCampos(equipo.Length, equipo);
        });
    }
Beispiel #29
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();

        socket.On("open", TestOpen);

        socket.On("boop", (SocketIOEvent e) => {
            Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data));
            data["email"] = "*****@*****.**";
            data["pass"]  = "******";
            socket.Emit("user:login", new JSONObject(data));
            Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data));
        });

        socket.On("receive", (SocketIOEvent e) => {
            Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data));
            data["email"] = "*****@*****.**";
            data["pass"]  = "******";
            //socket.Emit("user:login", new JSONObject(data));
            Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data));
        });

        socket.On("error", TestError);
        socket.On("close", TestClose);

        StartCoroutine("BeepBoop");
    }
Beispiel #30
0
 public void Start()
 {
     socket  = GetComponent <SocketIOComponent>();
     message = new JSONObject();
     socket.On("connectionEstablished", onConnectionEstabilished);
     socket.On("doAction", onActions);
 }