private static IObjectLayer FillObjectLayer( IAtlas atlas, ObjectGroup objectLayer, LayerType layerType, Action <GameActor> initializer, List <Tileset> tilesets, int tileWidth, int tileHeight, int worldHeight ) { List <TmxObject> tmxMapObjects = objectLayer.TmxMapObjects; tmxMapObjects.ForEach(x => NormalizeObjectPosition(x, tileWidth, tileHeight, worldHeight)); tmxMapObjects.ForEach(TransformObjectPosition); var simpleObjectLayer = new SimpleObjectLayer(layerType); // avatars list List <TmxObject> avatars = tmxMapObjects.Where(x => x.Type == "Avatar").ToList(); foreach (TmxObject avatar in avatars) { Avatar gameAvatar = LoadAgent(avatar, tilesets); initializer.Invoke(gameAvatar); simpleObjectLayer.AddGameObject(gameAvatar); atlas.AddAvatar(gameAvatar); } List <TmxObject> others = tmxMapObjects.Except(avatars).ToList(); List <TmxObject> characters = others.Where(x => x.Gid != 0).ToList(); foreach (TmxObject tmxObject in characters) { Character character = LoadCharacter(tmxObject, tilesets); initializer.Invoke(character); simpleObjectLayer.AddGameObject(character); atlas.Characters.Add(character); } others = others.Except(characters).ToList(); // TODO : other objects return(simpleObjectLayer); }
private static IObjectLayer FillObjectLayer( IAtlas atlas, ObjectGroup objectLayer, LayerType layerType, Action<GameActor> initializer, List<Tileset> tilesets, int tileWidth, int tileHeight, int worldHeight ) { List<TmxObject> tmxMapObjects = objectLayer.TmxMapObjects; tmxMapObjects.ForEach(x => NormalizeObjectPosition(x, tileWidth, tileHeight, worldHeight)); tmxMapObjects.ForEach(TransformObjectPosition); var simpleObjectLayer = new SimpleObjectLayer(layerType); // avatars list List<TmxObject> avatars = tmxMapObjects.Where(x => x.Type == "Avatar").ToList(); foreach (TmxObject avatar in avatars) { Avatar gameAvatar = LoadAgent(avatar, tilesets); initializer.Invoke(gameAvatar); simpleObjectLayer.AddGameObject(gameAvatar); atlas.AddAvatar(gameAvatar); } List<TmxObject> others = tmxMapObjects.Except(avatars).ToList(); List<TmxObject> characters = others.Where(x => x.Gid != 0).ToList(); foreach (TmxObject tmxObject in characters) { Character character = LoadCharacter(tmxObject, tilesets); initializer.Invoke(character); simpleObjectLayer.AddGameObject(character); atlas.Characters.Add(character); } others = others.Except(characters).ToList(); // TODO : other objects return simpleObjectLayer; }
public void NullAvatarThrows() { Assert.Throws <ArgumentNullException>(() => m_atlas.AddAvatar(null)); }