private List <_2DSpriteTextureGroup> GroupByTexture(List <_2DSprite> sprites) { var result = new List <_2DSpriteTextureGroup>(); var map = new Dictionary <Texture2D, _2DSpriteTextureGroup>(); foreach (var sprite in sprites) { if (!map.ContainsKey(sprite.Pixel)) { var grouping = new _2DSpriteTextureGroup { Pixel = sprite.Pixel, Depth = sprite.Depth }; grouping.Sprites.Add(sprite); map.Add(sprite.Pixel, grouping); result.Add(grouping); } else { map[sprite.Pixel].Sprites.Add(sprite); } } return(result); }
private List <_2DSpriteTextureGroup> GroupByTexture(List <_2DSprite> sprites) { var result = new List <_2DSpriteTextureGroup>(); var map = new Dictionary <Tuple <Texture2D, Texture2D>, _2DSpriteTextureGroup>(); foreach (var sprite in sprites) { var tuple = new Tuple <Texture2D, Texture2D>(sprite.Pixel, sprite.Mask); if (!map.ContainsKey(tuple)) { var grouping = new _2DSpriteTextureGroup { Pixel = sprite.Pixel, Depth = sprite.Depth, Mask = sprite.Mask }; grouping.Sprites.Add(sprite); map.Add(tuple, grouping); result.Add(grouping); } else { map[tuple].Sprites.Add(sprite); } } return(result); }
private List<_2DSpriteTextureGroup> GroupByTexture(List<_2DSprite> sprites) { var result = new List<_2DSpriteTextureGroup>(); var map = new Dictionary<Texture2D, _2DSpriteTextureGroup>(); foreach (var sprite in sprites){ if (!map.ContainsKey(sprite.Pixel)) { var grouping = new _2DSpriteTextureGroup { Pixel = sprite.Pixel, Depth = sprite.Depth }; grouping.Sprites.Add(sprite); map.Add(sprite.Pixel, grouping); result.Add(grouping); } else { map[sprite.Pixel].Sprites.Add(sprite); } } return result; }