Example #1
0
    private void OnTriggerStay2D(Collider2D other)
    {
        if (host)
        {
            if (other.GetInstanceID() != subjectColliderID)
            {
                return;
            }
        }
        if (occupied)                                //if it is occupied
        {
            if (!obj.isCentered)                     //and our object is not centered
            {
                obj.Center(this.transform.position); //we will center it
            }
        }
        else            //if it is not occupied
        {
            Drag_obj otherDrag = other.GetComponent <Drag_obj>();

            if ((type == otherDrag.type) || (type == "")) //if it our type
            {
                obj      = otherDrag;                     //it is ours now
                occupied = true;

                obj.Center(this.transform.position);        //and we will center it
                obj.centeringNow = true;
            }
        }
    }
Example #2
0
    public void Start()
    {
        obj     = subject.GetComponent <Drag_obj>();
        gesture = obj.GetComponent <TransformGesture>();

        obj.WaitAndCenter(transform.position);
        obj.Raise();
    }
Example #3
0
    public void OnTriggerExit2D(Collider2D other)
    {
        Drag_obj otherDrag = other.GetComponent <Drag_obj>();

        if (obj.GetInstanceID() == otherDrag.GetInstanceID()) //if it is our object, who came out
        {
            StartCoroutine(TakeBack());                       //get him back
        }
    }
Example #4
0
    public void OnTriggerExit2D(Collider2D other)
    {
        if (null != obj)            //if we have an object
        {
            Drag_obj otherDrag = other.GetComponent <Drag_obj>();

            if (obj.GetInstanceID() == otherDrag.GetInstanceID()) //if it is our object
            {
                if (isDestination)                                //and object has not reached a cake
                {
                    obj.hasReachedDestination = false;
                }
                obj      = null;        //then slot is free
                occupied = false;
            }
        }
    }
Example #5
0
 IEnumerator TakeBack()
 {
     while (gesture.ActiveTouches.Count != 0)
     {
         yield return(new WaitForEndOfFrame());
     }
     if (gesture.ActiveTouches.Count == 0)       // if we are not holding
     {
         if (obj.hasReachedDestination == false) //if object has not reached destination
         {
             obj.Center(transform.position);     //center it
             yield break;
         }
         else
         {
             this.GetComponent <Slot>().occupied = false;     //else free slot
             this.GetComponent <Slot>().obj      = null;
         }
     }
     //return null;
 }
Example #6
0
    private void OnTriggerStay2D(Collider2D other)
    {
        if (other.GetComponent <Drag_obj>() != null && other.GetComponent <Drag_obj>().dropped&& gameObject.GetComponent <BoxCollider2D>().enabled)
        {
            other.gameObject.transform.position = gameObject.transform.position;
            other.gameObject.transform.rotation = gameObject.transform.rotation;
            other.gameObject.transform.parent   = gameObject.transform;
            Drag_obj este = other.GetComponent <Drag_obj>();

            if (este.isRight == isRight && este.isArm == isArm)
            {
                FindObjectOfType <Score>().AddScore(temporizador.result * (temporizador.result / temporizador.time));
            }
            else
            {
                Debug.Log("Errado");
            }
            other.GetComponent <BoxCollider2D>().enabled      = false;
            gameObject.GetComponent <BoxCollider2D>().enabled = false;
            FindObjectOfType <Montagem>().Depart();
            check_enabled();
        }
    }
Example #7
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (host)
        {
            if (other.GetInstanceID() != subjectColliderID)
            {
                return;
            }
        }
        if (!occupied)      //if it is not occupied
        {
            Drag_obj otherDrag = other.GetComponent <Drag_obj>();

            if ((type == otherDrag.type) || (type == "")) //then, if type matches
            {
                occupied = true;                          //it is occupied now
                obj      = otherDrag;
                if (isDestination)
                {
                    obj.hasReachedDestination = true;
                }
            }
        }
    }