Exemple #1
0
        static void DrawPathFencesOnMap(TerrainMap map, IPathway path)
        {
            float   xs       = map.XSize / map.Resolution;
            float   zs       = map.ZSize / map.Resolution;
            Vector3 alongRow = new Vector3(xs, 0, 0);
            Vector3 nextRow  = new Vector3(-map.XSize, 0, zs);
            Vector3 g        = new Vector3((map.XSize - xs) / -2, 0, (map.ZSize - zs) / -2);

            for (int j = 0; j < map.Resolution; j++)
            {
                for (int i = 0; i < map.Resolution; i++)
                {
                    float       outside        = path.HowFarOutsidePath(g);
                    const float WALL_THICKNESS = 1.0f;

                    // set map cells adjacent to the outside edge of the path
                    if ((outside > 0) && (outside < WALL_THICKNESS))
                    {
                        map.SetMapBit(i, j, true);
                    }

                    // clear all other off-path map cells
                    if (outside > WALL_THICKNESS)
                    {
                        map.SetMapBit(i, j, false);
                    }

                    g += alongRow;
                }
                g += nextRow;
            }
        }
Exemple #2
0
        static void DrawBoundaryFencesOnMap(TerrainMap map)
        {
            // QQQ it would make more sense to do this with a "draw line
            // QQQ on map" primitive, may need that for other things too

            int cw = map.Cellwidth();
            int ch = map.Cellheight();

            int r = cw - 1;
            int a = cw >> 3;
            int b = cw - a;
            int o = cw >> 4;
            int p = (cw - o) >> 1;
            int q = (cw + o) >> 1;

            for (int i = 0; i < cw; i++)
            {
                for (int j = 0; j < ch; j++)
                {
                    bool c = i > a && i < b && (i <p || i> q);
                    if (i == 0 || j == 0 || i == r || j == r || (c && (i == j || i + j == r)))
                    {
                        map.SetMapBit(i, j, true);
                    }
                }
            }
        }
Exemple #3
0
        static void ClearCenterOfMap(TerrainMap map)
        {
            int o = map.Cellwidth() >> 4;
            int p = (map.Cellwidth() - o) >> 1;
            int q = (map.Cellwidth() + o) >> 1;

            for (int i = p; i <= q; i++)
            {
                for (int j = p; j <= q; j++)
                {
                    map.SetMapBit(i, j, false);
                }
            }
        }
Exemple #4
0
        void DrawRandomClumpsOfRocksOnMap(TerrainMap map)
        {
            if (_useRandomRocks)
            {
                const int SPREAD = 4;
                int       r      = map.Cellwidth();
                int       k      = RandomHelpers.RandomInt(50, 150);

                for (int p = 0; p < k; p++)
                {
                    int i = RandomHelpers.RandomInt(0, r - SPREAD);
                    int j = RandomHelpers.RandomInt(0, r - SPREAD);
                    int c = RandomHelpers.RandomInt(0, 10);

                    for (int q = 0; q < c; q++)
                    {
                        int m = RandomHelpers.RandomInt(0, SPREAD);
                        int n = RandomHelpers.RandomInt(0, SPREAD);
                        map.SetMapBit(i + m, j + n, true);
                    }
                }
            }
        }
        static void DrawPathFencesOnMap(TerrainMap map, IPathway path)
		{
			float xs = map.XSize / map.Resolution;
			float zs = map.ZSize / map.Resolution;
			Vector3 alongRow = new Vector3(xs, 0, 0);
			Vector3 nextRow = new Vector3(-map.XSize, 0, zs);
			Vector3 g = new Vector3((map.XSize - xs) / -2, 0, (map.ZSize - zs) / -2);
			for (int j = 0; j < map.Resolution; j++)
			{
				for (int i = 0; i < map.Resolution; i++)
				{
					float outside = path.HowFarOutsidePath(g);
					const float WALL_THICKNESS = 1.0f;

					// set map cells adjacent to the outside edge of the path
					if ((outside > 0) && (outside < WALL_THICKNESS))
						map.SetMapBit(i, j, true);

					// clear all other off-path map cells 
					if (outside > WALL_THICKNESS) map.SetMapBit(i, j, false);

					g += alongRow;
				}
				g += nextRow;
			}
		}
	    static void ClearCenterOfMap(TerrainMap map)
		{
			int o = map.Cellwidth() >> 4;
			int p = (map.Cellwidth() - o) >> 1;
			int q = (map.Cellwidth() + o) >> 1;
			for (int i = p; i <= q; i++)
				for (int j = p; j <= q; j++)
					map.SetMapBit(i, j, false);
		}
	    static void DrawBoundaryFencesOnMap(TerrainMap map)
		{
			// QQQ it would make more sense to do this with a "draw line
			// QQQ on map" primitive, may need that for other things too

			int cw = map.Cellwidth();
			int ch = map.Cellheight();

			int r = cw - 1;
			int a = cw >> 3;
			int b = cw - a;
			int o = cw >> 4;
			int p = (cw - o) >> 1;
			int q = (cw + o) >> 1;

			for (int i = 0; i < cw; i++)
			{
				for (int j = 0; j < ch; j++)
				{
					bool c = i > a && i < b && (i < p || i > q);
					if (i == 0 || j == 0 || i == r || j == r || (c && (i == j || i + j == r)))
						map.SetMapBit(i, j, true);
				}
			}
		}
		void DrawRandomClumpsOfRocksOnMap(TerrainMap map)
		{
			if (_useRandomRocks)
			{
				const int SPREAD = 4;
				int r = map.Cellwidth();
				int k = RandomHelpers.RandomInt(50, 150);

				for (int p = 0; p < k; p++)
				{
					int i = RandomHelpers.RandomInt(0, r - SPREAD);
					int j = RandomHelpers.RandomInt(0, r - SPREAD);
					int c = RandomHelpers.RandomInt(0, 10);

					for (int q = 0; q < c; q++)
					{
						int m = RandomHelpers.RandomInt(0, SPREAD);
						int n = RandomHelpers.RandomInt(0, SPREAD);
						map.SetMapBit(i + m, j + n, true);
					}
				}
			}
		}