示例#1
0
        // Update is called once per frame
        void Update()
        {
            if (anchorTarget)
            {
                float dist = Vector3.Distance(anchorTarget.transform.position, transform.position);
                if (dist >= pullDist)
                {
                    InteractionBehaviour targetInteraction = anchorTarget.GetComponent <InteractionBehaviour>();
                    targetInteraction.OnGraspEnd   -= OnGraspEnd;
                    targetInteraction.OnGraspBegin -= OnGraspBegin;

                    // clone stuff, manage attachment
                    GameObject           clone            = GameObject.Instantiate(anchorTarget, anchorTarget.transform.parent);
                    InteractionBehaviour cloneInteraction = clone.GetComponent <InteractionBehaviour>();
                    cloneInteraction.OnGraspEnd   += OnGraspEnd;
                    cloneInteraction.OnGraspBegin += OnGraspBegin;

                    // enable our anchor
                    anchor.enabled = true;
                    InteractionBehaviour interaction = clone.GetComponent <InteractionBehaviour>();
                    AnchorableBehaviour  anchorable  = clone.GetComponent <AnchorableBehaviour>();
                    //anchorable.transform.SetPositionAndRotation(anchor.transform.position, anchor.transform.rotation);
                    interaction.rigidbody.position = transform.position;
                    interaction.rigidbody.rotation = transform.rotation;

                    anchorable.anchor = anchor;
                    anchorable.TryAttach(true);
                    anchorTarget = clone.gameObject;
                }
            }
        }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     ib = GetComponent <InteractionBehaviour>();
     ib.rigidbody.useGravity  = false;
     ib.rigidbody.isKinematic = true;
     ib.moveObjectWhenGrasped = false;
     button        = GetComponent <UnityEngine.UI.Button>();
     rectTransform = GetComponent <RectTransform>();
     //collie = gameObject.AddComponent<BoxCollider>();
     collie             = GetComponent <BoxCollider>();
     collie.size        = new Vector3(rectTransform.rect.width, rectTransform.rect.height, .1f);
     normieBoi          = button.colors.normalColor;
     pressedBoi         = button.colors.highlightedColor;
     button.image.color = normieBoi;
     ib.OnContactBegin += delegate()
     {
         button.image.color = pressedBoi;
         button.onClick?.Invoke();
         Debug.Log("Touching...");
     };
     ib.OnContactEnd += delegate()
     {
         button.image.color = normieBoi;
         Debug.Log("NO Touching...");
     };
 }
示例#3
0
 void Start()
 {
     mat = new MaterialPropertyBlock();
     mat.SetColor("_Color", Color.red);
     interact = GetComponent <InteractionBehaviour>();
     render   = GetComponent <Renderer>();
 }
示例#4
0
 private void init()
 {
     iBehave = gameObject.GetComponent <InteractionBehaviour>();
     toolbox = GameObject.Find("BearToolBox[Bannannas]");
     toolbox.GetComponent <toolboxfollower>().bone = gameObject;
     StartCoroutine(allowDelete());
 }
示例#5
0
    void Start()
    {
        anchObj.OnPostTryAnchorOnGraspEnd += onPostTryAnchorOnGraspEnd;

        _intObj = anchObj.interactionBehaviour;
        _intObj.OnGraspBegin += onGraspBegin;
    }
