Esempio n. 1
0
    //find a singular zone; subfunction of zone
    void find_zone(int y, int x, Zone z)
    {
        tile t = maze [y, x];

        if (!t.get_touch())
        {
            t.set_zone(z);
            Debug.Log(t.get_zone().get_id());
            t.touch(true);
            z.add_tile(t);

            if (t.get_northwall() == tile.Wall.none)
            {
                find_zone(y - 1, x, z);
            }
            if (t.get_westwall() == tile.Wall.none)
            {
                find_zone(y, x - 1, z);
            }
            if (t.get_eastwall() == tile.Wall.none)
            {
                find_zone(y, x + 1, z);
            }
            if (t.get_southwall() == tile.Wall.none)
            {
                find_zone(y + 1, x, z);
            }
        }
    }
Esempio n. 2
0
 //finds all zones
 //Zones have a static int in constructor that keeps count
 void find_zones()
 {
     for (int y = 0; y < size; y++)
     {
         for (int x = 0; x < size; x++)
         {
             tile t = maze [y, x];
             if (t.get_zone() == null)
             {
                 Zone z = new Zone(zid);
                 zid++;
                 global_zones.Add(z);
                 find_zone(y, x, z);
             }
         }
     }
 }
Esempio n. 3
0
    void find_neighbor_tiles()
    {
        for (int y = 0; y < size; y++)
        {
            for (int x = 0; x < size; x++)
            {
                tile t     = maze [y, x];
                tile east  = null;
                tile south = null;

                Zone eastzone  = null;
                Zone southzone = null;

                if ((x + 1) != size)
                {
                    east = maze [y, x + 1];
//					Debug.Log("gonna check east tile at (" + east.x + "," + east.y + ")");
                    eastzone = east.get_zone();
                }

                if ((y + 1) != size)
                {
                    south     = maze [y + 1, x];
                    southzone = south.get_zone();
                }

                Zone tzone = t.get_zone();

//				Debug.Log(tzone.get_id()+ " " + eastzone.get_id());
                if (east != null && tzone.get_id() != eastzone.get_id())                     //Could probably just be get_zone();

                {
                    List <TilePair> ltp = null;

                    if (tzone.neighbors_tiles.TryGetValue(eastzone, out ltp))
                    {
                        Debug.Log("Found");
                        ltp.Add(new TilePair(t, east));
                        //assuming other zone has neighbor as well
                        List <TilePair> eltp = null;
                        eastzone.neighbors_tiles.TryGetValue(tzone, out eltp);
                        eltp.Add(new TilePair(east, t));
                    }
                    else
                    {
                        Debug.Log("Did not have pair matching for " + tzone.get_id() + " " + eastzone.get_id());
                        //Assuming the other zone does not have a list either
                        List <TilePair> l1 = new List <TilePair> ();
                        List <TilePair> l2 = new List <TilePair> ();

                        l1.Add(new TilePair(t, east));
                        l2.Add(new TilePair(east, t));
                        tzone.neighbors_tiles.Add(eastzone, l1);
                        eastzone.neighbors_tiles.Add(tzone, l2);
                    }
                }


                if (south != null && tzone.get_id() != southzone.get_id())                     //Could probably just be get_zone();
                {
                    List <TilePair> ltp = null;
                    if (tzone.neighbors_tiles.TryGetValue(southzone, out ltp))
                    {
                        ltp.Add(new TilePair(t, south));
                        //assuming other zone has neighbor as well
                        List <TilePair> sltp = null;
                        southzone.neighbors_tiles.TryGetValue(tzone, out sltp);
                        sltp.Add(new TilePair(south, t));
                    }
                    else
                    {
                        Debug.Log("Did not have pair matching for " + tzone.get_id() + " " + southzone.get_id());
                        //Assuming the other zone does not have a list either
                        List <TilePair> l1 = new List <TilePair> ();
                        List <TilePair> l2 = new List <TilePair> ();

                        l1.Add(new TilePair(t, south));
                        l2.Add(new TilePair(south, t));
                        tzone.neighbors_tiles.Add(southzone, l1);
                        southzone.neighbors_tiles.Add(tzone, l2);
                    }
                }
            }
        }
    }