Exemple #1
1
    public void getAcceleration(SocketIOEvent e)
    {
        //Debug.Log("Acceleration X: " +  e.data["aX"].ToString());
        //Debug.Log("Acceleration Y: " +  e.data["aY"].ToString());
        //Debug.Log("Acceleration Z: " +  e.data["aZ"].ToString());

        currentAx = float.Parse((e.data["aX"]).ToString());
        currentAy = float.Parse((e.data["aY"]).ToString());;
        //Probably most important value
        currentAz = float.Parse((e.data["aZ"]).ToString());

        if (currentAx > 0.5 || currentAx < -0.5) {
            ogAx = currentAx;
        }
        else {
            ogAx = 0;
        }
        if (currentAy > 0.5 || currentAy < -0.5) {
            ogAy = currentAy;
        }
        else {
            ogAy = 0;
        }
        if (currentAz > 0.5 || currentAz < -0.5) {
            ogAz = currentAz;
        } else {
            ogAz = 0;
        }
    }
 public void CloseHandler(SocketIOEvent e)
 {
     if(isServer){
         Debug.Log("[SocketIO] Close received: " + e.name + " " + e.data);
         // socketIOInputEvents.ServerDisconnect();
     }
 }
    private void ReceiveRoomList(SocketIO.SocketIOEvent ev)
    {
        if (GameObject.activeInHierarchy == false)
        {
            return;
        }
        this.m_RoomLoaded = true;
        var receiveRooms = ev.data.GetField("rooms").list;

        for (int i = 0; i < this.m_Rooms.Count; i++)
        {
            this.m_Rooms[i].gameObject.SetActive(false);
        }
        for (int i = 0; i < receiveRooms.Count; i++)
        {
            if (i >= this.m_Rooms.Count)
            {
                var roomInstantiate = GameObject.Instantiate(this.m_RoomItemPrefab);
                roomInstantiate.transform.SetParent(this.m_RoomContent.transform);
                roomInstantiate.transform.localPosition = Vector3.zero;
                roomInstantiate.transform.localRotation = Quaternion.identity;
                roomInstantiate.transform.localScale    = Vector3.one;
                this.m_Rooms.Add(roomInstantiate);
            }
            var room        = receiveRooms[i];
            var roomName    = room.GetField("roomName").ToString().Replace("\"", "");
            var players     = int.Parse(room.GetField("players").ToString());
            var maxPlayers  = room.GetField("maxPlayers").ToString().Replace("\"", "");
            var roomDisplay = string.Format("{0}: {1}/{2}", roomName, players, maxPlayers);
            this.m_Rooms[i].Setup(roomName, players, roomDisplay, this.JoinRoom);
            this.m_Rooms[i].SetEnable(true);
            this.m_Rooms[i].gameObject.SetActive(true);
        }
    }
Exemple #4
0
	void loginSuccess(SocketIOEvent e)
	{
		PlayerName = myscript.jsontoString( e.data [0].ToString (),"\"");
		Player.Name = PlayerName;
		Player.ID = myscript.jsontoString(e.data [1].ToString (),"\"");
		Player.MyColor = myscript.jsontoString(e.data [3].ToString (),"\"");
		Debug.Log ("Your ID : " + PlayerName);
		Debug.Log ("Your Position : " + e.data [2].ToString ());

		if (myscript.jsontoString(e.data [2].ToString (),"\"") == "null") 
		{
			Player.startPosition = Vector3.zero;

		} else 
		{
			Player.startPosition = myscript.StringtoVector3(myscript.jsontoString(e.data [2].ToString (),"\""));
		}

		Player.gameObject.transform.position = Player.startPosition;

		Login = false;
		Application.LoadLevel(1);

                                     
	}
    private void OnReceiveNewWord(SocketIO.SocketIOEvent ev)
    {
        // ANSWER
        // var lastIndex = int.Parse (ev.data.GetField("lastIndex").ToString());
        // GAME TURN
        var currentTurn = int.Parse(ev.data.GetField("turnIndex").ToString());

        this.SetCurrenTurn(currentTurn);
        this.m_YourTurnText.text = "YOUR TURN";
        this.m_WordInputString   = string.Empty;
        // CURRENT CHARACTER
        var currentPrefix = ev.data.GetField("nextCharacter").ToString().Replace("\"", string.Empty);

        this.SetCurrentCharacter(currentPrefix);
        // PLAYER
        var playerAvatar = int.Parse(ev.data.GetField("playerAvatar").ToString());
        var frame        = int.Parse(ev.data.GetField("playerFrame").ToString());
        // WORD LIST
        var displayWord = ev.data.GetField("displayWord").ToString().Replace("\"", string.Empty);
        var item        = this.DisplayAWord(frame, playerAvatar, displayWord);

        this.m_WordLists.Add(item);
        // GOLD COST
        var goldCost = int.Parse(ev.data.GetField("goldCost").ToString());

        this.m_GoldCostText.text = string.Format("-{0}", goldCost);
        // UI
        this.m_SuggestButton.interactable = true;
        // EVENTS
        CRootManager.Instance.StopCoroutine(this.HandleUpdateWordScrollRect());
        CRootManager.Instance.StartCoroutine(this.HandleUpdateWordScrollRect());
        CSoundManager.Instance.Play("sfx_new_word");
    }