示例#6
0
    private bool Naranja(Square cell, Transform obj, int angle)
    {
        Rigidbody            rbdy = obj.GetComponent <Rigidbody>();
        InteractionBehaviour bhvr = obj.GetComponent <InteractionBehaviour>();
        bool resultado            = false;

        switch (angle)
        {
        case 0:

            if (cell.isPlaceable && cell.right != null && cell.right.isPlaceable)
            {
                MagnetizarPieza(rbdy, obj, bhvr);
                cell.isPlaceable       = false;
                cell.right.isPlaceable = false;
                obj.position           = cell.cellPosition + new Vector3(0, 0.08f, 0);
                obj.eulerAngles        = new Vector3(0, 0, 0);
                resultado = true;
            }
            ; break;

        case 90:
            if (cell.isPlaceable && cell.down != null && cell.down.isPlaceable)
            {
                MagnetizarPieza(rbdy, obj, bhvr);
                cell.isPlaceable      = false;
                cell.down.isPlaceable = false;
                obj.position          = cell.cellPosition + new Vector3(0, 0.08f, 0);
                obj.eulerAngles       = new Vector3(0, 90, 0);
                resultado             = true;
            }
            ; break;

        case 180:
            if (cell.isPlaceable && cell.left != null && cell.left.isPlaceable)
            {
                MagnetizarPieza(rbdy, obj, bhvr);
                cell.isPlaceable      = false;
                cell.left.isPlaceable = false;
                obj.position          = cell.cellPosition + new Vector3(0, 0.08f, 0);
                obj.eulerAngles       = new Vector3(0, 180, 0);
                resultado             = true;
            }
            ; break;

        case 270:
            if (cell.isPlaceable && cell.up != null && cell.up.isPlaceable)
            {
                MagnetizarPieza(rbdy, obj, bhvr);
                cell.isPlaceable    = false;
                cell.up.isPlaceable = false;
                obj.position        = cell.cellPosition + new Vector3(0, 0.08f, 0);
                obj.eulerAngles     = new Vector3(0, 270, 0);
                resultado           = true;
            }
            ; break;
        }

        return(resultado);
    }
示例#7
0
 private void Start()
 {
     proxyNode                  = GetComponent <ProxyNode>();
     interactionBehaviour       = GetComponent <InteractionBehaviour>();
     manipulation               = GetComponent <Manipulation>();
     manipulation.OnModeChange += OnManipulationModeChange;
 }
 void CreateNew()
 {
     interaction = selectedObject.AddComponent <InteractionBehaviour>();
     CreateInteractionSound();
     CreateSlideEffect();
     CreateTrailRenderer();
 }
示例#9
0
    void Start()
    {
        score  = 0;
        _audio = GetComponent <AudioSource>(); // 3shan y6l3 bel inspictur
        if (index > PlayerPrefs.GetInt("level", 1))
        {
            Destroy(gameObject);
        }

        switch (PlayerPrefs.GetInt("level", 1))
        {
        case 1:
            boxesRequired = 1;
            break;

        case 2:
            boxesRequired = 3;
            break;

        case 3:
            boxesRequired = 5;
            break;

        default:
            boxesRequired = 1;
            break;
        }
        interaction = GetComponent <InteractionBehaviour>();

        interaction.OnGraspBegin = OnGraspBegin;
        interaction.OnHoverBegin = onHover;
        rb = GetComponent <Rigidbody>();
    }
 private void OnValidate()
 {
     if (intObj == null)
     {
         intObj = GetComponent <InteractionBehaviour>();
     }
 }
 virtual public void RebuildReferences()
 {
     _solidMesh   = transform.FindChild("Solid").GetComponent <MeshRenderer>();
     _outlineMesh = _solidMesh.transform.FindChild("Outline").GetComponent <MeshRenderer>();
     _rigidbody   = GetComponentInChildren <Rigidbody>();
     _leapInteractionBehaviour = GetComponentInChildren <InteractionBehaviour>();
 }
示例#12
0
 private void Reset()
 {
     if (intObj == null)
     {
         intObj = GetComponent <InteractionBehaviour>();
     }
 }
    void Start()
    {
        leftHandFingers  = new List <Finger>();
        rightHandFingers = new List <Finger>();

        // Find all object at stage with InteractionBehavior script
        List <InteractionBehaviour> interactibleObjects = new List <InteractionBehaviour>();

        Transform[] allStageChildren = stage.GetComponentsInChildren <Transform>();
        foreach (Transform child in allStageChildren)
        {
            InteractionBehaviour childIb = child.GetComponent <InteractionBehaviour>();
            if (childIb != null)
            {
                interactibleObjects.Add(childIb);
            }
        }

        // Fill list of interactible objects
        ilList = new List <InteractibleObject>();
        foreach (InteractionBehaviour ib in interactibleObjects)
        {
            //Debug.Log(ib);
            ilList.Add(new InteractibleObject(this, ib));
        }

        server = new SocketServer(SocketServer.GetLocalIP(), 7999, leftHandFingers, rightHandFingers);
        server.Run();
    }
