Ballz.SessionFactory.Worms.FindSpawnPoints C# (CSharp) Method

FindSpawnPoints() public method

public FindSpawnPoints ( Microsoft.Xna.Framework.Graphics.Texture2D map, float terrainScale ) : void
map Microsoft.Xna.Framework.Graphics.Texture2D
terrainScale float
return void
        public void FindSpawnPoints(Texture2D map, float terrainScale)
        {
            var w = map.Width;
            var h = map.Height;
            Color[] pixels = new Color[w * h];
            map.GetData<Color>(pixels);

            // Spawn points are identified by green pixels in the map
            var spawnPointColor = new Color(0f, 1f, 0f);

            for(int x = 0; x < w; x++)
            {
                for(int y = 0; y < h; y++)
                {
                    if (pixels[y * w + x] == spawnPointColor)
                        SpawnPoints.Add(new Vector2(x * terrainScale, (h - y) * terrainScale));
                }
            }
        }