Collection<VertexRoom> vr = new ArrayList<VertexRoom>();
Collection<VertexRoom> vr2 = new ArrayList<VertexRoom>();
Collection<VertexRoom> vr_light = new ArrayList<VertexRoom>();
Collection<Edge> eg = new ArrayList<Edge>();
vr.add((VertexRoom) bob.getLocation());
VertexRoom t, tve;
Iterator<VertexRoom> it_v;
Iterator<Edge> it_eg;
Edge te;
while (distance<distanceMax)
{
it_v = vr.iterator();
while (it_v.hasNext())
{
t = it_v.next();
vr_light.add(t);
eg = t.getEdges();
it_eg = eg.iterator();
while (it_eg.hasNext())
{
te = it_eg.next();
tve = (VertexRoom) te.getOtherVertex((Vertex) t);
if (!vr_light.contains(tve))
vr2.add(tve);
}
r = ((Square) t).getRow();
c = ((Square) t).getColumn();
if (((KeyboardCharacter) bob).lightIsOn())
{
t.setLight(distanceMax-distance-1);
g.drawImage(roomIcons[t.getLight()].getImage(), c*unite, r*unite, null);
if(t.isThereKey())
g.drawImage(key.getImage(), c * unite, r * unite, null);
}
else
t.setLight(0);
}
vr.clear();
vr.addAll(vr2);
vr2.clear();
distance++;