A way to unique store some instances reference

  • Thread starter Thread starter Crirus
  • Start date Start date
C

Crirus

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?
 
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
 
* "Crirus said:
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>
 
Oh,I see.
I know now my solution is slow.
Have you ever played a game by Blizzard called
starcraft.Do you mean to make the effects like what it
have done? I think ther original map is all visible for
player.And when you place the black fog on it ,it will
seem as if there is a vision for each unit.I mean there
were be two layers on your program.One is covered by
another. So ,you didn't have to check the array every
time. Just place the fog one time and give the attention
to each change. for example ,if a marine move , his vision
will change withe him .And this time ,what you have to do
all is change the array and modify the the upper layer.You
don't have to redraw all the map now .In ohter words ,the
fog Layer can be seen as a picture paint on black.And when
you want to show the vision of a unit,just make modify the
picture's by pixels.
Say Sorry for my poor English again.
Wish this help.
Best Regards.
 
That is not a problem, neither your english.. I understand it...
I just was looking for a way to filte only visible objects from a specific
player point of view
 
Sorry ,this time I can't quite follow you.(Just because my
poor English Understanding.)
May you give me a example to descirbe your question
clearly.
 
Finaly
I know what you want to say.
U mean,how to make sure whether Marine A is in Marine B's
vision?
I will think about it.
Best regards.
 
In fact, My goal for this question was how to filter objects on the map from
a certain player point of view....
I mean, I ned a list with all object a player see and you gave me the
solution with that array :)
 
I am sorry.I don't have ICQ.For our Company did not open
the port for us to use any communication tool.And I even
haven't apply for a number yet.
I have an advise for you.
I know what you want to do now.In fact,I think you can
give echo of the unit of the map a KEYID.This KEYID can be
write in the Unit Class.And there will be many KeyID in
the certain player's vision list.When the unit class is
disposed ,remove the KeyID from the vision list.Now you
can make sure that one Unit won't be add to list twice.
Wish this Help .
Best Regards.
 
Back
Top