Inheritance: BSONValue, IEnumerable
Ejemplo n.º 1
0
    void OnGUI()
    {
        // Make a background box
        GUI.Box(new Rect(10,10,300,260), "Menu");

        // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
        if(GUI.Button(new Rect(20,40,280,100), "Realistic")) {
            Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
            bsonObj.Add ("button", "realistic");
            bsonSender.SendUncompressed(bsonObj);
            //Application.LoadLevel(1);
        }

        // Make the second button.
        if(GUI.Button(new Rect(20,150,280,100), "Artistic")) {
            Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
            bsonObj.Add ("button", "artistic");
            bsonSender.SendUncompressed(bsonObj);
            //Application.LoadLevel(2);
        }

        GUI.Box(new Rect(Screen.width - 220,10,200,260), "Info");
        GUI.Label(new Rect(Screen.width - 200,30,280,20), "Host : " + remoteHost);
        GUI.Label(new Rect(Screen.width - 200,60,280,20), "Port : " + remotePort);
    }
 public override void SoundPlayRateMsg(icSound sound)
 {
     BSONObject b = new BSONObject();
     b["id"] = sound.GetId();
     b["speed"] = sound.PlayRate;
     bsonChildren["playrate"].Add (b);
 }
 public override void SoundPositionMsg(icSound sound)
 {
     BSONObject b = new BSONObject();
     b["id"] = sound.GetId();
     b["position"] = WorldToBellowsPosition(sound.GetWorldPosition());
     bsonChildren["move"].Add (b);
 }
Ejemplo n.º 4
0
    void OnGUI()
    {
        // Make a background box
        GUI.Box(new Rect(10, 10, 300, 260), "Menu");

        // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
        if (GUI.Button(new Rect(20, 40, 280, 100), "Realistic"))
        {
            Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
            bsonObj.Add("button", "realistic");
            bsonSender.SendUncompressed(bsonObj);
            //Application.LoadLevel(1);
        }

        // Make the second button.
        if (GUI.Button(new Rect(20, 150, 280, 100), "Artistic"))
        {
            Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
            bsonObj.Add("button", "artistic");
            bsonSender.SendUncompressed(bsonObj);
            //Application.LoadLevel(2);
        }

        GUI.Box(new Rect(Screen.width - 220, 10, 200, 260), "Info");
        GUI.Label(new Rect(Screen.width - 200, 30, 280, 20), "Host : " + remoteHost);
        GUI.Label(new Rect(Screen.width - 200, 60, 280, 20), "Port : " + remotePort);
    }
        public override void SoundSeekMsg(icSound sound, int milliseconds)
        {
            BSONObject b = new BSONObject();
            b["id"] = sound.GetId();
            b["t"] = milliseconds;

            bsonChildren["time"].Add (b);
        }
        public override void SoundVolumeMsg(icSound sound)
        {
            BSONObject b = new BSONObject();
            b["id"] = sound.GetId();
            b["volume"] = sound.Volume;

            bsonChildren["volume"].Add(b);
        }
Ejemplo n.º 7
0
		public void WriteSingleObject()
		{
			BSONObject obj = new BSONObject ();

			obj ["Blah"] = 1;

			string bson = MiscellaneousUtils.BytesToHex(SimpleBSON.Dump(obj));
			Assert.AreEqual("0F-00-00-00-10-42-6C-61-68-00-01-00-00-00-00", bson);
		}
Ejemplo n.º 8
0
        private void encodeArray(MemoryStream ms, BSONArray lst)
        {
            var obj = new BSONObject();

            for (int i = 0; i < lst.Count; ++i)
            {
                obj.Add(Convert.ToString(i), lst[i]);
            }

            encodeDocument(ms, obj);
        }
Ejemplo n.º 9
0
        public static byte[] Dump(BSONObject obj)
        {
            SimpleBSON   bson = new SimpleBSON();
            MemoryStream ms   = new MemoryStream();

            bson.encodeDocument(ms, obj);

            byte[] buf = new byte[ms.Position];
            ms.Seek(0, SeekOrigin.Begin);
            ms.Read(buf, 0, buf.Length);

            return(buf);
        }
