示例#1
0
 public bool HasItem(IBagThrowable item)
 {
     if (model.bagItem == null)
     {
         return(false);
     }
     return(model.bagItem.Equals(item));
 }
示例#2
0
        public void AddItemToCell(IBagThrowable item, GameObject copy)
        {
            model.bagItem = item;
            model.bagCopy = copy;

            copy.transform.SetParent(transform, false);
            copy.transform.localScale = Vector3.one * itemScale;
        }
示例#3
0
        public void RemoveItem(IBagThrowable item)
        {
            var cell = cells.FirstOrDefault(x => x.HasItem(item));

            if (cell != null)
            {
                cell.ClearCell();
            }
        }
示例#4
0
        public void AddItem(IBagThrowable item, GameObject copy)
        {
            var cell = cells.FirstOrDefault(x => x.IsFree);

            if (cell != null)
            {
                cell.AddItemToCell(item, copy);
            }
        }
        private void PlaceInTheBag(IBagThrowable item)
        {
            var itemGO = item as MonoBehaviour;

            if (itemGO != null)
            {
                Vector3 randOffset = new Vector3(Random.Range(-maxOffset, maxOffset), Random.Range(-maxOffset, maxOffset), Random.Range(-maxOffset, maxOffset));
                itemGO.transform.DOLocalMove(randOffset, 0.5f).SetEase(Ease.InOutCubic);
                itemGO.transform.DORotate(transform.rotation.eulerAngles, 0.5f).SetEase(Ease.InOutCubic);
                itemGO.transform.DOScale(Vector3.one * 0.25f, 0.5f).SetEase(Ease.InOutCubic);
                OnObjectAdded?.Invoke(item.GetID());
            }
        }
        /// <summary>
        /// Create a copy of the original item for UI
        /// </summary>
        /// <param name="item"></param>
        /// <param name="copy"></param>
        private void CreateBagCopy(IBagThrowable item, out GameObject copy)
        {
            var itemGO = item as MonoBehaviour;

            if (itemGO != null)
            {
                copy = new GameObject("Copy");
                var mF = copy.AddComponent <MeshFilter>();
                var mR = copy.AddComponent <MeshRenderer>();

                mF.sharedMesh = itemGO.GetComponent <MeshFilter>().sharedMesh;
                mR.material   = itemGO.GetComponent <MeshRenderer>().material;

                itemGO.transform.SetParent(transform, true);
                copy.transform.position   = itemGO.transform.position;
                copy.transform.rotation   = itemGO.transform.rotation;
                copy.transform.localScale = itemGO.transform.localScale / transform.localScale.x;
            }
            else
            {
                Debug.LogError("Item is not a MonoBehavior");
                copy = null;
            }
        }
 public OnBagEnterEvent(IBagThrowable item)
 {
     this.item = item;
 }
示例#8
0
 public OnBagLeaveEvent(IBagThrowable item)
 {
     this.item = item;
 }