예제 #1
0
        private void zdjecie_Click(object sender, EventArgs e)
        {
            if (EquippedArmor.Items.Count > 0 && EquippedArmor.Items[0].Selected == true)
            {
                Przedmiot P = postac.getZalozonaZbroja() as Przedmiot;
                if (P != null)
                {
                    EquippedArmor.Items[0].Selected = false;

                    if (EquippedWeapon.Items.Count > 0 && EquippedWeapon.Items[0].Selected == true)
                    {
                        EquippedWeapon.Items[0].Selected = false;
                    }

                    listBox1.Items.Add(postac.getZalozonaZbroja().getNazwa().ToString() + " - " + postac.getZalozonaZbroja().getIlosc().ToString());
                    postac.Ekwipunek.Add(postac.getZalozonaZbroja());
                    EquippedArmor.Clear();
                    imageList1.Images.RemoveAt(0);
                    postac.ZalozZbroje(null);

                    Sound.PlaySound(Sound.Sound_weararmor);
                }

                P = null;
            }
            else if (EquippedWeapon.Items.Count > 0 && EquippedWeapon.Items[0].Selected == true)
            {
                Przedmiot P = postac.getZalozonaBron() as Przedmiot;
                if (P != null)
                {
                    EquippedWeapon.SelectedItems[0].Selected = false;

                    if (EquippedArmor.Items.Count > 0 && EquippedArmor.Items[0].Selected == true)
                    {
                        EquippedArmor.Items[0].Selected = false;
                    }

                    listBox1.Items.Add(postac.getZalozonaBron().getNazwa().ToString() + " - " + postac.getZalozonaBron().getIlosc().ToString());
                    postac.Ekwipunek.Add(postac.getZalozonaBron());
                    postac.addStrenght(-1 * postac.getZalozonaBron().getItemStrength());
                    EquippedWeapon.Clear();
                    imageList2.Images.RemoveAt(0);
                    postac.ZalozBron(null);

                    Sound.PlaySound(Sound.Sound_wearweapon);
                }

                P = null;
            }

            UpdateEquipment(postac);
        }
    public void Drop(Item item)
    {
        if (item.IsEquippable)
        {
            if (LeftHand == item)
            {
                Unequip(WeaponSlot.LEFT_HAND);
            }
            else if (RightHand == item)
            {
                Unequip(WeaponSlot.RIGHT_HAND);
            }
            else if (EquippedArmor.Contains((Equippable)item))
            {
                EquippedArmor.Remove((Equippable)item);
            }
            else if (m_EquippableItems.Contains((Equippable)item))
            {
                m_EquippableItems.Remove((Equippable)item);
            }
            else
            {
                return;
            }
        }
        else if (m_MiscItems.Contains(item))
        {
            m_MiscItems.Remove(item);
        }
        else
        {
            return;
        }

        item.transform.SetParent(null);
        item.ToggleItem(true);
        GameController.InvokeDroppedItem(this, Owner, item);
    }
 // Start is called before the first frame update
 void Start()
 {
     equippedScript = GameObject.Find("Armor Slots").GetComponent <EquippedArmor>();
 }
예제 #4
0
        private void uzycie_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem != null)
            {
                Przedmiot P = postac.Ekwipunek.ElementAt(listBox1.SelectedIndex) as Przedmiot;
                if (P != null)
                {
                    if (P.getItemType() == ItemType.Armor)
                    {
                        if (postac.getZalozonaZbroja() != null)
                        {
                            listBox1.Items.Add(postac.getZalozonaZbroja().getNazwa().ToString() + " - " + postac.getZalozonaZbroja().getIlosc().ToString());
                            postac.Ekwipunek.Add(postac.getZalozonaZbroja());
                            EquippedArmor.Clear();
                            imageList1.Images.RemoveAt(0);
                        }

                        postac.ZalozZbroje(P as Zbroja);
                        imageList1.Images.Add((P as Zbroja).getArmorImage());

                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.ImageIndex = 0;
                        EquippedArmor.Items.Add(listViewItem);

                        postac.Ekwipunek.RemoveAt(listBox1.SelectedIndex);
                        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                        listBox1.ClearSelected();

                        Sound.PlaySound(Sound.Sound_weararmor);
                    }
                    else if (P.getItemType() == ItemType.Consumable)
                    {
                        if (P.GetType() == typeof(Mikstury))
                        {
                            Mikstury potion = P as Mikstury;
                            postac.SetHP(postac.GetHP() + potion.getPotionHp());
                            postac.SetMP(postac.GetMP() + potion.getPotionMp());
                        }

                        postac.addStrenght(P.getItemStrength());
                        postac.addDexterity(P.getItemDexterity());
                        postac.addIntelligence(P.getItemIntelligence());


                        if (postac.Ekwipunek.ElementAt(listBox1.SelectedIndex).getIlosc() == 1)
                        {
                            postac.Ekwipunek.RemoveAt(listBox1.SelectedIndex);
                            listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                            listBox1.ClearSelected();
                        }
                        else
                        {
                            postac.Ekwipunek.ElementAt(listBox1.SelectedIndex).zmniejszIlosc(1);
                            listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                            listBox1.ClearSelected();
                        }

                        Sound.PlaySound(Sound.Sound_healing);
                    }
                    else if (P.getItemType() == ItemType.Weapon)
                    {
                        if (postac.getZalozonaBron() != null)
                        {
                            listBox1.Items.Add(postac.getZalozonaBron().getNazwa().ToString() + " - " + postac.getZalozonaBron().getIlosc().ToString());
                            postac.Ekwipunek.Add(postac.getZalozonaBron());
                            postac.addStrenght(-1 * postac.getZalozonaBron().getItemStrength());
                            EquippedWeapon.Clear();
                            imageList2.Images.RemoveAt(0);
                        }

                        postac.ZalozBron(P as Bron);
                        postac.addStrenght(postac.getZalozonaBron().getItemStrength());
                        imageList2.Images.Add((P as Bron).getWeaponImage());

                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.ImageIndex = 0;
                        EquippedWeapon.Items.Add(listViewItem);

                        postac.Ekwipunek.RemoveAt(listBox1.SelectedIndex);
                        listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                        listBox1.ClearSelected();

                        Sound.PlaySound(Sound.Sound_wearweapon);
                    }
                }

                P = null;
            }

            UpdateEquipment(postac);
        }
예제 #5
0
 // Start is called before the first frame update
 void Start()
 {
     equippedWeaponScript = GameObject.Find("Weapon Slot").GetComponent <EquippedWeapon>();
     equippedArmorScript  = GameObject.Find("Armor Slots").GetComponent <EquippedArmor>();
     weaponStats          = GameObject.Find("Gun Stats Inventory");
 }