Esempio n. 1
0
 public void MouseUpAsButton()
 {
     if (isPicked && isDragging)
     {
         Collider2D[] _overlaps = Physics2D.OverlapPointAll((Vector2)transform.position);
         if (_overlaps.Length > 0)
         {
             bool isInInventory = false;
             bool alreadySwitch = false;
             foreach (Collider2D _c in _overlaps)
             {
                 if (_c.gameObject.name == "Inventory")
                 {
                     isInInventory = true;
                 }
                 Class_PassiveItem _itemClass = _c.GetComponent <Class_PassiveItem>();
                 if (!alreadySwitch && _itemClass != null && _itemClass.isPicked && _itemClass.gameObject != gameObject)
                 {
                     alreadySwitch = true;
                     ItemProgress.instance.SwitchItem(gameObject, _c.gameObject);
                     inventoryObject.transform.parent.SendMessage("DetailClose", passiveItemInfo.details);
                 }
             }
             if (!isInInventory)
             {
                 ItemProgress.instance.DropItem(gameObject);
                 inventoryObject.transform.parent.SendMessage("DetailClose", passiveItemInfo.details);
             }
         }
     }
     isDragging        = false;
     somethingDragging = false;
 }
Esempio n. 2
0
        void DetailOpen(Class_PassiveItem itemInfo)
        {
            if (detailText.transform.parent.gameObject.activeInHierarchy || !inventoryPopup)
            {
                return;
            }
            detailText.transform.parent.gameObject.SetActive(true);
            itemInfo.GetComponent <Rigidbody2D>().velocity = Vector2.zero;

            Text itemText = itemName.GetComponent <Text>();

            itemText.text = itemInfo.passiveItemInfo.name;
            Text textUI = detailText.GetComponent <Text>();

            textUI.text = itemInfo.passiveItemInfo.details;
            StartCoroutine("DetailFollow", itemInfo.transform);
        }
Esempio n. 3
0
        float PlayerDamageModify(float _damage)
        {
            List <Func <float, float> > _sortedFuncList = new List <Func <float, float> >();

            foreach (GameObject _IGO in ItemProgress.instance.itemEquipList)
            {
                if (_IGO != null)
                {
                    Class_PassiveItem pi = _IGO.GetComponent <Class_PassiveItem>();
                    if (pi != null)
                    {
                        string itemID = pi.passiveItemInfo.ToString();
                        itemID = itemID.Substring(0, itemID.IndexOf(' '));
                        //Debug.Log(itemID);
                        if (playerDamagedModifyerList.Count != 0)
                        {
                            foreach (Func <float, float> _func in playerDamagedModifyerList)
                            {
                                //Debug.Log(_func.Method.DeclaringType.Name);
                                if (itemID == _func.Method.DeclaringType.Name)
                                {
                                    _sortedFuncList.Add(_func);
                                    break;
                                }
                            }
                        }
                    }
                }
                if (_sortedFuncList.Count != 0)
                {
                    int i = 0;
                    foreach (Func <float, float> _func in _sortedFuncList)
                    {
                        i++;
                        Debug.Log("Sorted " + i + ":" + _func.Method.DeclaringType.Name);
                        if (_func != null)
                        {
                            _damage = _func(_damage);
                        }
                    }
                }
            }

            return(_damage);
        }
Esempio n. 4
0
        void Update()
        {
            if (gameObject.transform.parent == null)
            {
                InActiveInventory();
                return;
            }

            if (Input.GetKeyDown(KeyCode.Tab))
            {
                if (!inventoryPopup)
                {
                    ActiveInventory();
                }
                else
                {
                    InActiveInventory();
                }
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                InActiveInventory();
            }

            Collider2D[] hit;
            hit = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition));

            bool inactiveInventory = true;
            bool exitbutton        = false;

            foreach (Collider2D _hit in hit)
            {
                Class_PassiveItem _class = _hit.transform.GetComponent <Class_PassiveItem>();
                if (_class != null && _class.m_triggerCollider)
                {
                    _class.MouseEnter();
                    if (Input.GetMouseButtonDown(0))
                    {
                        _class.MouseDown();
                    }
                    else if (Input.GetMouseButton(0))
                    {
                        _class.OnMouseDrag();
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        _class.MouseUpAsButton();
                    }
                }

                if (!exitbutton)
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        if (_hit.name == "ExitButton")
                        {
                            exitbutton = true;
                        }
                        else if (_hit.name == "Inventory")
                        {
                            inactiveInventory = false;
                        }
                    }
                    else
                    {
                        inactiveInventory = false;
                    }
                }
            }
            if (inventoryPopup && (inactiveInventory || exitbutton))
            {
                InActiveInventory();
            }

            foreach (GameObject _go in ItemProgress.instance.itemEquipList)
            {
                bool _exist = false;
                foreach (Collider2D _hit in hit)
                {
                    if (_go != null && _hit.transform.gameObject == _go.transform.gameObject)
                    {
                        _exist = true;
                        break;
                    }
                }
                if (!_exist && _go != null)
                {
                    _go.GetComponent <Class_PassiveItem>().MouseExit();
                }
            }
            foreach (GameObject _go in ItemProgress.instance.itemList)
            {
                bool _exist = false;
                foreach (Collider2D _hit in hit)
                {
                    if (_go != null && _hit.transform.gameObject == _go.transform.gameObject)
                    {
                        _exist = true;
                        break;
                    }
                }
                if (!_exist && _go != null)
                {
                    _go.GetComponent <Class_PassiveItem>().MouseExit();
                }
            }
        }