Exemple #6
0
    void OnEnemies(SocketIO.SocketIOEvent socketIOEvent)
    {
        EnemiesJSON  enemiesJSON = EnemiesJSON.CreateFromJSON(socketIOEvent.data.ToString());
        EnemySpawner es          = GetComponent <EnemySpawner>();

        es.SpawnEnemies(enemiesJSON);
    }
Exemple #7
0
    void CheckID(SocketIOEvent e)
    {
        //socket情報抽出
        string id = "__"+e.data.GetField("id").str;
        string direction = e.data.GetField("direction").str;
        Debug.Log(id);
        Debug.Log(direction);

        //送られてきたIDの対象を特定
        GameObject target = GameObject.Find(id);
        plycon = target.GetComponent<PlayerController>();

        //対象のオブジェクトに、特定の方向に動かす命令
        switch(direction){
            case "up":
                plycon.MoveUp();
                break;
            case "left":
                plycon.MoveLeft();
                break;
            case "right":
                plycon.MoveRight();
                break;
            case "down":
                plycon.MoveDown();
                break;
        }
    }
Exemple #8
0
    public TimeLeftSync(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
        : base(e, socket, networkManager)
    {
        timeLeftInSeconds = int.Parse(data["timeLeftInSeconds"]);

        HandlePacket();
    }
Exemple #9
0
 public void Call(SocketIO.SocketIOEvent param0)
 {
     func.BeginPCall();
     func.PushObject(param0);
     func.PCall();
     func.EndPCall();
 }
    public void OnMessage(SocketIOEvent e)
    {
        Debug.Log("[SocketIO] OnMessage : " + e.name + " " + e.data);
        Debug.Log("hello");

        dataF = e.data.list[0].f;
    }
Exemple #11
0
    public void GameOverResponse(SocketIO.SocketIOEvent E)
    {
        PlayerResult rr = JsonConvert.DeserializeObject <PlayerResult>(E.data.ToString());

        gameOver.SetActive(true);
        gameOver.transform.GetChild(1).GetComponent <Text>().text = rr.Player.Name + " wins";
    }
    void setIntensity(SocketIO.SocketIOEvent ev)
    {
        //json = JsonUtility.FromJson<data>(ev.data);
        string amountstr = string.Format("{0}", ev.data);

        intensity = massageSocket(amountstr);
    }
Exemple #13
0
 public void PlayerMove(SocketIOEvent e)
 {
     Debug.Log("Player " + myscript.jsontoString (e.data [0].ToString (), "\"") + " : " + myscript.jsontoString (e.data [1].ToString (), "\"") );
     GameObject newObj = GameObject.Find (myscript.jsontoString (e.data [0].ToString (), "\""));
     Debug.Log(newObj);
     newObj.GetComponent<OtherPlayer>().currentPosition = myscript.StringtoVector3(myscript.jsontoString(e.data [1].ToString (),"\""));
 }
	public void playerEnter(SocketIOEvent e)
	{
		string side = string.Format ("{0}", e.data ["side"]);
		string character = string.Format ("{0}", e.data ["character"]);
		string holdingItem = string.Format ("{0}", e.data ["holdingItem"]);

		if (holdingItem.Contains ("none")) {

			Debug.Log ("NOITEMCALLchar: " + character + "  tempSide: " + side);
			callingCharAnims.GetComponent<CallingCharAnimations> ().callAnimation (character, side);


		} else {
			Debug.Log ("char: " + character + "  tempSide: " + side + "  holdingItem :" + holdingItem);
			
			string tempItem = "chili";
			
			callingCharAnims.GetComponent<CallingCharAnimations> ().callAnimationWithItem (character, side, holdingItem);
			
			
			if (tempItem.Contains ("bramble")) {
				
			}

		}

	}
Exemple #15
0
    private void moveCallback(SocketIOEvent obj)
    {
        Debug.Log(string.Format("[name: {0}, data: {1}]", obj.name, obj.data));

        var playerId = obj.data["player"].str;
        var move = obj.data["move"];
        var distance = obj.data["distance"].n;
        var direction = int.Parse(move.str);

        _gameboard.SetActivePlayer(playerId);

        // -1 is a failed move
        if (distance < 0)
            _gameboard.HandlePlayerMove(playerId, direction, false);

        // 1 is a successful move
        if (distance > 0)
        {
            _gameboard.HandlePlayerMove(playerId, direction, true);
        }
        
        // 0 is game over
        if (distance == 0)
        {
            _gameboard.HandleGameOver();
        }
    }
Exemple #16
0
 public void RemovePlayer(SocketIOEvent e)
 {
     string id = "__"+e.data.GetField("id").str;
     //        Debug.Log("goodby "+id);
     GameObject obj = GameObject.Find(id);
     Destroy(obj);
 }
    public HiderCountSync(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
        : base(e, socket, networkManager)
    {
        hidersLeft = int.Parse(data["hiderAmount"]);

        HandlePacket();
    }
    private void OnStartGame(SocketIO.SocketIOEvent ev)
    {
        // GAME TURN
        var firstTurn = int.Parse(ev.data.GetField("firstPlayerIndex").ToString());

        this.SetCurrenTurn(firstTurn);
        // PREFIX
        var currentPrefix = ev.data.GetField("firstCharacter").ToString().Replace("\"", string.Empty);

        this.SetCurrentCharacter(currentPrefix);
        // AVATAR
        var room    = ev.data.GetField("roomInfo");
        var players = room.GetField("players").list;

        for (int i = 0; i < players.Count; i++)
        {
            var playerAvatar = int.Parse(players[i].GetField("playerAvatar").ToString());
            this.m_PlayerDisplayItems[i].Setup(playerAvatar);
        }
        // GOLD COST
        var goldCost = int.Parse(ev.data.GetField("goldCost").ToString());

        this.m_GoldCostText.text = string.Format("-{0}", goldCost);
        CRootManager.Instance.BackTo("MainGamePanel");
        CSoundManager.Instance.Play("sfx_new_word");
    }
Exemple #19
0
	public void ToClient(SocketIOEvent e){
		Debug.Log(string.Format("[name: {0}, data: {1}]", e.name, e.data));
		Debug.Log (e.data ["msg"].ToString().Trim());
		playercontrolobject = GameObject.Find ("__GameManager");
		_PlayerControl = playercontrolobject.GetComponent<PlayerControl> ();
		//_PlayerControl.TakeInput (e.data ["msg"].ToString().Trim('"'));
	}
Exemple #20
0
    /// <summary>
    /// Handles a player dying, this will eventually play an animation and remove the player from the scene.
    /// </summary>
    /// <param name="e">The event we need to handle</param>
    /// <param name="socket">The socket</param>
    /// <param name="networkManager">The network manager</param>
    public PlayerDeath(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
        : base(e, socket, networkManager)
    {
        this.clientId = data["clientId"];

        HandlePacket();
    }
Exemple #21
0
    void OnOtherPlayerConnected(SocketIO.SocketIOEvent socketIOEvent)
    {
        print("Someone else joined");
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Vector3    position = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]);
        Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);
        GameObject o        = GameObject.Find(userJSON.name) as GameObject;

        if (o != null)
        {
            return;
        }
        GameObject p = Instantiate(player, position, rotation) as GameObject;
        //We are setting up their other fields name and if they are local
        PlayerController pc         = p.GetComponent <PlayerController>();
        Transform        t          = p.transform.Find("HealthBarCanvas");
        Transform        t1         = t.transform.Find("PlayerName");
        Text             playerName = t1.GetComponent <Text>();

        playerName.text  = userJSON.name;
        pc.isLocalPlayer = false;
        p.name           = userJSON.name;
        // we also need to set the health
        Health h = p.GetComponent <Health>();

        h.currentHealth = userJSON.health;
        h.OnChangeHealth();
    }
    private void OnPlayAvariable(SocketIOEvent evt )
    {
        UserData player1 = CheckPlayer(evt.data.GetField("player1"));
        UserData player2 = CheckPlayer(evt.data.GetField("player2"));

        if( GameManager.Instance.userData.ID == player1.ID ){
            Debug.Log("Player1 Ready!!");
            GameManager.Instance.player = GameManager.Player.player1;

            JSONObject ready = new JSONObject();
            ready.AddField("id", player1.ID );
            NetworkManager.Instance.Socket.Emit("READY", ready);
        }else{
            if( GameManager.Instance.userData.ID == player2.ID ){
                Debug.Log("Player2 Ready!!");
                GameManager.Instance.player = GameManager.Player.player2;
                JSONObject ready = new JSONObject();
                ready.AddField("id", player1.ID );
                NetworkManager.Instance.Socket.Emit("READY", ready);
            }else{
                Debug.Log("JUST WATCH!!");
                GameManager.Instance.player = GameManager.Player.guest;
            }
        }

        oldText.text 		= player1.UserName;
        friendText.text 	= player2.UserName;
    }
