public void Start()
 {
     socket = gameObject.GetComponent<SocketIOComponent>();
     socket.On("smarttouch-start", SmartTouch);
     socket.On("smarttouch-end", SmartTouch);
     checkJSON.readJson();
 }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     //Start listening to all the server events
     socket.On("redirectToServer", Redirect);
     socket.On("connect", OnConnection);
     socket.On("statusUpdate", StatusUpdate);
 }
Esempio n. 3
0
	//GameManager gameManager;

	void Start() {
		//Makes this object stay throughout the entire scene
		if (dontDestroyOnLoad) {
			DontDestroyOnLoad (transform.gameObject);
		}
		network = FindObjectOfType<NetworkManager> ();

		//Find the Socket Component in the Game Scene
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		//Register what kind of messages the client receives
		socket.On ("ConnectionTest", NetTest);
		socket.On ("JoinRoom", NetLogin);
		//socket.On ("Response", NetResponse);
		socket.Connect ();

		//Start Connection Test
		if (socket.IsConnected) {
			//Debug.Log ("Connected to Server!");
			StartCoroutine("ConnectionTest");
		} else {
			Debug.Log ("Not Connected...");
		}

	}
Esempio n. 4
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open",Opend);
        socket.On("power",PowerReact);
    }
Esempio n. 5
0
	void Start () {
		DontDestroyOnLoad (gameObject);
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		socket.On ("connection", Connection);
		socket.On("loginconfirm", LoginConfirm);
	}
Esempio n. 6
0
    // Use this for initialization
    void Start ()
	{
	    _gameboard = FindObjectOfType<Gameboard>();

        GameObject go = GameObject.Find("SocketIO");
        _socket = go.GetComponent<SocketIOComponent>();
        _socket.On("login", connectCallback);
        _socket.On("move", moveCallback);
        Debug.Log("Connecting");
    }
Esempio n. 7
0
	void Start () 
	{
		Name = " ";
		DontDestroyOnLoad (gameObject);
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		socket.On("error", ServerError);
		socket.On("close", ServerClose);
		transform.position = startPosition;
		rend = GetComponent<Renderer>();
	}
Esempio n. 8
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        //新しくログインしてきたら、CreateNewを起動
        socket.On("new_player",CreateNewPlayer);

        //誰かがページを離れたら、オブジェクトが消える。
        socket.On("player_exit",RemovePlayer);
    }
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open", TestOpen);
        socket.On("message",OnMessage);
        socket.On("welcome",OnWelcome);
        socket.On("error", TestError);
        socket.On("close", TestClose);
    }
Esempio n. 10
0
	// Use this for initialization
	void Start () {
		//ws://localhost:4567/socket.io/?EIO=4&transport=websocket
		//GameObject go = GameObject.Find("SocketIO");
		socket = GameObject.FindObjectOfType<SocketIOComponent>();
		//socket.Connect ();

		socket.On("open", OnSocketOpen);
		socket.On("error", OnSocketError);
		socket.On("chat message", ChatMessage);

		//StartCoroutine(TestCoroutine());
	}
Esempio n. 11
0
	public void Start()
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		socket.On("open", TestOpen);
		socket.On("boop", TestBoop);
		socket.On("error", TestError);
		socket.On("close", TestClose);
		
		StartCoroutine("BeepBoop");
	}
	// Use this for initialization
	void Start () {
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		Debug.Log ("Adding callbacks");
		socket.On("connect", Connect);
		socket.On("updateBlob", UpdateUser);
		socket.On("newBlob", AddUser);
		socket.On ("removeBlob", DeleteUser);

		socket.Connect ();

	}
