我该如何检查多少次“次”我以前添加了一个项目? [英] How do i check how many "times" ago i added an item?

查看:57
本文介绍了我该如何检查多少次“次”我以前添加了一个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喂!我有一个问题。我为我玩的游戏制作了一个程序,我需要一些帮助。我有一个列表框,我在其中添加了我从老板那里得到的物品,然后我可以看到我有一件物品有多少以及收到物品的机会有多大。列表可能如下所示:



1.魔法种子

2.魔术日志

3.绿色dragonhide

4. Torva板体

5.绿色龙皮

6. Saradomin酿造

7.纯净精华



我想要做的是看看有多少杀死之前我添加了Torva板体。正如你所看到的那样,它已经灭了3个星期。我只是不知道我应该如何编写代码来使程序计算它。我想让它在下次打开程序时就在那里。我在列表框中读到了一个文本文件,其中所有项目都是,然后我可以看到我在标签等中有多少项目。但我怎么能看到多少次杀死之前我添加了项目 Torva platebody?

Hey! I got a question. I make a program to a game i play and i need some help. I have a listbox where i add items i get from a boss, i can then see how many of one item i''ve got and how big chance of recieving the item are. the list can look like this:

1. Magic seed
2. Magic logs
3. Green dragonhide
4. Torva platebody
5. Green dragonhide
6. Saradomin brews
7. Pure essence

what i want to do is to see how many "kills" ago i added the Torva platebody. And as you can see it''s 3 kills ago. I just don''t know how i should write the code to make the program count it. I want it to be there next time i open the program. I read a text file into the listbox where all that item is and then i can see how many of one item i''ve got in a label etc.. But how can i do to see how many kills ago i added the item "Torva platebody"?

推荐答案

这只是一个如何增加而不是作为线程解决方案的例子。代码在这里更具可读性。

This is only an example of how to increment and not to be taken as a solution to the thread. Code is more readable here.
public static void Kill()
{
    int killIncrementer = 0;
    killIncrementer++;
}





每次发生杀戮时,只需增加一个int。您可以随时存储该号码或将其设置为标签。



That just increments an int eachtime a kill happens. You will want to store that number or set it to a label whenever you want.


这篇关于我该如何检查多少次“次”我以前添加了一个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