Esempio n. 1
0
        private void LoadBodyRow(RPGItem item, Inventory.BodySlot slot, bool AddNewRow)
        {
            DataRow row;

            if (AddNewRow)
            {
                row = dtBodyItems.NewRow();
            }
            else
            {
                row = dtBodyItems.Rows[(int)slot];
            }
            row[0] = Enum.GetName(typeof(Inventory.BodySlot), slot);

            if (item == null)
            {
                row[1] = "";
                row[2] = "";
                row[3] = "";
            }
            else
            {
                row[1] = item.Name;
                row[2] = GetItemType(item);
                row[3] = item.Description;
            }
            if (AddNewRow)
            {
                dtBodyItems.Rows.Add(row);
            }
        }
        private void LoadQuickItem(int index, RPGItem item)
        {
            switch (index)
            {
            case (0):
            {
                btnItem1.LoadItem(item);
                break;
            }

            case (1):
            {
                btnItem2.LoadItem(item);
                break;
            }

            case (2):
            {
                btnItem3.LoadItem(item);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Esempio n. 3
0
        public bool AddQuickItem(RPGItem item)
        {
            int  slot   = GetOpenQuickSlot();
            bool result = false;

            if (slot >= 0 && slot < QUICK_SIZE)
            {
                result = AddQuickItem(item, slot);
            }
            return(result);
        }
Esempio n. 4
0
        private bool AddItemToBody(RPGItem item, Inventory.BodySlot slot)
        {
            bool result = false;

            if (item != null && thisActor.inventory.AddBodyItem(item))
            {
                result = true;
                LoadBodyGrid(thisActor);
            }
            return(result);
        }
Esempio n. 5
0
        public void ClearItem()
        {
            if (m_item != null)
            {
                m_item = null;
            }
            ButtonText = "-";
            IsSelected = false;

            this.Refresh();
        }
Esempio n. 6
0
        public bool AddBodyItem(RPGItem item)
        {
            if (item.isOfType(typeof(RPGPotion)))
            {
                return(false);
            }
            else if (BodyItems[(int)item.Slot] != null)
            {
                return(false);
            }
            else
            {
                // the slot is empty, make sure we CAN set it here
                // if item is a wpn
                if (item.Slot == BodySlot.Hand1)
                {
                    // if wpn is two handed
                    if (((RPGWeapon)item).is2Handed == true)
                    {
                        //make sure 2nd hand is empty too.
                        if (BodyItems[(int)BodySlot.Hand2] != null)
                        {
                            return(false);
                        }
                    }
                }
                // if item to be equipped is a shield
                else if (item.Slot == BodySlot.Hand2)
                {
                    // make sure 1st hand is not a two handed weapon
                    if (BodyItems[(int)BodySlot.Hand1] != null)
                    {
                        // we have something in the wpn hand, check it.
                        RPGItem itemInHand = BodyItems[(int)BodySlot.Hand1];
                        if (itemInHand.isOfType(typeof(RPGWeapon)))
                        {
                            RPGWeapon wpn = itemInHand as RPGWeapon;
                            if (wpn.is2Handed)
                            {
                                return(false);
                            }
                        }
                    }
                }

                BodyItems[(int)item.Slot] = item;

                // this could change our stats
                Owner.UpdateAttack();
                Owner.UpdateDefense();
                return(true);
            }
        }
Esempio n. 7
0
 public bool AddQuickItem(RPGItem item, int slotZeroBased)
 {
     if (QuickItems[slotZeroBased] != null)
     {
         return(false);
     }
     else
     {
         QuickItems[slotZeroBased] = item;
         return(true);
     }
 }
Esempio n. 8
0
 public bool AddPackItem(RPGItem item)
 {
     try
     {
         PackItems[GetOpenPackSlot()] = item;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 9
0
 public RPGItem RemoveBodyItem(int slotIndex)
 {
     if (BodyItems[slotIndex] != null)
     {
         RPGItem item = BodyItems[slotIndex];
         BodyItems[slotIndex] = null;
         return(item);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 10
0
        public RPGWeapon GetWpn()
        {
            RPGItem item = BodyItems[(int)BodySlot.Hand1];

            if (item != null)
            {
                return((RPGWeapon)item);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 11
0
        void btnEquip_Click(object sender, EventArgs e)
        {
            // move selected pack item to body, at correct slot
            // if already equipped, then switch locations.
            RPGObject item = GetSelectedItemFromPack();

            // now, check if body already has an item at that slot
            if (item == null)
            {
                MessageBox.Show("No item selected from pack to equip.");
                return;
            }
            else if (item.isOfType(typeof(RPGItem)) == false)
            {
                MessageBox.Show("This item type cannot be equipped.");
                return;
            }
            else
            {
                // check if destination slot is already filled
                if (thisActor.inventory.GetBodyItem(((RPGItem)item).Slot) != null)
                {
                    // find currently equipped item and remove it
                    RPGItem currentlyEquippedItem
                        = thisActor.inventory.GetBodyItem(((RPGItem)item).Slot);

                    if (AddItemToPack(currentlyEquippedItem))
                    {
                        RemoveItemFromBody(currentlyEquippedItem);
                    }
                    else
                    {
                        MessageBox.Show("Unable to add equipped item back into pack.");
                        return;
                    }
                } // end it slot is already filled
                else
                {
                    // add new item to body
                    if (AddItemToBody(((RPGItem)item), ((RPGItem)item).Slot))
                    {
                        RemoveItemFromPack(item);
                    }
                    else
                    {
                        MessageBox.Show("Unable to equip item.");
                    }
                } // end else - destination slot empty
            }     // end else - item ok
        }
Esempio n. 12
0
        public RPGItem RemoveQuickItem(int quickSlotIndex)
        {
            RPGItem item = GetQuickItem(quickSlotIndex);

            if (item != null)
            {
                QuickItems[quickSlotIndex] = null;
                return(item);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 13
0
        private void RemoveItemFromBody(RPGItem item)
        {
            if (item == null)
            {
                return;
            }

            if (thisActor.inventory.GetBodyItem(item.Slot) == item)
            {
                thisActor.inventory.RemoveBodyItem(item.Slot);
            }
            else
            {
                // item was not on the body for removal...
            }

            LoadBodyGrid(thisActor);
        }
Esempio n. 14
0
        void btnUnEquip_Click(object sender, EventArgs e)
        {
            // move selected body item to pack
            RPGItem item = GetSelectedItemFromBody();

            if (item == null)
            {
                MessageBox.Show("No item selected from body to unequip.");
            }
            else if (AddItemToPack(item))
            {
                RemoveItemFromBody(item);
            }
            else
            {
                MessageBox.Show("Unable to unequip item from body.");
            }
        }
Esempio n. 15
0
        private RPGItem GetSelectedItemFromBody()
        {
            if (dgvBody.SelectedRows.Count == 0)
            {
                return(null);
            }
            string selDesc = dgvBody.SelectedRows[0].Cells[3].Value.ToString();

            for (int i = 0; i < Enum.GetValues(typeof(Inventory.BodySlot)).Length; i++)
            {
                RPGItem item = thisActor.inventory.GetBodyItem(i);
                if (item != null && item.Description == selDesc)
                {
                    return(item);
                }
            }

            return(null);
        }
Esempio n. 16
0
 public RPGItem RemoveQuickItem(RPGItem item)
 {
     if (item != null)
     {
         RPGItem[] items = GetQuickItems();
         for (int i = 0; i < items.Length; i++)
         {
             if (QuickItems[i] == item)
             {
                 QuickItems[i] = null;
                 return(item);
             }
         }
         return(item);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 17
0
        public void LoadItem(RPGItem item)
        {
            if (item != null)
            {
                this.m_item = item;
                if (item.Name != null &&
                    item.Name.Length > 0)
                {
                    ButtonText = item.Name;
                }
                else
                {
                    ButtonText = item.ToString();
                }

                this.Refresh();
            }
            else
            {
                ClearItem();
            }
        }