Esempio n. 13
0
    void StartWebsocket()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();


        socket.On("acceleration", OnAcceleration);
        socket.On("steering", OnSteering);
        //socket.On("open", TestOpen);
        /*socket.On("error", TestError);
        socket.On("close", TestClose);*/

    }
    void Start()
    {
        io = GetComponent <SocketIO.SocketIOComponent>();
        io.On("NewPlayer", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data   = e.data;
            string playerID   = getField(data, "playerID");
            string playerName = getField(data, "playerName");
            createNewPlayer(playerID, playerName);
        });
        io.On("ButtonDown", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data      = e.data;
            string playerID      = getField(data, "playerID");
            string buttonPressed = getField(data, "button");

            player foundPlayer = getPlayer(playerID);
            Vector3 moveDir    = new Vector3(0f, 0f, 0f);
            Debug.Log(playerID + " pressed " + buttonPressed);
            switch (buttonPressed.ToString())
            {
            case "up":
                moveDir = new Vector3(0f, 1f, 0f);
                foundPlayer.setAimDirection("up");
                foundPlayer.move(moveDir);
                break;

            case "down":
                moveDir = new Vector3(0f, -1f, 0f);
                foundPlayer.setAimDirection("down");
                foundPlayer.move(moveDir);
                break;

            case "left":
                moveDir = new Vector3(-1f, 0f, 0f);
                foundPlayer.setAimDirection("left");
                foundPlayer.move(moveDir);
                break;

            case "right":
                moveDir = new Vector3(1f, 0f, 0f);
                foundPlayer.setAimDirection("right");
                foundPlayer.move(moveDir);
                break;

            case "fire":
                foundPlayer.FireWeapon(1);
                break;
            }
        });
    }
	public void Start() 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
        
        txt = this.gameObject.GetComponent<Text>(); 

		socket.On("sendname", OnSendName);
		socket.On("randomnumber",OnRandomNumber);
		socket.On("welcome",OnWelcome);
		socket.On("error", TestError);
		socket.On("close", TestClose);

	}
Esempio n. 16
0
	void Start () {
		DontDestroyOnLoad (transform.gameObject);
		go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();


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

		socket.On ("connection", Connection);
		socket.On("loginconfirm", LoginConfirm);
		socket.On("toclient", ToClient);
	}
Esempio n. 17
0
    // Use this for initialization
    void Start()
    {
        rb = this.GetComponent<Rigidbody> ();
        gameManager = GameObject.Find ("GameManager").GetComponent<GameManager> ();
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open", TestOpen);
        socket.On("gyro", (message) =>
        {
           JSONObject json =  message.data;
            JSONObject pitchJSON = json.GetField("beta");
            pitchAxis = float.Parse(pitchJSON.ToString())/180;
            JSONObject rollJSON = json.GetField("gamma");
            rollAxis = float.Parse(rollJSON.ToString())/180;
            JSONObject yawJSON = json.GetField("alpha");
            //yawAxis = float.Parse(yawJSON.ToString());
            //yawAxis = (yawAxis - 180) / 360;

            //Debug.Log("pitch: "+pitchAxis+" yaw: " +yawAxis +" Roll "+ rollAxis);

        });
        socket.On("speed",(message) =>
         {
            AmbientSpeed = float.Parse (message.data.GetField("speed").ToString());
        });

        socket.On("error", TestError);
        socket.On("close", TestClose);
    }
Esempio n. 18
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");

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

        socket.On("open", socketConnected);

        socket.On("do flight", doFlight);

        // transform.position = start.position;

        pos = transform.position;
        rot = transform.rotation;
        // Debug.Log("Position " + pos + " and the rotation " + rot);
    }
Esempio n. 19
0
	void Start () 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		myscript = go.GetComponent<ectScript>();
		socket.On ("talk", ChatMessage);
	}
Esempio n. 20
0
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("message", TestMessage);
    }
