一种独特的方式存储一些实例引用 [英] A way to unique store some instances reference

查看:54
本文介绍了一种独特的方式存储一些实例引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在游戏中有一张地图。我需要为一个

玩家制作一个包含所有可见对象的列表

因此,任何建筑物和任何单位都可以在地图上提供一系列可见性。


现在VB问题:


如何在集合中存储可见对象的引用,

确保我添加一个对象只有一次......?


此外..如何确定某个对象是否属于可见的

列表......


我可以从播放器可见的所有区域获得一个GraphicsPath,并且

遍历所有其他玩家的对象,并检查它是否在内部

可见的GraphicsPath,但是我注意到即使路径中添加了2个圆圈,GraphicsPath.IsVisible仍然很慢......

有什么想法?< br $> b $ b -

Ceers,

Crirus


---------- --------------------

如果工作是件好事,那么老板就会把这一切都从你身上带走

------------ ------------------

解决方案

对不起,我不擅长英语。

但是我仍然可以猜出你想表达什么。

我不能用英语清楚地表达我的想法,所以我试着

使用一些例子。

你可以制作一张你感染过的地图表。

这张表有一个X,Y的位置。一个阵列可以存放

it,A(640,480)恢复地图的信息大小

是640 * 480.如果你有一个叫海洋的单位,那就是它的愿景

视线是10,这个海军陆战队员的位置是(400,300)。那么

for i = 400-10 to 400 + 10

j = 300 -10到300 + 10

如果a(i,j)= 0那么

A(i,j)= 1

结束if

next

next

如果另一个海军陆战队员来近,你也可以做同样的b $ b操作。 />
希望这可以帮到你。

最好的问候菜单陈

如果它的位置是0或1,那么我只需要为每个其他对象ckeck

那个阵列...好的想法


这样一来,不需要GraphPath


四处,我可能还有一些其他的q,看起来你是最新的

这个问题:)


谢谢


-

Ceers,

Crirus


------------------------------

如果工作是好事,老板会把这一切都从你那里拿走


------------------------- -----


" Menu Chen" <一个******* @ discussions.microsoft.com>在消息中写道

news:09 **************************** @ phx.gbl ... < blockquote class =post_quotes>对不起,我不擅长英语。
但是我仍然可以猜出你想表达什么。
我不能用英语清楚地表达我的想法,所以我尝试使用一些示例。
你可以制作一张你感染过的地图表。
这张桌子有一个X,Y的位置。一个阵列可以存放它吧, A(640,480)恢复地图的信息,大小
是640 * 480.如果你有一个叫做海军陆战队的单位,它的视野将是10,这个海军陆战队员的位置是(400,300)。然后对于i = 400-10到400 + 10
对于j = 300-10到300 + 10
如果a(i,j)= 0那么
A(i,j)= 1
如果下一个结束
下一个
如果另一个海军陆战队员来到附近,你也可以做同样的操作。

最好的问候陈菜单



*" Crirus" <铬**** @ datagroup.ro> scripsit:

我在游戏中有一张地图。我需要为一个
播放器制作一个包含所有可见对象的列表
因此,任何建筑物和任何单元都可以提供对地图的一系列可见性。

现在VB问题:

如何将可见对象的引用存储在集合中,以确保我只添加一个对象...?




您可以将它们添加到''Hashtable''。


-

Herfried K. Wagner

MVP·VB Classic,VB.NET

< http://www.mvps.org/dotnet>


< http:// www。 plig.net/nnq/nquote.html>


I have a map in a game. I need to make a list with all visible objects for a
player
So, any building and any unit offer a range of visibility over the map.

Now VB question:

How can I store the references of that visible objects in a collection, to
make sure I added one object only once...?

Moreover ..how to determine if a certain object belong to the visible
list...

I could have a GraphicsPath from all regions visible to the the Player and
iterate through all other players''s objects, and check out if it is inside
the visible GraphicsPath, but I noticed that GraphicsPath.IsVisible is very
slow even with 2 circles added to the path...
Any thoughts?
--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

解决方案

I am sorry I am not good at English.
But I can still guess what you want to express.
I can''t express my thoughts clearly in English,so I try to
use some Example.
You can make a table of that map your have infered.
This table have a X,Y location.An array can eailsy store
it, A(640,480) restores an map''s information which size
is 640*480.If you have a unit Called marine ,it''s vision
sight is 10,and this marine''s position is (400,300).Then
for i=400-10 to 400+10
for j=300-10 to 300+10
If a(i,j)=0 then
A(i,j)=1
End if
next
next
If another Marine come to nearbY, you can do same
operation too.
Wish this can help you .
Best Regards Menu Chen


And I only have to ckeck for each other object if it''s location is 0 or 1 in
that array... good ideea

This way, no need for GraphPath

Say around, I may have some other q for you and seems you are up to date on
this issues :)

Thanks

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Menu Chen" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...

I am sorry I am not good at English.
But I can still guess what you want to express.
I can''t express my thoughts clearly in English,so I try to
use some Example.
You can make a table of that map your have infered.
This table have a X,Y location.An array can eailsy store
it, A(640,480) restores an map''s information which size
is 640*480.If you have a unit Called marine ,it''s vision
sight is 10,and this marine''s position is (400,300).Then
for i=400-10 to 400+10
for j=300-10 to 300+10
If a(i,j)=0 then
A(i,j)=1
End if
next
next
If another Marine come to nearbY, you can do same
operation too.
Wish this can help you .
Best Regards Menu Chen



* "Crirus" <Cr****@datagroup.ro> scripsit:

I have a map in a game. I need to make a list with all visible objects for a
player
So, any building and any unit offer a range of visibility over the map.

Now VB question:

How can I store the references of that visible objects in a collection, to
make sure I added one object only once...?



You can add them to a ''Hashtable''.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>


这篇关于一种独特的方式存储一些实例引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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