Click here to Skip to main content
11,631,796 members (72,697 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET
How can I create an inventory system like in an RPG game, where, as you get items, they'll be collected in a grouping control? I want to be able to distinguish certain items as weapons or armor, and be able to equip up to 2 of each. These items will add to the player's attack and defense. How can I do this?
Posted 7-Oct-10 10:43am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

create an items class, having the contstructor include, type, damage, etc.. all your properties.
then you can populate an 'ArrayList' with different instances of the class.

Public Class Item
    Private itemName As String
    Private Const itemStrength as int = 100
    Property Line() As String
           Return itemName
        End Get
        Set(ByVal Value As String)
            mstrLine = Value
        End Set
    End Property
    ReadOnly Property strength() As Integer
           Return itemStrength
       End Get
    End Property
End Class

then populating the arraylist would be like:
inherits System.Collections;

 dim ar as new Arraylist()
 dim Itm as new Item()
 itm.Type = "Armor"
 itm.Damage = itm.itemStrength

and so on so then you'l have an arraylist which will hold all your items. google Arraylist for more
drummerboy0511 at 8-Oct-10 10:12am
What is the "mstrLine = Value" line in the first block of code? It's causing an error on my machine... what is it supposed to do?
JFergulbops at 15-Oct-10 10:02am
parameter passd to the set sry my bad

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS

Advertise | Privacy | Mobile
Web04 | 2.8.150728.1 | Last Updated 8 Oct 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100