Ejemplo n.º 10
0
		public void WriteArray()
		{
			byte[] data = MiscellaneousUtils.HexToBytes("31-00-00-00-04-42-53-4f-4e-00-26-00-00-00-02-30-00-08-00-00-00-61-77-65-73-6f-6d-65-00-01-31-00-33-33-33-33-33-33-14-40-10-32-00-c2-07-00-00-00-00");

			BSONObject obj = new BSONObject();

			obj ["BSON"] = new BSONArray ();
			obj ["BSON"].Add ("awesome");
			obj ["BSON"].Add (5.05);
			obj ["BSON"].Add (1986);

			byte[] target = SimpleBSON.Dump (obj);
			Assert.IsTrue (MiscellaneousUtils.ByteArrayCompare (target, data) == 0);

		}
Ejemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        framesTillSend--;

        if (framesTillSend <= 0)
        {
            Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
            bsonObj.Add("newx", playerPosition.transform.position.x);
            bsonObj.Add("newy", playerPosition.transform.position.y);
            bsonObj.Add("newz", playerPosition.transform.position.z);
            bsonSender.SendUncompressed(bsonObj);

            framesTillSend = sendEveryXFrames;
        }
    }
Ejemplo n.º 12
0
        private void encodeDocument(MemoryStream ms, BSONObject obj)
        {
            MemoryStream dms = new MemoryStream();

            foreach (string str in obj.Keys)
            {
                encodeElement(dms, str, obj[str]);
            }

            BinaryWriter bw = new BinaryWriter(ms);

            bw.Write((Int32)(dms.Position + 4 + 1));
            bw.Write(dms.GetBuffer(), 0, (int)dms.Position);
            bw.Write((byte)0);
        }
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        framesTillSend--;

        if (framesTillSend <= 0)
        {
            Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject ();
            bsonObj.Add ("newx", playerPosition.transform.position.x);
            bsonObj.Add ("newy", playerPosition.transform.position.y);
            bsonObj.Add ("newz", playerPosition.transform.position.z);
            bsonSender.SendUncompressed (bsonObj);

            framesTillSend = sendEveryXFrames;
        }
    }
Ejemplo n.º 14
0
	// Use this for initialization
	void Start () {
		bsonSender = new BSONSender(remoteHost, remotePort);
		bsonObj = new Kernys.Bson.BSONObject();
		dataAdded = false;

		if (positionListener)
		{
			bsonListener = new BSONListener(listenPort);

			Debug.Log ("Sending listener active message");
			Kernys.Bson.BSONObject laMsg = new Kernys.Bson.BSONObject();
			laMsg.Add ("positionListener", "active");
			bsonSender.SendUncompressed (laMsg);
		}

	}
Ejemplo n.º 15
0
        private BSONArray decodeArray()
        {
            BSONObject obj = decodeDocument();

            int       i     = 0;
            BSONArray array = new BSONArray();

            while (obj.ContainsKey(Convert.ToString(i)))
            {
                array.Add(obj [Convert.ToString(i)]);

                i += 1;
            }

            return(array);
        }
Ejemplo n.º 16
0
        private BSONObject decodeDocument()
        {
            int length = mBinaryReader.ReadInt32() - 4;

            BSONObject obj = new BSONObject();

            int i = (int)mBinaryReader.BaseStream.Position;

            while (mBinaryReader.BaseStream.Position < i + length - 1)
            {
                string    name;
                BSONValue value = decodeElement(out name);
                obj.Add(name, value);
            }

            mBinaryReader.ReadByte();              // zero
            return(obj);
        }
Ejemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        radius    = 1000.0f;
        ang       = 0;
        elevation = 0.1f;
        offset    = new Vector3(0, 0, 0);

        /*
         * tcpSender = new TCPAsyncSender("192.168.1.103", 5555);
         * tcpSender.StartThread();
         * tcpSender.AddMessage(testMsg);
         */

        Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
        bsonObj.Add("test", "hello");

        bsonSender = new BSONSender(remoteHost, remotePort);
        bsonSender.SendUncompressed(bsonObj);
    }
Ejemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        radius = 1000.0f;
        ang = 0;
        elevation = 0.1f;
        offset = new Vector3(0, 0, 0);

        /*
        tcpSender = new TCPAsyncSender("192.168.1.103", 5555);
        tcpSender.StartThread();
        tcpSender.AddMessage(testMsg);
        */

        Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
        bsonObj.Add ("test", "hello");

        bsonSender = new BSONSender(remoteHost, remotePort);
        bsonSender.SendUncompressed(bsonObj);
    }
Ejemplo n.º 19
0
	// Update is called once per frame
	void Update () {
		BSONObject bo;
		
		if (dataAdded)
		{
			//Debug.Log ("sending data");
			bsonSender.SendUncompressed(bsonObj);
			bsonObj = new Kernys.Bson.BSONObject();
			dataAdded = false;
		}

		if (!positionListener)
			return;

		bo = bsonListener.Receive();
		hasNewPosition = false;
		newPosition = new Vector3 (0, 0, 0);
		
		while (bo != null)
		{
			Debug.Log ("Got new pos");
			if (bo.ContainsKey("newx"))
			{
				hasNewPosition = true;
				newPosition.x = bo["newx"];
			}
			if (bo.ContainsKey("newy"))
			{
				hasNewPosition = true;
				newPosition.y = bo["newy"];
			}
			if (bo.ContainsKey("newz"))
			{
				hasNewPosition = true;
				newPosition.z = bo["newz"];
			}
			bo = bsonListener.Receive();
		}
		
		if (hasNewPosition)
			playerDisplay.transform.position = newPosition;
	}
Ejemplo n.º 20
0
		public void WriteAndRead()
		{
			var obj = new BSONObject ();
			obj["hello"] = 123;

			obj["where"] = new BSONObject();
			obj["where"]["Korea"] = "Asia";
			obj["where"]["USA"] = "America";
			obj["bytes"] = new byte[41223];

			byte []buf = SimpleBSON.Dump(obj);
			Console.WriteLine (buf);

			obj = SimpleBSON.Load(buf);

			Console.WriteLine(obj["hello"].int32Value); // => 123
			Console.WriteLine(obj["where"]["Korea"].stringValue); // => "Asia"
			Console.WriteLine(obj["where"]["USA"].stringValue); // => "America"
			Console.WriteLine(obj["bytes"].binaryValue.Length); // => 128-length bytesbytes
		}
	// Update is called once per frame
	void Update () {
		float x, y, z;
		bool tapMove = false;
		Vector3 tapMovePos = new Vector3(0, 0, 0);


		if (Input.touchCount == 1)
		{
			Touch touch = Input.GetTouch(0);
			if (touch.phase == TouchPhase.Began)
			{
				touchMoved = false;
				touchStartPos = touch.position;
				/*
				 * We make some "dead zones" near the buttons at the top of the screen and around the joystick
				 * and on the left hand side of the screen to avoid thumb presses
				 * Touch events cannot start in these regions
				 */
				if ((touch.position.y > 1300) ||
				    ((touch.position.x > 1920) && (touch.position.y < 528)) ||
				    (touch.position.x < 300))
					touchStarted = false;
				else
					touchStarted = true;

				//Debug.Log ("Touch start " + touch.position.x + ", " + touch.position.y);
			}
			else if (touch.phase == TouchPhase.Moved)
			{
				Vector3 cameraPos;
				float moveAmount;

				/*
				ang -= touch.deltaPosition.x * sensitivityRotate;
				elevation += touch.deltaPosition.y * sensitivityElevate;
				if (elevation < 0)
					elevation = 0;
				else if (elevation > (Mathf.PI / 2.0f))
					elevation = Mathf.PI / 2.0f;
				*/
				if (touchStarted)
				{
					moveAmount = sensitivityMove * (camera.transform.position.y / camMaxHeight);
					cameraPos = camera.transform.position;
					cameraPos -= (touch.deltaPosition.x * moveAmount) * Vector3.right;
					cameraPos -= (touch.deltaPosition.y * moveAmount) * Vector3.forward;
					camera.transform.position = cameraPos;
				}
				if (!touchMoved)
				{
					if (Vector2.Distance(touchStartPos, touch.position) > clickDelta)
						touchMoved = true;
				}
			}
			else if (touch.phase == TouchPhase.Ended)
			{
				// this is a click
				if (touchStarted && !touchMoved)
				{
					/* test for a double click */
					if ((Vector2.Distance(lastClickPos, touch.position) < doubleClickDelta) &&
					    ((Time.time - lastClickTime) < doubleClickTimeDelta))
					{
						RaycastHit hitInfo;
						debug = "x";
						tapCount++;
						if (Physics.Raycast(camera.ScreenPointToRay(new Vector3(touch.position.x, touch.position.y, 0)), out hitInfo))
						{
							debug = "hit";
							//playerDisplay.transform.position = hitInfo.point;
							tapMove = true;
							tapMovePos = hitInfo.point + new Vector3(0, 20, 0);

						}
						else
						{
							debug = "miss";
						}
					}

					lastClickTime = Time.time;
					lastClickPos = touch.position;
				}
				touchStarted = false;
			}

		} 
		else if (Input.touchCount == 2)
		{
			Touch t1, t2;
			Vector2 touchPos;
			Vector2 touchDiff;
			float touchAngle;
			Vector3 oldCamRotation;
			t1 = Input.GetTouch(0);
			t2 = Input.GetTouch(1);
			if (!pinching)
			{
				pinching = true;
				pinchDist = Vector2.Distance(t1.position, t2.position);
				oldTouchPos = (t1.position + t2.position) * 0.5f; // midpoint
				forwardDir = camera.transform.forward;
				forwardDir.y = 0;
				rightDir = camera.transform.right;
				rightDir.y = 0;
				touchDiff = t2.position - t1.position;
				oldTouchAngle = Mathf.Atan2(touchDiff.y, touchDiff.x);
			} else {
				float oldPinchdist = pinchDist;
				pinchDist = Vector2.Distance(t1.position, t2.position);
				camera.transform.position += new Vector3(0, oldPinchdist - pinchDist, 0);
				offset -= forwardDir * (oldTouchPos.y - t1.position.y);
				offset += rightDir * (oldTouchPos.x - t1.position.x);
				touchPos = (t1.position + t2.position) * 0.5f; // midpoint
				//if (camera.transform.rotation.eulerAngles.x < 90)
				oldCamRotation = camera.transform.eulerAngles;
				camera.transform.Rotate((oldTouchPos.y - touchPos.y) * -0.05f, 0, 0);
				if (camera.transform.rotation.eulerAngles.y > 170)
				{
					camera.transform.eulerAngles = oldCamRotation;
				}

				touchDiff = t2.position - t1.position;
				touchAngle = Mathf.Atan2(touchDiff.y, touchDiff.x);
				//camera.transform.Rotate(0, 0, (touchAngle - oldTouchAngle) * -60.0f);

				oldTouchPos = touchPos;
				oldTouchAngle = touchAngle;
			}
		}
		else
		{
			pinching = false;
		}

		if (camera.transform.position.y > camMaxHeight)
		{
			Vector3 pos;
			pos = camera.transform.position;
			pos.y = camMaxHeight;
			camera.transform.position = pos;
		}
		else if (camera.transform.position.y < camMinHeight)
		{
			Vector3 pos;
			pos = camera.transform.position;
			pos.y = camMinHeight;
			camera.transform.position = pos;
		}


		if (Input.GetKey(KeyCode.A))
			ang += 0.1f;
		if (Input.GetKey(KeyCode.D))
			ang -= 0.1f;
		if (Input.GetKey(KeyCode.Q))
			if (elevation < (Mathf.PI / 2.0f))
				elevation += 0.1f;
		if (Input.GetKey(KeyCode.E))
			if (elevation > 0.15f)
				elevation -= 0.1f;
		if (Input.GetKey(KeyCode.W))
			camera.transform.position += new Vector3(100, 0, 0);
		if (Input.GetKey(KeyCode.S))
			radius += 10.0f;
		if (Input.GetKey(KeyCode.Z))
			offset += forwardDir;
		if (Input.GetKey(KeyCode.X))
			offset -= forwardDir;

		x = radius * Mathf.Cos(ang) * Mathf.Sin(elevation);
		z = radius * Mathf.Sin(ang) * Mathf.Sin(elevation);
		y = radius * Mathf.Cos(elevation);

		//camera.transform.localPosition = new Vector3(x, y, z) + orbitAround.position + offset;
		//camera.transform.LookAt(orbitAround.position + offset);

		Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
		if ((jstick.position.x >= joystickDeadZone) || (jstick.position.x <= -1 * joystickDeadZone) ||
		    (jstick.position.y >= joystickDeadZone) || (jstick.position.y <= -1 * joystickDeadZone))
		{

			bsonComms.addData ("x", jstick.position.x);
			bsonComms.addData ("y", jstick.position.y);
			sentJoystickZero = false;
		}
		else if (!sentJoystickZero)
		{			
			bsonComms.addData ("x", 0.0f);
			bsonComms.addData ("y", 0.0f);
			sentJoystickZero = true;
		}
		if (tapMove)
		{
			Debug.Log ("sending MOVE msg");
			bsonComms.addData ("movex", tapMovePos.x);
			bsonComms.addData ("movey", tapMovePos.y);
			bsonComms.addData ("movez", tapMovePos.z);
			Debug.Log ("sent MOVE msg");
		}
		//bsonSender.SendUncompressed(bsonObj);

	}
Ejemplo n.º 22
0
        protected override void SoundLoadMsg(icSound sound)
        {
            BSONObject b = new BSONObject();
            b["id"] = sound.GetId();
            b["streaming"] = new BSONValue(sound.IsStreaming());
            b["looping"] = new BSONValue(sound.IsLooping());
            b["videosync"] = new BSONValue(sound.IsVideoSync());
            b["permanent"] = new BSONValue(true);
            b["path"] = sound.GetFilePath();
            b["speed"] = sound.PlayRate;
            b["volume"] = sound.Volume;

            b["position"] = WorldToBellowsPosition(sound.GetWorldPosition());

            bsonChildren["load"].Add (b);
        }
Ejemplo n.º 23
0
    // Update is called once per frame
    void Update()
    {
        float x, y, z;

        if (Input.touchCount == 1)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began)
            {
                touchMoved = false;
            }
            else if (touch.phase == TouchPhase.Moved)
            {
                Vector3 cameraPos;
                /*
                ang -= touch.deltaPosition.x * sensitivityRotate;
                elevation += touch.deltaPosition.y * sensitivityElevate;
                if (elevation < 0)
                    elevation = 0;
                else if (elevation > (Mathf.PI / 2.0f))
                    elevation = Mathf.PI / 2.0f;
                */
                cameraPos = camera.transform.position;
                cameraPos.x += touch.deltaPosition.x;
                cameraPos.z += touch.deltaPosition.y;
                camera.transform.position = cameraPos;
                touchMoved = true;
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                // this is a click
                if (!touchMoved)
                {
                    /* We can use GUI stuff so probably don't need this */
                    /*
                    Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
                    bsonObj.Add ("x", touch.position.x);
                    bsonObj.Add ("y", touch.position.y);
                    bsonSender.SendUncompressed(bsonObj);
                    */
                }
            }
        }
        else if (Input.touchCount == 2)
        {
            Touch t1, t2;
            t1 = Input.GetTouch(0);
            t2 = Input.GetTouch(1);
            if (!pinching)
            {
                pinching = true;
                pinchDist = Vector2.Distance(t1.position, t2.position);
                oldTouchPos = t1.position;
                forwardDir = camera.transform.forward;
                forwardDir.y = 0;
                rightDir = camera.transform.right;
                rightDir.y = 0;
            } else {
                float oldPinchdist = pinchDist;
                pinchDist = Vector2.Distance(t1.position, t2.position);
                radius += oldPinchdist - pinchDist;
                offset -= forwardDir * (oldTouchPos.y - t1.position.y);
                offset += rightDir * (oldTouchPos.x - t1.position.x);
                oldTouchPos = t1.position;
            }
        }
        else
        {
            pinching = false;
        }

        if (Input.GetKey(KeyCode.A))
            ang += 0.1f;
        if (Input.GetKey(KeyCode.D))
            ang -= 0.1f;
        if (Input.GetKey(KeyCode.Q))
            if (elevation < (Mathf.PI / 2.0f))
                elevation += 0.1f;
        if (Input.GetKey(KeyCode.E))
            if (elevation > 0.15f)
                elevation -= 0.1f;
        if (Input.GetKey(KeyCode.W))
            radius -= 10.0f;
        if (Input.GetKey(KeyCode.S))
            radius += 10.0f;
        if (Input.GetKey(KeyCode.Z))
            offset += forwardDir;
        if (Input.GetKey(KeyCode.X))
            offset -= forwardDir;

        x = radius * Mathf.Cos(ang) * Mathf.Sin(elevation);
        z = radius * Mathf.Sin(ang) * Mathf.Sin(elevation);
        y = radius * Mathf.Cos(elevation);

        //camera.transform.localPosition = new Vector3(x, y, z) + orbitAround.position + offset;
        //camera.transform.LookAt(orbitAround.position + offset);

        Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
        bsonObj.Add ("x", jstick.position.x);
        bsonObj.Add ("y", jstick.position.y);
        bsonSender.SendUncompressed(bsonObj);
    }
Ejemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        float x, y, z;

        if (Input.touchCount == 1)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began)
            {
                touchMoved = false;
            }
            else if (touch.phase == TouchPhase.Moved)
            {
                Vector3 cameraPos;

                /*
                 * ang -= touch.deltaPosition.x * sensitivityRotate;
                 * elevation += touch.deltaPosition.y * sensitivityElevate;
                 * if (elevation < 0)
                 *      elevation = 0;
                 * else if (elevation > (Mathf.PI / 2.0f))
                 *      elevation = Mathf.PI / 2.0f;
                 */
                cameraPos    = camera.transform.position;
                cameraPos.x += touch.deltaPosition.x;
                cameraPos.z += touch.deltaPosition.y;
                camera.transform.position = cameraPos;
                touchMoved = true;
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                // this is a click
                if (!touchMoved)
                {
                    /* We can use GUI stuff so probably don't need this */

                    /*
                     * Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
                     * bsonObj.Add ("x", touch.position.x);
                     * bsonObj.Add ("y", touch.position.y);
                     * bsonSender.SendUncompressed(bsonObj);
                     */
                }
            }
        }
        else if (Input.touchCount == 2)
        {
            Touch t1, t2;
            t1 = Input.GetTouch(0);
            t2 = Input.GetTouch(1);
            if (!pinching)
            {
                pinching     = true;
                pinchDist    = Vector2.Distance(t1.position, t2.position);
                oldTouchPos  = t1.position;
                forwardDir   = camera.transform.forward;
                forwardDir.y = 0;
                rightDir     = camera.transform.right;
                rightDir.y   = 0;
            }
            else
            {
                float oldPinchdist = pinchDist;
                pinchDist   = Vector2.Distance(t1.position, t2.position);
                radius     += oldPinchdist - pinchDist;
                offset     -= forwardDir * (oldTouchPos.y - t1.position.y);
                offset     += rightDir * (oldTouchPos.x - t1.position.x);
                oldTouchPos = t1.position;
            }
        }
        else
        {
            pinching = false;
        }


        if (Input.GetKey(KeyCode.A))
        {
            ang += 0.1f;
        }
        if (Input.GetKey(KeyCode.D))
        {
            ang -= 0.1f;
        }
        if (Input.GetKey(KeyCode.Q))
        {
            if (elevation < (Mathf.PI / 2.0f))
            {
                elevation += 0.1f;
            }
        }
        if (Input.GetKey(KeyCode.E))
        {
            if (elevation > 0.15f)
            {
                elevation -= 0.1f;
            }
        }
        if (Input.GetKey(KeyCode.W))
        {
            radius -= 10.0f;
        }
        if (Input.GetKey(KeyCode.S))
        {
            radius += 10.0f;
        }
        if (Input.GetKey(KeyCode.Z))
        {
            offset += forwardDir;
        }
        if (Input.GetKey(KeyCode.X))
        {
            offset -= forwardDir;
        }

        x = radius * Mathf.Cos(ang) * Mathf.Sin(elevation);
        z = radius * Mathf.Sin(ang) * Mathf.Sin(elevation);
        y = radius * Mathf.Cos(elevation);

        //camera.transform.localPosition = new Vector3(x, y, z) + orbitAround.position + offset;
        //camera.transform.LookAt(orbitAround.position + offset);

        Kernys.Bson.BSONObject bsonObj = new Kernys.Bson.BSONObject();
        bsonObj.Add("x", jstick.position.x);
        bsonObj.Add("y", jstick.position.y);
        bsonSender.SendUncompressed(bsonObj);
    }
Ejemplo n.º 25
0
        void Awake()
        {
            // Set up BSON objects before script Start()
            bsonRoot = new BSONObject();
            bsonGlobals = new BSONObject();

            bsonChildren["load"] = new BSONArray();
            bsonChildren["play"] = new BSONArray();
            bsonChildren["move"] = new BSONArray();
            bsonChildren["volume"] = new BSONArray();
            bsonChildren["playrate"] = new BSONArray();
            bsonChildren["time"] = new BSONArray();
        }
		public static byte[] Dump(BSONObject obj) {
			
			SimpleBSON bson = new SimpleBSON ();
			MemoryStream ms = new MemoryStream ();

			bson.encodeDocument (ms, obj);

			byte[] buf = new byte[ms.Position];
			ms.Seek (0, SeekOrigin.Begin);  
			ms.Read (buf, 0, buf.Length);

			return buf;
		}
		private void encodeArray(MemoryStream ms, BSONArray lst) {

			var obj = new BSONObject ();
			for(int i = 0;i < lst.Count;++i) {
				obj.Add(Convert.ToString(i), lst[i]);
			}

			encodeDocument (ms, obj);
		}
		private void encodeDocument(MemoryStream ms, BSONObject obj) {

			MemoryStream dms = new MemoryStream ();
			foreach(string str in obj.Keys) {
				encodeElement(dms, str, obj[str]);
			}

			BinaryWriter bw = new BinaryWriter (ms);
			bw.Write ((Int32)(dms.Position+4+1));
			bw.Write (dms.GetBuffer (), 0, (int)dms.Position);
			bw.Write ((byte)0);
		}
		private BSONObject decodeDocument() {
			int length = mBinaryReader.ReadInt32 ()-4;

			BSONObject obj = new BSONObject ();

			int i = (int)mBinaryReader.BaseStream.Position;
			while(mBinaryReader.BaseStream.Position < i+length - 1) {
				string name;
				BSONValue value = decodeElement (out name);
				obj.Add (name, value);

			}

			mBinaryReader.ReadByte (); // zero
			return obj;
		}
Ejemplo n.º 30
0
 public override void SoundPlayMsg(icSound sound)
 {
     BSONObject b = new BSONObject();
     b["id"] = sound.GetId();
     bsonChildren["play"].Add(b);
 }