Exemple #1
0
        private void OnItemPickedUp(ItemPickupEventInfo ui)
        {
            switch (ui.HeroName)
            {
            case "Mage": GiveItemToHero("Mage");
                break;

            case "Ranger":
                GiveItemToHero("Ranger");
                break;

            case "Warrior":
                GiveItemToHero("Warrior");
                break;
            }
        }
Exemple #2
0
        void Update()
        {
            if (Input.GetButtonDown("InventoryP" + m_PlayerID))
            {
                m_hero.inventory.m_inventoryEnabled = !m_hero.inventory.m_inventoryEnabled;
                if (m_hero.inventory.m_inventoryEnabled)
                {
                    m_hero.inventory.m_inventory.SetActive(true);
                    inventoryEnabled = true;
                    eventSystem.SetSelectedGameObject(m_hero.m_FirstInventorySlot);
                }
                else
                {
                    m_hero.inventory.m_inventory.SetActive(false);
                    inventoryEnabled = false;
                }
            }


            if (!inventoryEnabled)
            {
                if (m_PlayerID == 0)
                {
                    Debug.Log("You forgot to give your players ID-s");
                }
                else
                {
                    velocity = new Vector2(Input.GetAxisRaw("Horizontal" + m_PlayerID), Input.GetAxisRaw("Vertical" + m_PlayerID)).normalized *m_MovementSpeed;
                }

                // ATTACK BASIC
                if (Input.GetButtonDown("BasicAttackP" + m_PlayerID))
                {
                    m_hero.Attack();
                }

                //USE SPELL 1
                if (Input.GetButtonDown("SpellOneP" + m_PlayerID))
                {
                    m_hero.UseSkill(1);
                }

                //
                if (Input.GetButtonDown("UseP" + m_PlayerID))
                {
                    if (m_hero.bags > 0)
                    {
                        ItemPickupEventInfo ipei = new ItemPickupEventInfo();
                        ipei.EventDescription = "your hero wants to pick up an item";
                        ipei.HeroName         = m_hero.gameObject.name;
                        EventSystem.Current.FireEvent(ipei);
                    }
                }
            }
            else
            {
                if (eventSystem.currentSelectedGameObject != null)
                {
                    go = eventSystem.currentSelectedGameObject;
                }
                if (eventSystem.currentSelectedGameObject == null)
                {
                    eventSystem.SetSelectedGameObject(go);
                }

                if (Input.GetButtonDown("BasicAttackP" + m_PlayerID))
                {
                    m_hero.Attack();
                }
            }
        }