예제 #1
0
 public void AddItem(Transform item, OhSnap os)
 {
     if (!ownerToCollection.ContainsKey(os))
     {
         ownerToCollection.Add(os, new List <Transform>());
     }
     ownerToCollection[os].Add(item);
 }
예제 #2
0
    private void GrabbedObject_Update()
    {
        if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger) || Input.GetKeyDown(KeyCode.C))
        {
            fsm.ChangeState(RaycastStates.Raycast);
        }
        if (OVRInput.GetDown(OVRInput.Button.Two) || Input.GetKeyDown(KeyCode.F))
        {
            fsm.ChangeState(RaycastStates.ManipulateObject);
        }

        if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger) || Input.GetKeyDown(KeyCode.T)) //attach
        {
            OhSnap snap = Utility.GetSafeComponent <OhSnap>(grabbedObject);
            snap.SnapJoints();
        }
        if (OVRInput.GetDown(OVRInput.Button.PrimaryHandTrigger) || Input.GetKeyDown(KeyCode.Y)) //detach
        {
            Debug.Log("Break Joint");
            OhSnap snap = Utility.GetSafeComponent <OhSnap>(grabbedObject);
            snap.BreakJoints();
        }
        // ADDED
        if (OVRInput.GetDown(OVRInput.Button.PrimaryHandTrigger) && !isEnergyOn)
        {
            energy.StoreEnergy(this.grabbedObject.GetComponent <Rigidbody>());
            isEnergyOn = true;
        }
        if (OVRInput.GetDown(OVRInput.Button.One))
        {
            GameObject empty = new GameObject();
            grabbedObject.SetParent(empty.transform);
            saver.CreateTemplate(empty);
        }

        // Sets the line
        this.line.SetPosition(0, transform.position);
        if (this.grabbedObject != null)
        {
            this.line.SetPosition(1, this.grabbedObject.position);
        }
    }
예제 #3
0
 private void Awake()
 {
     joints = Utility.GetSafeComponent <OhSnap>(transform.parent.gameObject);
 }
예제 #4
0
 public void RemoveItem(Transform item, OhSnap os)
 {
     ownerToCollection[os].Remove(item);
 }
예제 #5
0
 // Finds out which game object to add joint to
 private GameObject AddJointToThis(OhSnap other)
 {
     return((GetComponent <Joint>() == null) ? gameObject : other.gameObject);
 }