コード例 #1
0
 /// <summary> Add a target object. </summary>
 /// <param name="obj"></param>
 public void AddTarget(SG_Grabable obj)
 {
     if (obj != null)
     {
         this.objectsToGet.Add(obj);
     }
 }
コード例 #2
0
 /// <summary> Check if this SG_SenseGloveHardware is one of the "goal" objects; </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public bool IsTarget(SG_Grabable obj)
 {
     if (this.objectsToGet.Count > 0)
     {
         return(SG_DropZone.ListIndex(obj, this.objectsToGet) > -1);
     }
     return(true); //we can accept any kind of Object.
 }
コード例 #3
0
 /// <summary>  Calls the ObjectRemoved event  </summary>
 /// <param name="removedObject"></param>
 protected virtual void CallObjectRemoved(SG_Grabable removedObject)
 {
     //Debug.Log(this.name + ": " + removedObject.name + " Removed!");
     if (this.ObjectRemoved != null)
     {
         this.ObjectRemoved(this, new DropZoneArgs(removedObject));
     }
     this.OnObjectRemoved.Invoke();
 }
コード例 #4
0
 /// <summary> Calls the ObjectDetected event </summary>
 /// <param name="detectedObject"></param>
 protected virtual void CallObjectDetect(SG_Grabable detectedObject)
 {
     //Debug.Log(this.name + ": " + detectedObject.name + " Detected!");
     if (this.ObjectDetected != null)
     {
         this.ObjectDetected(this, new DropZoneArgs(detectedObject));
     }
     this.OnObjectDetected.Invoke();
 }
コード例 #5
0
    protected virtual void CheckObjectExit(GameObject obj)
    {
        SG_Grabable grabableScript = obj.GetComponent <SG_Grabable>();

        if (grabableScript != null)
        {
            this.RemoveObject(grabableScript); //RemoveObject(Grabable) will check for indices etc.
        }
    }
コード例 #6
0
    /// <summary> Check if a newly incoming object belongs to our targets. </summary>
    /// <param name="obj"></param>
    protected virtual void CheckObjectEnter(GameObject obj)
    {
        SG_Grabable grabableScript = obj.GetComponent <SG_Grabable>();

        if (grabableScript != null && this.IsTarget(grabableScript) && !this.IsDetected(grabableScript))
        {
            this.AddObject(grabableScript);
        }
    }
コード例 #7
0
    /// <summary> Removes a specific object from this SenseGlove_DropZone </summary>
    /// <param name="grabable"></param>
    public virtual void RemoveObject(SG_Grabable grabable)
    {
        int objIndex = SG_DropZone.ListIndex(grabable, this.objectsInside);

        if (objIndex > -1)
        {
            this.RemoveObject(objIndex);
        }
    }
コード例 #8
0
        protected void CheckReset(Collider other)
        {
            SG_Grabable grabable = other.gameObject.GetComponent <SG_Grabable>();

            if (other.tag.Contains(this.resetTag) && grabable != null && !grabable.IsInteracting())
            {
                grabable.ResetObject();
                //Debug.Log("Reset " + other.name);
            }
        }
コード例 #9
0
    /// <summary> Adds an object to this SenseGlove_DropZone. Does not fire the eventTime. </summary>
    /// <param name="grabable"></param>
    public virtual void AddObject(SG_Grabable grabable)
    {
        this.objectsInside.Add(grabable);
        this.dropProperties.Add(new DropProps());

        if (this.detectionTime == 0 && (!grabable.IsInteracting() || this.detectHeldObjects))
        {
            this.dropProperties[this.dropProperties.Count - 1].detected = true; //mark that we have detected it!
            this.CallObjectDetect(grabable);
        }
    }
コード例 #10
0
        //--------------------------------------------------------------------------------------------------------------------------
        // Functions

        /// <summary> Check if you can reset a collider. </summary>
        /// <param name="other"></param>
        protected void CheckReset(Collider other)
        {
            SG_Grabable grabable = other.gameObject.GetComponent <SG_Grabable>();

            if (grabable == null && other.attachedRigidbody != null)
            {
                grabable = other.attachedRigidbody.GetComponent <SG_Grabable>();
            }
            if (grabable != null && !grabable.IsInteracting() && other.tag.Contains(this.resetTag))
            {
                grabable.ResetObject();
            }
        }
コード例 #11
0
    // Detection Logic

    #region Detection

    /// <summary> Retrieve the index of a Grabable within a list of Grabables. </summary>
    /// <param name="obj"></param>
    /// <param name="grabables"></param>
    /// <returns> Returns -1 if obj does not exist in grabables. </returns>
    public static int ListIndex(SG_Grabable obj, List <SG_Grabable> grabables)
    {
        if (obj != null)
        {
            for (int i = 0; i < grabables.Count; i++)
            {
                if (GameObject.ReferenceEquals(obj.pickupReference.gameObject, grabables[i].pickupReference.gameObject))
                {
                    return(i);
                }
            }
        }
        return(-1);
    }
コード例 #12
0
 /// <summary> Check if this Object has already been detected. </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public bool IsDetected(SG_Grabable obj)
 {
     return(SG_DropZone.ListIndex(obj, this.objectsInside) > -1);
 }
コード例 #13
0
 /// <summary> Create a new instance of the DropZoneArgs. </summary>
 /// <param name="obj"></param>
 public DropZoneArgs(SG_Grabable obj)
 {
     this.grabable = obj;
 }