Esempio n. 1
0
 private void TryGrab()
 {
     Collider[] cols = Physics.OverlapSphere(_grabCenter.position, .75f, _interactObj);
     if (cols != null && cols.Length > 0)
     {
         if (cols[0].CompareTag("Donor"))
         {
             BloodDonor donor = (cols[0].GetComponent <BloodDonor>());
             if (donor.state != BloodDonor.State.taking && donor.state != BloodDonor.State.leave && donor.state != BloodDonor.State.rageQuit)
             {
                 AttachObj(donor, _attrachAnchor);
                 SetBul(true, sprites[(int)donor.bloodInfo.type - 1], "" + donor.bloodInfo.family);
                 ResetHighlightAndBul(false);
             }
             else if (donor.state == BloodDonor.State.rageQuit)
             {
                 donor.PlayRageSound();
             }
         }
         else if (cols[0].CompareTag("Bloodbag"))
         {
             BloodBag bloodbag = (cols[0].GetComponent <BloodBag>());
             AttachObj(bloodbag, _grabCenter);
             SetBul(true, sprites[(int)bloodbag.bloodInfo.type - 1], "" + bloodbag.bloodInfo.family);
             ResetHighlightAndBul(false);
         }
         else if (cols[0].CompareTag("FoodBag"))
         {
             FoodBag bloodbag = (cols[0].GetComponent <FoodBag>());
             AttachObj(bloodbag, _grabCenter);
             ResetHighlightAndBul(true);
         }
     }
     else
     {
         cols = Physics.OverlapSphere(_grabCenter.position, .75f, _interactPlace);
         if (cols != null && cols.Length > 0)
         {
             if (cols[0].CompareTag("BloodShelf") || cols[0].CompareTag("FoodShelf"))
             {
                 Shelf shelf = cols[0].GetComponent <Shelf>();
                 if (shelf != null)
                 {
                     DragableObj b = shelf.TakeOut();
                     if (b != null)
                     {
                         AttachObj(b, _grabCenter);
                         if (b is BloodBag)
                         {
                             BloodBag bloodBag = ((BloodBag)b);
                             SetBul(true, sprites[(int)bloodBag.bloodInfo.type - 1], "" + bloodBag.bloodInfo.family);
                         }
                     }
                 }
             }
             else if (cols[0].CompareTag("CallCenter"))
             {
                 CallCenter cc = cols[0].GetComponent <CallCenter>();
                 if (cc != null)
                 {
                     cc.Open(this);
                 }
             }
         }
     }
 }