Esempio n. 21
0
    // Use this for initialization
    void Start()
    {
        Canvas canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
        canvas.enabled = false;

        submitBtn.onClick.AddListener(OnClickSubmit);
        NetworkManager.Instance.Init();
        _socket = NetworkManager.Instance.Socket;
        _socket.On("NET_AVARIABLE",  (SocketIOEvent evt) =>{
            canvas.enabled = true;
            Debug.Log("Net Avariable");
        });
        _socket.On("CONNECTED", OnUserSignUped);
        DontDestroyOnLoad(_socket.gameObject);
        DontDestroyOnLoad(GameManager.Instance.gameObject);
    }
Esempio n. 22
0
    public void Initialize()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.Connect();

        // Register callbacks
        socket.On("message", OnMessage);

        // Send first contact to server
        socket.Emit("connection");

        // Log in
        Dictionary<string,string> login = new Dictionary<string,string>();
        login["username"] = "******";
        socket.Emit("login", new JSONObject(login));

        /*
        client = new Client(url);

        client.Opened += OnSocketOpened;
        client.Message += SocketMessage;
        client.SocketConnectionClosed += SocketConnectionClosed;
        client.Error +=SocketError;

        client.Connect();
        */
    }
Esempio n. 23
0
	public void Start() {
		controller = GetComponent<CharacterController>();
		GameObject go = GameObject.Find("SocketIO");
		Debug.Log ("TEST TEST");
		socket = go.GetComponent<SocketIOComponent>();
		// Defining the socket callback
		socket.On ("test", (SocketIOEvent e) => {
			Debug.Log("TEST EVENT RECIEVED");
		});
		socket.On("move", (SocketIOEvent e) => {
			Debug.Log(e.data);
			nextDirection = new Vector3(0, e.data["z"].f, e.data["y"].f);
			nextRotation = e.data["x"].f * 50;
			socketInput = true;
		});
	}
Esempio n. 24
0
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        //コントローラーの命令が入ってきたら処理する。(1、idを特定し、オブジェクトを特定 2、特定したオブジェクトのコンポーネントに命令)
        socket.On("move",CheckID);
    }
Esempio n. 25
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();
        socket.On ("rgb",changeBackgroundRGB);

        _guiText = guiText.GetComponent<Text> ();
    }
Esempio n. 26
0
	void Start()
	{
		DontDestroyOnLoad (gameObject);
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		myscript = go.GetComponent<ectScript>();
		socket.On("open", ServerOpen);
		socket.On("error", ServerError);
		socket.On("close", ServerClose);
		socket.On("loginSuccess",loginSuccess);
		socket.On("loginUnsuccess",loginUnsuccess);
		socket.On("swapPlayer",swapPlayer);
		socket.On ("PlayerMove", PlayerMove);
		socket.On ("Playerdisconnected", Playerdisconnected);
		socket.On ("registersuccess", registersuccess);
		socket.On ("registerunsuccess", registerunsuccess);
	}
Esempio n. 27
0
	void Start () 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		myscript = go.GetComponent<ectScript>();
		socket.Emit("LoadMap");
		socket.On("swapAllPlayer",swapAllPlayer);

	}
Esempio n. 28
0
    // Use this for initialization
    void Start()
    {
        //socket.io approach
        //retrieve socket component
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        nodeList = new Dictionary<string, Node>(); //create a new dictionary

        socket.On("result", NodeListUpdate); //event listener waiting for the results of the node queries
    }
Esempio n. 29
0
    // Use this for initialization
    void Start()
    {
        InitUI ();

        //same old, same old
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        //register for events via coordinated string keys
        //there are some defaults, like connect, open, close
        socket.On("connect", ConnectedToServer);
    }
        public void Start()
        {
            if (autoConnect)
            {
                Connect();

                GameObject        go   = GameObject.Find("SocketIO");
                SocketIOComponent sock = (SocketIOComponent)go.GetComponent(typeof(SocketIOComponent));

                sock.On("move_forward_Utkarsh", (SocketIOEvent e) => {
                    Debug.Log("Utkarsh move forward");
                });
            }
        }
