Beispiel #1
0
        private void SaveTileset(object sender, GameObjectSaveEventArgs e)
        {
            e.ActiveTileset.TileList = (from tile
                                        in TilesetEditorEntityInstance.TileList
                                        select new Tile
                                        {
                                            TextureCellX = tile.SpriteSheetColumn,
                                            TextureCellY = tile.SpriteSheetRow,
                                            TilesetID = e.ActiveTileset.ResourceID,
                                            CollisionBoxes = (from box
                                                              in tile.CollisionBoxList
                                                              select new TileCollisionBox
                                                              {
                                                                  IsPassable = box.IsPassable,
                                                                  TileLocationIndex = box.TileIndex
                                                              }).ToList()
                                        }).ToList();

            using (TilesetRepository repo = new TilesetRepository())
            {
                repo.Upsert(e.ActiveTileset);
            }
        }
 public void UpsertInDatabase(GameObjectBase gameObject, string connectionString = "")
 {
     if (gameObject.GameObjectType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository(connectionString))
         {
             repo.Upsert(gameObject as Area);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository(connectionString))
         {
             repo.Upsert(gameObject as Conversation);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository(connectionString))
         {
             repo.Upsert(gameObject as Creature);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository(connectionString))
         {
             repo.Upsert(gameObject as Item);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository(connectionString))
         {
             repo.Upsert(gameObject as Placeable);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository(connectionString))
         {
             repo.Upsert(gameObject as Script);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository(connectionString))
         {
             repo.Upsert(gameObject as Tileset);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }