Exemple #1
0
    public void Load()
    {
        int radius = 7;

        if (radius > 0)
        {
            AddLoc(new HexLoc(0, 0));
            for (int fRadius = 1; fRadius <= radius; fRadius++)
            {
                //Set initial hex grid location
                HexLoc loc = new HexLoc(fRadius, -fRadius);
                HexDir dir = (HexDir)2;
                //Find data for each hex in the ring (each ring has 6 more hexes than the last)
                for (int fHex = 0; fHex < 6 * fRadius; fHex++)
                {
                    AddLoc(loc);
                    //Finds next hex in ring
                    loc = loc.MoveTo(dir);
                    if (loc.x == 0 || loc.y == 0 || loc.x == -loc.y)
                    {
                        dir++;
                    }
                }
            }
        }
        foreach (HexTile t in locs.Values)
        {
            t.FindConnections();
        }
    }
 public void FindConnections()
 {
     for (int i = 0; i < 6; i++)
     {
         HexTile h = Room.Instance.GetTile(loc.MoveTo((HexDir)i));
         if (h != null)
         {
             connections.Add(h);
         }
     }
 }