Esempio n. 31
0
 // Start is called before the first frame update
 private void Start()
 {
     //Start listening to all the server events
     socket.On("redirectToServer", Redirect);
     socket.On("CameraInput", HandleCameraInput);
     socket.On("connect", OnConnection);
     socket.On("colorUpdate", HandleQRColorUpdate);
     socket.On("mapUpdate", ReceiveMapImage);
     socket.On("appendagePositionUpdate", OnAppendagePositionUpdate);
 }
Esempio n. 32
0
 // Start is called before the first frame update
 void Start()
 {
     //Start listening to all the server events
     socket.On("redirectToServer", Redirect);
     socket.On("move", MovePlayer);
     socket.On("join", PlayerJoin);
     socket.On("quit", PlayerQuit);
     socket.On("bullet_spawn", BulletSpawn);
     socket.On("connect", PlayerJoinServer);
 }
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open", Open);
        socket.On("wait", Wait);
        socket.On("roomready", Roomready);
        socket.On("needwait", NeedWait);
        socket.On("error", Error);
        socket.On("close", Close);
    }
	public void Start() 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
        
        txt = this.gameObject.GetComponent<Text>(); 

		socket.On("sendname", OnSendName);
		socket.On("img_from_phone",OnGetImage);
		socket.On ("location",OnGetLocation);
		socket.On ("DeviceOrientation",onRotation);
		socket.On("welcome",OnWelcome);
		socket.On("error", TestError);
		socket.On("close", TestClose);

	}
	public void Start() 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		Player = GameObject.FindGameObjectWithTag("Player");
		Player_rg = Player.GetComponent<Rigidbody>();
		modify = Player.GetComponent<Modify>();
		world = GameObject.Find("WorldStartHere").GetComponent<World>();

		socket.On("open", TestOpen);
		socket.On("boop", TestBoop);
		socket.On("error", TestError);
		socket.On("close", TestClose);
//		socket.On("user_added", AddUserToWorld);
		socket.On ("user_update_position", UpdateOtherPos);
//		socket.On ("user list", AddUserToWorld);
		socket.On("map_modify", ModifyMap);
		socket.On ("set_specblock", SetSpecBlock);
		socket.On ("shotting", OtherShotting);

		StartCoroutine("BeepBoop");
//		StartCoroutine("SendPosition");
	}
	public void Start() 
	{
		ps1 = GetComponent<ParticleSystem> ();
		em1 = ps1.emission;
		ps2 = GetComponent<ParticleSystem> ();
		em2 = ps2.emission;
		ps3 = GetComponent<ParticleSystem> ();
		em3 = ps3.emission;

		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
        
        txt = this.gameObject.GetComponent<Text>(); 

		socket.On("sendname", OnSendName);
		socket.On("twitter-stream", OnRandomyNumber);
		socket.On("welcome",OnWelcome);
		socket.On("error", TestError);
		socket.On("close", TestClose);
		socket.On ("presidential", OnPresidential);
		socket.On ("migrant", OnMigrant);
		socket.On ("poverty", OnPoverty);

	}
Esempio n. 37
0
    // Start is called before the first frame update
    private void Start()
    {
        //Start listening to all the server events
        //Connection packets
        socket.On("connect", PlayerJoinServer);
        socket.On("RedirectToServer", Redirect);
        socket.On("ServerClose", ServerClosed);
        socket.On("PlayerJoin", OnPlayerJoin);
        socket.On("PlayerQuit", OnPlayerQuit);
        socket.On("PlayerMove", OnPlayerMove);
        socket.On("PlayerMoveHead", OnPlayerMoveHead);
        socket.On("PlayerTeleport", OnPlayerTeleport);
        socket.On("UpdateSeeker", OnSeekerUpdate);
        socket.On("PlayerDeath", OnPlayerDeath);
        socket.On("PropMove", OnPropMove);

        socket.On("TimeLeftSync", OnTimeLeftSync);
        socket.On("PlayerMessage", OnPlayerMessage);
        socket.On("PlayerSeesSeeker", OnPlayerSeesSeeker);
        socket.On("HiderCountSync", OnHiderCountSync);

        socket.On("SyncDayNightCycle", OnSyncDayNightCycle);
        socket.On("StartDayNightCycle", OnStartDayNightCycle);
        socket.On("StopDayNightCycle", OnStopDayNightCycle);

        PlayerMovement.localPlayerMoveEvent      += PlayerMoveServer;
        SmoothMouseLook.localPlayerHeadMoveEvent += PlayerMoveHeadServer;
    }
