void Update()
    {
        if (!theUI.GetchatTBFocus())
        {
            if (Input.GetKeyDown(KeyCode.W))
            {
                this.MecAnim.SetBool(RUN_ANIMATION, true);
                ISFSObject ObjectIn = new SFSObject();
                ObjectIn.PutFloatArray("Location", ourLPC.GetLocation());
                ObjectIn.PutBool("IsMoving", true);
                SFServer.Send(new ExtensionRequest("PositionUpdate", ObjectIn));

                // First rotation
                this.PlayerRB.transform.Rotate(0, crosshairTransform.localRotation.eulerAngles.y, 0);
                crosshairTransform.localRotation = Quaternion.Euler(crosshairTransform.localEulerAngles.x, 0, crosshairTransform.localEulerAngles.z);
                crosshairTransform.localPosition = new Vector3(1f, 2.5f, 1.0f);
                ObjectIn = new SFSObject();
                ObjectIn.PutFloat("Rotation", ourLPC.GetRotation());
                SFServer.Send(new ExtensionRequest("RotationUpdate", ObjectIn));
            }
            if (Input.GetKeyUp(KeyCode.W))
            {
                this.MecAnim.SetBool(RUN_ANIMATION, false);
                ISFSObject ObjectIn = new SFSObject();
                ObjectIn.PutFloatArray("Location", ourLPC.GetLocation());
                ObjectIn.PutBool("IsMoving", false);
                SFServer.Send(new ExtensionRequest("PositionUpdate", ObjectIn));
            }

            if (Input.GetKey(KeyCode.W))
            {
                CameraController cameraControllerObj = (CameraController)Camera.main.GetComponent("CameraController");
                cameraControllerObj.setCursorVisible(false);
                this.PlayerRB.MovePosition(transform.position + (transform.forward * Time.deltaTime * PlayerSpeed));
            }

            if (Input.GetKey(KeyCode.W) && Input.GetAxis("Mouse X") != 0)
            {
                // Take Cross Hair's rotate, and reset crosshair
                this.PlayerRB.transform.Rotate(0, crosshairTransform.localRotation.eulerAngles.y, 0);
                crosshairTransform.localRotation = Quaternion.Euler(crosshairTransform.localEulerAngles.x, 0, crosshairTransform.localEulerAngles.z);
                crosshairTransform.localPosition = new Vector3(1f, 2.5f, 1.0f);

                ISFSObject ObjectIn = new SFSObject();
                ObjectIn.PutFloat("Rotation", ourLPC.GetRotation());
                SFServer.Send(new ExtensionRequest("RotationUpdate", ObjectIn));
            }
            if (Input.GetKeyDown(KeyCode.F))
            {
                if (ourLPC.getPlayerAction() != null)
                {
                    ourLPC.getPlayerAction().performAction(GameObject.Find("SceneScriptsObject"));
                }
            }
        }
    }
Ejemplo n.º 2
0
 private void sendBlockDataSFSMessage(object sender, DoWorkEventArgs e)
 {
     var blocks = e.Argument as List<float[]>;
     var obj = new SFSObject();
     obj.PutUtfString("type", "sync");
     var blocksArray = new SFSArray();
     foreach (var block in blocks) {
         var blockData = new SFSObject();
         blockData.PutFloatArray("position", new[] {block[0], block[1]});
         blockData.PutFloatArray("velocity", new[] {block[2], block[3]});
         blocksArray.AddSFSObject(blockData);
     }
     obj.PutSFSArray("blocks", blocksArray);
     smartFox.Send (new ObjectMessageRequest(obj));
 }
Ejemplo n.º 3
0
 void sendExplosionForce(Vector3 location, float force)
 {
     ISFSObject sendExplosion = new SFSObject();
     sendExplosion.PutUtfString("type", "explosion");
     if (isBlueTeam)
     {
         sendExplosion.PutUtfString("team", "blue");
     }
     else
     {
         sendExplosion.PutUtfString("team", "red");
     }
     sendExplosion.PutFloat("force", force);
     sendExplosion.PutFloatArray("pos", new[] {location.x, location.z});
     smartFox.Send(new ObjectMessageRequest(sendExplosion, null, smartFox.LastJoinedRoom.UserList));
 }