예제 #1
0
 [SerializeField] private DragableObj _foodBag = null; //prefab
 #endregion
 #region MonoFunction
 #endregion
 #region Function
 public override int FillIn(DragableObj bag)
 {
     if (bag.CompareTag("FoodBag"))
     {
         base.FillIn(bag);
     }
     return(-1);
 }
예제 #2
0
    private void AttachObj(DragableObj obj, Transform anchor)
    {
        obj.Attach(anchor, this);

        _currentObjAttached = obj;
        _audioSource.clip   = _attachedSound;
        _audioSource.volume = _volume;
        _audioSource.Play();
    }
예제 #3
0
    private void DetachObj()
    {
        _currentObjAttached.Detach();

        _currentObjAttached   = null;
        _hasBeenAttachedCheck = false;
        _audioSource.clip     = _detachedSound;
        _audioSource.volume   = _volume;
        _audioSource.Play();
    }
예제 #4
0
 public virtual DragableObj TakeOut()
 {
     if (_bags.Count > 0)
     {
         DragableObj b = _bags[0];
         b.gameObject.SetActive(true);
         _bags.RemoveAt(0);
         return(b);
     }
     return(null);
 }
예제 #5
0
    public int TryFeed(DragableObj food)
    {
        int score = -1;

        if (!_hasAlrBeFeed)
        {
            _hasAlrBeFeed = true;
            score         = _data.ScoreByFoodGiven;
            CanvasManager.inst.AddScore(score);
        }
        Destroy(food.gameObject);
        return(score);
    }
예제 #6
0
    public override int FillIn(DragableObj bag)
    {
        int score = -1;

        if (bag.CompareTag("Bloodbag"))
        {
            if (((BloodBag)bag).bloodInfo.Equals(info, true, true, false))
            {
                base.FillIn(bag);
                score = _data.ScoreByBloodStocked;
                CanvasManager.inst.AddScore(score);
            }
            else
            {
                Debug.Log("Your are bad: wrong shelf for this blood bag");
                Destroy(bag.gameObject);
                _audioSource.Play();
            }
        }
        return(score);
    }
예제 #7
0
 public void ForceDrop()
 {
     _currentObjAttached = null;
 }
예제 #8
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);
                 }
             }
         }
     }
 }
예제 #9
0
 public virtual int FillIn(DragableObj bag)
 {
     bag.gameObject.SetActive(false);
     _bags.Add(bag);
     return(-1);
 }