Exemple #23
0
    /* Player
     */

    /// <summary>
    /// deze funcite is voor je moeder
    /// </summary>
    /// <param name="e"></param>
    private void PlayerJoin(SocketIO.SocketIOEvent e)
    {
        string eventAsString             = "" + e.data;
        Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(eventAsString);

        if (data["clientId"] == this.socket.sid & !joined)
        {
            joined = true;

            GameObject newPlayer = Instantiate(playerPrefabs[int.Parse(data["playerTypeId"])],
                                               new Vector3(float.Parse(data["x"]), float.Parse(data["y"])),
                                               Quaternion.Euler(0, float.Parse(data["rotY"]), float.Parse(data["rotZ"])));

            MultiPlayerPlayer player = newPlayer.GetComponent <MultiPlayerPlayer>();
            player.Init(this, data["clientId"], true);
            players.Add(player);
            cam.SetPlayer(newPlayer);
        }
        else if (data["clientId"] != this.socket.sid)
        {
            GameObject newPlayer = Instantiate(playerPrefabs[int.Parse(data["playerTypeId"])],
                                               new Vector3(float.Parse(data["x"]), float.Parse(data["y"])),
                                               Quaternion.Euler(0, float.Parse(data["rotY"]), float.Parse(data["rotZ"])));

            MultiPlayerPlayer player = newPlayer.GetComponent <MultiPlayerPlayer>();
            player.Init(this, data["clientId"], false);
            players.Add(player);
        }
    }
 public void ackLeaveRoom(SocketIOEvent e)
 {
     Debug.Log ("방 퇴장");
     //방을 퇴장하면 룸 채팅창을 깨끗히 비운다.
     GameObject.Find ("RoomChatField").GetComponent<Text> ().text = "";
     GameObject.Find ("Canvas").GetComponent<MenuManager> ().ShowMenu (GameObject.Find ("Lobby").GetComponent<Menu>());
 }
    public void SetDataToFields(SocketIO.SocketIOEvent dataLB)
    {
        foreach (JSONObject board in dataLB.data["boards"].list)
        {
            String boardTitle = board["title"].str;

            Board b = new Board();
            b.boardName = boardTitle;
            b.players   = new List <Player>();

            foreach (JSONObject player in board["players"].list)
            {
                String playerNick = player["nick"].str;
                int    playerVal  = (int)player["value"].n;

                Player p = new Player();
                p.nick  = playerNick;
                p.score = playerVal;

                b.players.Add(p);
            }
            boards.Add(b);
        }
        LoadCurrentBoard(0);
    }
 private void PlayerJoinServer(SocketIO.SocketIOEvent e)
 {
     if (!joined)
     {
         new PlayerJoinBuilder(socket, this);
     }
 }
 public void OnAcceleration(SocketIOEvent e)
 {
     Debug.Log(e.data);
     JSONNode node = JSON.Parse(e.data + "");
     acceleration = node["acceleration"].AsFloat;
     //Debug.Log(json.GetField("acceleration"));
      
 }
 private void OnRecketEnemyMove(SocketIOEvent evt )
 {
     if( GameManager.Instance.player == GameManager.Player.player1 ){
         racketPlayer2.FromBoradcastVelocity(Converter.JsonToVecter2(Converter.JsonToString(evt.data.GetField("position").ToString())));
     }else if( GameManager.Instance.player == GameManager.Player.player2 ){
         racketPlayer1.FromBoradcastVelocity(Converter.JsonToVecter2(Converter.JsonToString(evt.data.GetField("position").ToString())));
     }
 }
    private void OnCountDownAnswerTimer(SocketIO.SocketIOEvent ev)
    {
        var answerTimer = int.Parse(ev.data.GetField("answerTimer").ToString());
        var minute      = answerTimer / 60;
        var second      = answerTimer % 60;

        this.m_YourTurnText.text = string.Format("YOUR TURN\n{0}:{1}", minute.ToString("d2"), second.ToString("d2"));
    }
    /// <summary>
    /// Handles the quit packet mainly by removing the corresponding player object from the scene.
    /// </summary>
    /// <param name="e">The event we need to handle</param>
    /// <param name="socket">The socket</param>
    /// <param name="networkManager">The networking manager</param>
    public PlayerQuit(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
        : base(e, socket, networkManager)
    {
        this.player = networkManager.GetPlayerFromClientId(data["socketId"]);
        networkManager.RemoveOnlinePlayer(player);

        HandlePacket();
    }
    public PlayerMessageHandler(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
        : base(e, socket, networkManager)
    {
        this.messageType = (MessageTypes)Enum.GetValues(typeof(MessageTypes)).GetValue(int.Parse(data["messageType"]));
        this.message     = data["message"];

        HandlePacket();
    }
 void Start()
 {
     json = new JSONObject();
     json.AddField("steering_angle", "0");
     json.AddField("throttle", "1");
     json.AddField("vert_angle", "0");
     socketEvent = new SocketIO.SocketIOEvent("OnSteer", json);
 }
    public void Bet(SocketIOEvent e)
    {
        Debug.Log("Bet recieved: " + e.name + " " + e.data);

        int amount = 0;
        e.data.GetField(ref amount, "amount");
        gameMananger.updateOpponentBet(amount);
    }
    public void OnSteering(SocketIOEvent e)
    {
        Debug.Log(e.data);
        JSONNode node = JSON.Parse(e.data + "");
        steeringAngle = node["angle"].AsFloat;
        //Debug.Log(json.GetField("acceleration"));

    }
 private void OnUserDisconnected(SocketIOEvent evt )
 {
     UserData  usrdata = new UserData();
     usrdata.ID = Converter.JsonToString(evt.data.GetField("id").ToString());
     usrdata.UserName = Converter.JsonToString(evt.data.GetField("name").ToString());
     _usersData.Remove(usrdata);
     usrdata = null;
 }
    private void OnCountDownTimer(SocketIO.SocketIOEvent ev)
    {
        var roomTimer = int.Parse(ev.data.GetField("roomTimer").ToString());
        var minute    = roomTimer / 60;
        var second    = roomTimer % 60;

        this.m_RoomTimerText.text = string.Format("{0}:{1}", minute.ToString("d2"), second.ToString("d2"));
    }
Exemple #37
0
 public void loginSuccess(SocketIOEvent e)
 {
     Debug.Log("Login Exitoso");
     GameObject script = GameObject.Find("Cube");
     Debug.Log(script);
     Destroy(script);
     Application.LoadLevel("Juego");
 }
Exemple #38
0
    void OnOtherPlayerDisconnect(SocketIO.SocketIOEvent socketIOEvent)
    {
        print("user disconnected");
        string   data     = socketIOEvent.data.ToString();
        UserJSON userJSON = UserJSON.CreateFromJSON(data);

        Destroy(GameObject.Find(userJSON.name));
    }
    public SyncDayNightCycle(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
        : base(e, socket, networkManager)
    {
        this.time             = PacketUtils.FromPacketString(data["time"]);
        this.secondsPerSecond = PacketUtils.FromPacketString(data["secondsPerSecond"]);

        this.HandlePacket();
    }
    private void StatusUpdate(SocketIO.SocketIOEvent e)
    {
        string eventAsString             = "" + e.data;
        Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(eventAsString);

        this.status     = Status.GetById(int.Parse(data["status"]));
        statusText.text = status.Name;
    }
    private void OnAppendagePositionUpdate(SocketIO.SocketIOEvent e)
    {
        string eventAsString             = "" + e.data;
        Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(eventAsString);

        Vector3 pos = new Vector3(float.Parse(data["x"]), float.Parse(data["y"]), float.Parse(data["z"]));

        ragdollController.UpdateApandages(int.Parse(data["id"]), pos);
    }
Exemple #42
0
    private void messageResponse(SocketIO.SocketIOEvent E)
    {
        MessageResult result = JsonConvert.DeserializeObject <MessageResult>(E.data.ToString());

        if (result.State)
        {
            message = result.msg;
        }
    }
    private void Redirect(SocketIO.SocketIOEvent e)
    {
        string eventAsString             = "" + e.data;
        Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(eventAsString);

        socket.ReConnect(data["port"]);
        //Start registering new data
        this.Start();
    }
    public void HandleGame(SocketIOEvent e)
    {
        Debug.Log("[SocketIO] " + e.name + " received: " + e.data);
        gameData = e.data;

        string state = e.data.GetField("state").GetField("name").str; // The game's state
        Debug.Log ("Sending trigger " + state);
        GetComponent<Animator>().SetTrigger(state);
    }
    public PlayerSeesSeekerHandler(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager, Seeker seeker)
        : base(e, socket, networkManager)
    {
        this.seeker    = seeker;
        this.hider     = (Hider)networkManager.GetPlayerFromClientId(data["socketId"]);
        this.isVisible = bool.Parse(data["isVisible"]);

        HandlePacket();
    }
    private void OnUserConnected( SocketIOEvent evt )
    {
        UserData  usrdata = new UserData();
        usrdata.ID = Converter.JsonToString(evt.data.GetField("id").ToString());
        usrdata.UserName = Converter.JsonToString(evt.data.GetField("name").ToString());
        _usersData.Add(usrdata);

        Debug.Log("Counter User : "+_usersData.Count);
    }
    public void LoginSuccess(SocketIOEvent e)
    {
        Debug.Log("LOGIN SUCCESS: " + e.name + " " + e.data);
        PlayerPrefs.SetString ("username", username_text.text);
        PlayerPrefs.SetString ("password", password_text.text);

        StatusSyncButton.gameObject.SetActive (true);
        CharacterSyncButton.gameObject.SetActive (true);
        login_button.gameObject.SetActive (false);
    }
    void OnUserConnected(SocketIOEvent obj)
    {
        Debug.Log( "all user born on this client" );

        GameObject otherPlater =  GameObject.Instantiate( playerGameObj.gameObject, playerGameObj.position, Quaternion.identity ) as GameObject;
        Player otherPlayerCom = otherPlater.GetComponent<Player>();
        otherPlayerCom.playerName = JsonToString(obj.data.GetField("name").ToString(), "\"");
        otherPlater.transform.position =  JsonToVecter3( JsonToString(obj.data.GetField("position").ToString(), "\"") );
        otherPlayerCom.id = JsonToString(obj.data.GetField("id").ToString(), "\"");
    }
Exemple #49
0
        void UpdatePlayersDisplayView(SocketIOEvent ev)
        {
            JSONObject players = ev.data["players"];

              transform.Find("PlayersDisplay")
            .GetComponent<PlayersDisplay>()
            .UpdatePlayersView(players);

              Show();
        }
 private void ReceiveMessageError(SocketIO.SocketIOEvent ev)
 {
     if (this.GameObject.activeInHierarchy == false)
     {
         return;
     }
     // UI
     this.m_SubmitButton.interactable = true;
     CSocketManager.Instance.Invoke("ShowLastErrorPopup", 0f);
 }
Exemple #51
0
    public PacketHandler(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
    {
        string eventAsString             = "" + e.data;
        Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(eventAsString);

        this.e              = e;
        this.data           = data;
        this.socket         = socket;
        this.networkManager = networkManager;
    }
    /* Direct responses
     */
    private void OnConnection(SocketIO.SocketIOEvent e)
    {
        if (!joined)
        {
            Dictionary <string, string> data = new Dictionary <string, string>();
            data["connectionType"] = connectionType;

            socket.Emit("join", new JSONObject(data));
        }
    }
Exemple #53
0
    private void FindMovesResponse(SocketIO.SocketIOEvent E)
    {
        print(E.data.ToString());
        MovesResult result = JsonConvert.DeserializeObject <MovesResult>(E.data.ToString());

        if (result.State)
        {
            selectedPiece.GetComponent <Piece>().FindAllPossibleMoves(result.Paths, pieces, grid, highLightMaterial1, highLightMaterial2, highLightMaterial4);
        }
    }
    public void ackGlobalChat(SocketIOEvent e)
    {
        string id = e.data.GetField ("id").str;
        string input = e.data.GetField ("input").str;

        if (input != "") {
            GameObject chatField = GameObject.Find("ChatField");
            chatField.GetComponent<Text> ().text += id+" : "+input+"\n";
            chatField.GetComponent<RectTransform>().sizeDelta = new Vector2(chatField.GetComponent<RectTransform>().sizeDelta.x,chatField.GetComponent<RectTransform>().sizeDelta.y+17);
        }
    }
 //called by our socket event - mapped to a specific event in this case
 public void OnSocketConnect(SocketIOEvent e)
 {
     //cool. we connected to the server and got the event data
     Debug.Log("[SocketIO] Open received: " + e.name + " " + e.data);
     //update the UI
     status_text.text = "status : CONNECTED!!!!";
     //lets send a message to the server and let know who's boss
     JSONObject json = new JSONObject(JSONObject.Type.OBJECT);
     json.AddField("data", "I'm unity, bitch");
     socket.Emit ("update_from_client", json);
 }
Exemple #56
0
    public void TestMessage(SocketIOEvent e)
    {
        Debug.Log (string.Format ("[name: {0}, data: {1}]", e.name, e.data));

        switch(e.data.GetField("message").str)
        {
            case "first": generate(first_note); break;
            case "second": generate(second_note);break;
            case "third": generate(third_note);break;
        }
    }
 private void OnUserSignUped(SocketIOEvent evt )
 {
     Debug.Log("ID = "+evt.data.GetField("id").ToString());
     Debug.Log("NAME = "+evt.data.GetField("name").ToString());
     UserData usrData = new UserData();
     usrData.ID = Converter.JsonToString(evt.data.GetField("id").ToString());
     usrData.UserName = Converter.JsonToString(evt.data.GetField("name").ToString());
     usrData.isSignUp = true;
     GameManager.Instance.userData = usrData;
     SceneManager.LoadScene("Main");
 }
	public void OnPresidential(SocketIOEvent e)
	{
		Debug.Log ("presidential");

		var rate = new ParticleSystem.MinMaxCurve();
		rate.constantMax = 1000f;
		em1.rate = rate;

		Invoke("ResetParticleRate1", 1f);

			
	}
	public void TestBoop(SocketIOEvent e)
	{
		Debug.Log("[SocketIO] Boop received: " + e.name + " " + e.data);

		if (e.data == null) { return; }

		Debug.Log(
			"#####################################################" +
			"THIS: " + e.data.GetField("this").str +
			"#####################################################"
		);
	}
	//This function is called when the server responds to Connection Test. 
	//The client stops pinging the server and enables the main Game Logic. 
	public void NetTest(SocketIOEvent socketEvent) {
		//Process Data from the Server.
		isConnected = true;
		string data = socketEvent.data.ToString ();
		Debug.Log ("Response from server: " + data);
		StopCoroutine ("ConnectionTest");
		socket.Off ("ConnectionTest", NetTest);
		//Enable Game Logic in the Scene. 
		//GameObject go = GameObject.FindGameObjectWithTag ("GameController");
		//gameManager = go.GetComponent<GameManager> ();
		//((MonoBehaviour)gameManager).enabled = true;
		socket.Emit ("JoinRoom");
	}