Esempio n. 38
0
    void Start()
    {
        io = GetComponent <SocketIO.SocketIOComponent>();
        dodgeballManager = transform.parent.GetComponentInChildren <dodgeballManager>();

        io.On("joined-game", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data = e.data;
            Debug.Log("Joined game " + data);
        });
        io.On("player-position-update", (SocketIO.SocketIOEvent e) =>
        {
            try
            {
                JSONObject data = e.data;
                string playerID = data.GetField("id").ToString();

                JSONObject playerPos = data.GetField("position");
                Vector3 newPos       = new Vector3(
                    float.Parse(playerPos.GetField("x").ToString()),
                    float.Parse(playerPos.GetField("y").ToString()),
                    float.Parse(playerPos.GetField("z").ToString())
                    );

                JSONObject playerRot = data.GetField("rotation");
                Quaternion newRot    = new Quaternion(
                    float.Parse(playerRot.GetField("x").ToString()),
                    float.Parse(playerRot.GetField("y").ToString()),
                    float.Parse(playerRot.GetField("z").ToString()),
                    float.Parse(playerRot.GetField("w").ToString())
                    );

                player p = getPlayer(playerID);
                if (p != null)
                {
                    p.newPos = newPos;
                    p.newRot = newRot;
                }
            }
            catch (Exception err)
            {
                Debug.LogError("player-position-update-exception: " + err);
            }
        });
        io.On("dodgeball-thrown", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data   = e.data;
            JSONObject posObj = data.GetField("position");
            JSONObject dirObj = data.GetField("direction");
            int ID            = int.Parse(data.GetField("ID").ToString());
            string playerID   = data.GetField("playerID").ToString();

            Vector3 position = new Vector3(
                float.Parse(posObj.GetField("x").ToString()),
                float.Parse(posObj.GetField("y").ToString()),
                float.Parse(posObj.GetField("z").ToString())
                );
            Vector3 direction = new Vector3(
                float.Parse(dirObj.GetField("x").ToString()),
                float.Parse(dirObj.GetField("y").ToString()),
                float.Parse(dirObj.GetField("z").ToString())
                );
            dodgeballManager.onNetworkThrowBall(position, direction);
            getPlayer(playerID).network.onThrowDodgeball();
        });
        io.On("dodgeball-pickup", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data = e.data;
            string playerID = data.GetField("playerID").ToString();

            player foundPlayer = getPlayer(playerID);
            foundPlayer.network.onPickupDodgeball();
        });
        io.On("player-join", (SocketIO.SocketIOEvent e) =>
        {
            Debug.Log("new player join");
            JSONObject data = e.data;

            player newPlayer     = new player();
            newPlayer.id         = data.GetField("playerID").ToString();
            GameObject playerObj = GameObject.Instantiate(playerPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity);
            newPlayer.transform  = playerObj.transform;
            newPlayer.network    = playerObj.GetComponent <networkPlayerController>();
            otherPlayers.Add(newPlayer);
        });
        io.On("player-disconnect", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data = e.data;
            string id       = data.GetField("id").ToString();
            player p        = otherPlayers.Find(x => x.id == id);
            GameObject.Destroy(p.transform.gameObject);
            otherPlayers.Remove(p);
        });
        io.On("player-death", (SocketIO.SocketIOEvent e) =>
        {
            Debug.Log("player death");
        });
    }