Basic中用于RPG型游戏的库存系统

Basic中用于RPG型游戏的库存系统

本文介绍了Visual Basic中用于RPG型游戏的库存系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何创建类似于RPG游戏中的库存系统,当您获得物品时,该物品将被收集到分组控件中?我希望能够将某些物品区分为武器或装甲,并且最多可以装备2件.这些物品将增加玩家的攻击和防御.我该怎么做?

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?

推荐答案

Public Class Item

    Private itemName As String
    Private Const itemStrength as int = 100

    Property Line() As String
        Get
           Return itemName
        End Get
        Set(ByVal Value As String)
            mstrLine = Value
        End Set
    End Property

    ReadOnly Property strength() As Integer
       Get
           Return itemStrength
       End Get
    End Property
End Class



然后填充arraylist就像:



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
 ar.Add(itm);



依此类推,那么您将拥有一个将保存所有项目的arraylist. google Arraylist了解更多



and so on so then you''l have an arraylist which will hold all your items. google Arraylist for more


这篇关于Visual Basic中用于RPG型游戏的库存系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 04:12