示例#14
0
    void Start()
    {
        _intObj = GetComponent <InteractionBehaviour>();
        _sliObj = GetComponent <InteractionSlider>();

        _renderer = GetComponentInChildren <SpriteRenderer>();
    }
        void ChangeSelection(GameObject newSelection)
        {
            interaction = newSelection.GetComponent <InteractionBehaviour>();

            // get our interaction sound
            interactionSound = newSelection.GetComponent <InteractionSound>();
            if (interactionSound)
            {
                GetInteractionSoundObjectAndProperties();
            }
            else
            {
                // clear interaction sound and object properties!
                interactionSoundObject  = null;
                throwSourceProperty     = null;
                impactSourceProperty    = null;
                grabSourceProperty      = null;
                slideSourceProperty     = null;
                enableImpactSfxProperty = null;
                enableImpactVfxProperty = null;
            }

            // get trail renderer
            currentTrailRenderer = newSelection.GetComponent <TrailRenderer>();
            if (currentTrailRenderer)
            {
                GetTrailObjectAndProperties();
            }
            else
            {
                // clear trail renderer properties
                trailRendererObject        = null;
                trailTimeProperty          = null;
                trailMaterialsProperty     = null;
                trailMinVertexDistProperty = null;
                trailWidthDistProperty     = null;
                trailGradientProperty      = null;
            }

            // get our sliding effect
            slideEffect = newSelection.GetComponent <SlideEffect>();
            if (slideEffect)
            {
                GetSlideEffectObjectAndProperties();
            }
            else
            {
                // clear slide effect stuff
                slideEffectObject              = null;
                slideMaxMagnitudeProperty      = null;
                slideMaxSoundMagnitudeProperty = null;
                slideMaxEmissionRateProperty   = null;
                slideSoundVolumeProperty       = null;
                slideParticleProperty          = null;
                enableSlideSfx         = null;
                enableAirTrailProperty = null;
            }

            selectedObject = newSelection;
        }
示例#16
0
 private void Awake()
 {
     rigidBody            = GetComponent <Rigidbody>();
     interactionBehaviour = GetComponent <InteractionBehaviour>();
     interactionSound     = GetComponent <InteractionSound>();
     trailRenderer        = GetComponent <TrailRenderer>();
 }
示例#17
0
    /// <summary>
    /// Method to set up all necessary GameObjects references for VR and Leap Motion Interaction.
    /// </summary>
    /// <param name="tdrcInterfaceRef">Reference to the ThreeDimRadarChartInterface instance.</param>
    /// <returns>True once everything has been set up.</returns>
    public bool setupForVRAndLeapMotionInteraction(ThreeDimRadarChartInterface tdrcInterfaceRef)
    {
        tdrcInterface = tdrcInterfaceRef;

        // Generally, the setup of GameObjects for Leap Motion interaction follows the same routine of:
        // (1) Attach an InteractionBehaviour component to the corresponding GameObject.
        // (2) Configure the attached InteractionBehaviour component if necessary.
        // (3) Setup EventListerners in the attached InteractionBehaviour component.

        if (tdrcInterface.interact_activationToggle != null)
        {
            InteractionBehaviour ibActivationToggle = tdrcInterface.interact_activationToggle.gameObject.AddComponent <InteractionBehaviour>();
            ibActivationToggle.ignoreGrasping = true;
            ibActivationToggle.OnPerControllerContactBegin = vrlmTriggerActivationToggleOnPerControllerContactBegin;
        }

        if (tdrcInterface.interact_rotationHandle != null)
        {
            InteractionBehaviour ibRotationHandle = tdrcInterface.interact_rotationHandle.gameObject.AddComponent <InteractionBehaviour>();
            ibRotationHandle.moveObjectWhenGrasped = true;      // Note: Movement properties can be adjusted by editing the RigidBody component of the TDRCInteractionInteractionRotationHandle GameObject
        }

        if (tdrcInterface.interact_timeSliceGO != null)
        {
            ibTimeSliceGO = tdrcInterface.interact_timeSliceGO.AddComponent <InteractionBehaviour>();
            ibTimeSliceGO.moveObjectWhenGrasped = false;
            ibTimeSliceGO.OnGraspStay           = vrlmGraspStayTimeSlice;
        }

        return(true);
    }
