Exemple #1
0
 public void DeleteSelection()
 {
     data.shape_id = SelectionRaycast.selectedGameobject.GetInstanceID().ToString();
     audio.PlayOneShot(deleteSound, 1.0f);          //play delete sfx once
     Destroy(SelectionRaycast.selectedGameobject);  //delete gameobject that is selected on raycast hit
     reporter.Event(type, data.ToJson());
 }
Exemple #2
0
    IEnumerator SockEventPost()
    {
        w = new WebSocket(new Uri("ws://gbakimchi.herokuapp.com/ws/"));
        yield return(StartCoroutine(w.Connect()));

        while (true)
        {
            if (this.readyToPost)
            {
                print("trying to post");
                DataObj sockdata = new DataObj();
                sockdata.type = "ws-" + this.sockType;
                sockdata.data = this.sockData;
                readyToPost   = false;
                string sockdata_str = sockdata.ToJson();
                print(sockdata_str);
                w.SendString(sockdata_str);
            }
            if (w.error != null)
            {
                Debug.LogError("Error: " + w.error);
                break;
            }
            yield return(0);
        }
        w.Close();
    }
    public void MoveCam(string direction)
    {
        type           = "rotate_view";
        view.orient    = cam.transform.rotation.ToString();
        view.pos       = cam.transform.position.ToString();
        data.prev_view = view.ToJson();
        switch (direction)
        {
        case "left":

            cam.transform.RotateAround(Vector3.zero, Vector3.up, horizontalMovement * -1.0f);

            data.btn_clicked = "left";
            break;

        case "right":
            cam.transform.RotateAround(Vector3.zero, Vector3.up, horizontalMovement);
            data.btn_clicked = "right";
            break;

        case "down":
            // float newDownPitch = cam.transform.eulerAngles.x + verticalMovement;
            // cam.transform.eulerAngles = new Vector3 (newDownPitch, cam.transform.eulerAngles.y, cam.transform.eulerAngles.z);
            if (cam.transform.eulerAngles.x > 10)
            {
                cam.transform.RotateAround(Vector3.zero, cam.transform.right, verticalMovement * -1.0f);
            }
            data.btn_clicked = "down";

            break;

        case "up":
            // float newUpPitch = cam.transform.eulerAngles.x - verticalMovement;
            // cam.transform.eulerAngles = new Vector3 (newUpPitch, cam.transform.eulerAngles.y, cam.transform.eulerAngles.z);
            // cam.transform.eulerAngles.x += verticalMovement;
            if (cam.transform.eulerAngles.x < 80)
            {
                cam.transform.RotateAround(Vector3.zero, cam.transform.right, verticalMovement);
            }
            data.btn_clicked = "up";

            break;

        case "home":
            cam.transform.position    = defaultpos;
            cam.transform.eulerAngles = defaultrot;
            type             = "reset_view";
            data.btn_clicked = "home";
            break;

        default:
            break;
        }
        view.orient    = cam.transform.rotation.ToString();
        view.pos       = cam.transform.position.ToString();
        data.curr_view = view.ToJson();
        reporter.Event(type, data.ToJson());
    }
    public void movePlusX()
    {
        data.shape_id    = cube.GetInstanceID().ToString();
        data.init_orient = cube.transform.rotation.ToString();

        cube.transform.Rotate(delta, 0, 0, Space.World);

        data.end_orient  = cube.transform.rotation.ToString();
        data.btn_clicked = "rotatePlusX";
        reporter.Event(type, data.ToJson());
    }
    public void changePerspective(GameObject buttonLabel)
    {
        foreach (GameObject wall in walls)
        {
            // Changes the walls visibility state to the opposite of what it was
            wall.GetComponent <MeshRenderer>().enabled = !wall.GetComponent <MeshRenderer>().enabled;
        }
        // Changes the perspective state to the opposite of what it was

        cam.orthographic = !cam.orthographic;
        if (cam.orthographic)
        {
            buttonLabel.GetComponent <Text>().text = "Orthographic";
            data.previous_perspective = "perspective";
            data.new_perspective      = "orthographic";
        }
        else
        {
            buttonLabel.GetComponent <Text>().text = "Perspective";
            data.previous_perspective = "orthographic";
            data.new_perspective      = "perspective";
        }
        reporter.Event(type, data.ToJson());
    }