Ejemplo n.º 1
0
 private void handlePickRequest()
 {
     if (state == PickerState.empty)
     {
         var pickedup = PlacementLogic.handlePickUpRequest(transform.position);
         if (pickedup != null)
         {
             state  = PickerState.full;
             picked = Transform.Instantiate(pickedup.getGameObject().transform, new Vector3(-1000, -1000, -1000), pickedup.getGameObject().transform.rotation, transform);
             if (pickedup.model != null)
             {
                 pickedModel = Transform.Instantiate <Transform>(pickedup.model, transform.position, pickedup.getGameObject().transform.rotation, transform);
                 pickedModel.gameObject.SetActive(true);
             }
             Destroy(pickedup.getGameObject());
         }
     }
     else if (state == PickerState.full)
     {
         var placed = PlacementLogic.handlePlaceRequest(picked, transform.position);
         if (placed)
         {
             state = PickerState.empty;
             picked.GetComponent <Syncable>().Delete();
             placed.gameObject.SetActive(true);
             if (pickedModel != null)
             {
                 Destroy(pickedModel.gameObject);
             }
             transform.rotation = Quaternion.identity;
         }
     }
 }
Ejemplo n.º 2
0
    private void handlePlace()
    {
        if (PlacementLogic.isMouseOverUI())
        {
            return;
        }
        var syncobjs = TuringScene.CurrentController.syncer.findSyncObjectsByPosition(transform.position.snap());

        //if there are objects in the way, don't place anything
        if (syncobjs.Where(x => x.preventPlacement).Count() > 0)
        {
            return;
        }

        Transform t = Instantiate(Placable, transform.position, transform.rotation);
    }
Ejemplo n.º 3
0
    private bool handleDelete()
    {
        if (PlacementLogic.isMouseOverUI())
        {
            return(false);
        }

        var syncobj = TuringScene.CurrentController.syncer.findSyncObjectsByPosition(transform.position.snap()).Where(x => x is PagodaController).FirstOrDefault();

        if (syncobj != null)
        {
            syncobj.Delete();
            return(true);
        }
        return(false);
    }
Ejemplo n.º 4
0
    void handleCameraScroll()
    {
        if (PlacementLogic.isMouseOffScreen() || PlacementLogic.isMouseOverUI())
        {
            return;
        }
        var x = Input.mousePosition.x / Screen.width;
        var y = Input.mousePosition.y / Screen.height;

        var camforward      = cam.transform.forward;
        var camforwardzerod = new Vector3(camforward.x, 0, camforward.z).normalized;
        var camleft         = -cam.transform.right;
        var camleftzerod    = new Vector3(camleft.x, 0, camleft.z).normalized;
        var camright        = cam.transform.right;
        var camrightzerod   = new Vector3(camright.x, 0, camright.z).normalized;
        var camback         = -cam.transform.forward;
        var cambackzerod    = new Vector3(camback.x, 0, camback.z).normalized;

        Vector3 htravel = Vector3.zero;
        Vector3 vtravel = Vector3.zero;

        if (x < .1f)
        {
            htravel = camleftzerod;
        }
        if (x > .9f)
        {
            htravel = camrightzerod;
        }
        if (y < .1f)
        {
            vtravel = cambackzerod;
        }
        if (y > .75f)
        {
            vtravel = camforwardzerod;
        }

        cam.transform.position += (htravel + vtravel).normalized * Time.deltaTime * 8.0f * /*zoomCoefficient*/ 1f;
    }