示例#18
0
 void Start()
 {
     thisIbehave = GetComponent <InteractionBehaviour>();
     thisABehave = GetComponent <AnchorableBehaviour>();
     thisABehave.OnDetachedFromAnchor += detach;
     initPos = gameObject.transform.position;
 }
示例#19
0
 void Start()
 {
     _intObj = GetComponent <InteractionBehaviour>();
     _intObj.OnGraspBegin      += onGraspBegin;
     _intObj.OnGraspedMovement += onGraspedMovement;
     _intObj.OnGraspEnd        += onGraspEnd;
 }
示例#20
0
 // Use this for initialization
 void Start()
 {
     gripIsReleased        = true;
     _intObj               = GetComponent <InteractionBehaviour> ();
     _intObj.OnGraspBegin += OnGraspBegin;
     _intObj.OnGraspEnd   += OnGraspEnd;
     _rigidbody            = GetComponent <Rigidbody> ();
 }
示例#21
0
 void Start()
 {
     _intObj = GetComponent <InteractionBehaviour>();
     if (_intObj != null)
     {
         _intObj.OnGraspStay += onGraspStay;
     }
 }
 // Start is called before the first frame update
 void Start()
 {
     groundObject              = GameObject.FindGameObjectWithTag("Ground");
     _intObj                   = GetComponent <InteractionBehaviour>();
     _intObj.OnContactStay    += OnContactStay;
     _intObj.OnContactEnd     += OnContactEnd;
     _intObj.OnSuspensionBegin = OnSuspension;
 }
    // Use this for initialization
    void Start()
    {
        _intObj = GetComponent <InteractionBehaviour>();
        _intObj.OnGraspBegin += onGraspBegin;
        _intObj.OnGraspEnd   += onGraspEnd;

        PhysicsCallbacks.OnPostPhysics += onPostPhysics;
    }
示例#24
0
 void Awake()
 {
     _levelController      = GameObject.FindGameObjectWithTag("LevelController").GetComponent <LevelController>();
     _interactionBehaviour = GetComponent <InteractionBehaviour>();
     _soundEffects         = GetComponent <AudioSource>();
     _currentNotes         = new List <NoteController>();
     BUTTON_START_POS      = transform.position;
 }
示例#25
0
 // Use this for initialization
 public void Init(CustomAnchor main)
 {
     interaction = GetComponent <InteractionBehaviour>();
     anchorable  = GetComponent <AnchorableBehaviour>();
     MainAnchor  = main;
     cam         = FindObjectOfType <Camera>();
     GraspEnd();
 }
示例#26
0
 private void MagnetizarPieza(Rigidbody rbdy, Transform obj, InteractionBehaviour behaviour)
 {
     behaviour.ignoreContact  = true;
     behaviour.ignoreGrasping = true;
     behaviour.ReleaseFromGrasp();
     rbdy.isKinematic      = true;
     rbdy.detectCollisions = false;
 }
 private void Start()
 {
     inFinalRotation      = false;
     attached             = false;
     keyRigidbody         = GetComponent <Rigidbody>();
     interactionBehaviour = GetComponent <InteractionBehaviour>();
     anchorableBehaviour  = GetComponent <AnchorableBehaviour>();
 }
示例#28
0
 private void Start()
 {
     claspHinge1       = clasp1.GetComponent <HingeJoint>();
     claspHinge2       = clasp2.GetComponent <HingeJoint>();
     handleInteraction = handle.GetComponent <InteractionBehaviour>();
     Debug.Log(claspHinge1);
     Debug.Log(claspHinge2);
 }
 // Use this for initialization
 void Start()
 {
     intBehaviour = GetComponent <InteractionBehaviour>();
     controllers  = new List <InteractionController>();
     foreach (var cont in InteractionManager.instance.interactionControllers)
     {
         controllers.Add(cont);
     }
 }
        private void refreshRequiredComponents()
        {
            _intObj  = GetComponent <InteractionBehaviour>();
            _anchObj = GetComponent <AnchorableBehaviour>();

            _intObj.OnGraspedMovement += onGraspedMovement;

            _anchObj.OnPostTryAnchorOnGraspEnd += onPostObjectGraspEnd;
        }