コード例 #1
0
        // Lucas
        private List <SQLite_Resource> LoadResource(int ID)
        {
            List <SQLite_Resource> resources = new List <SQLite_Resource>();

            List <ISQLiteRow> convert = Singletons.TableContainerSingleton.ResourceWorldEditorTable.GetMultiple(PropertyFinder <SQLiteResourceWorldEditorModel> .Find(x => x.WorldId), ID);

            for (int i = 0; i < convert.Count; i++)
            {
                SQLite_Resource resource = new SQLite_Resource();

                resource.resourcesType = (EResourcesType)(convert.ElementAt(i) as SQLiteResourceWorldEditorModel).ResourceTypeId;
                resource.X             = (convert.ElementAt(i) as SQLiteResourceWorldEditorModel).Xpos;
                resource.Y             = (convert.ElementAt(i) as SQLiteResourceWorldEditorModel).Ypos;

                resources.Add(resource);
            }

            return(resources);
        }
コード例 #2
0
        public void SaveSQLite(TileGrid tileGrid)
        {
            List <SQLite_Ground>   grounds   = new List <SQLite_Ground>();
            List <SQLite_Building> builings  = new List <SQLite_Building>();
            List <SQLite_Unit>     units     = new List <SQLite_Unit>();
            List <SQLite_Resource> resources = new List <SQLite_Resource>();

            for (int x = 0; x < tileGrid.groundTileGrid.GetLength(0); x++)
            {
                for (int y = 0; y < tileGrid.groundTileGrid.GetLength(1); y++)
                {
                    if (tileGrid.groundTileGrid[x, y] != null)
                    {
                        SQLite_Ground ground = new SQLite_Ground();
                        ground.tileType = tileGrid.groundTileGrid[x, y].GetComponent <CTile>().TileType;
                        ground.X        = x;
                        ground.Y        = y;

                        grounds.Add(ground);
                    }
                }
            }

            for (int x = 0; x < tileGrid.buildingTileGrid.GetLength(0); x++)
            {
                for (int y = 0; y < tileGrid.buildingTileGrid.GetLength(1); y++)
                {
                    if (tileGrid.buildingTileGrid[x, y] != null)
                    {
                        SQLite_Building building = new SQLite_Building();
                        building.BuildingType = tileGrid.buildingTileGrid[x, y].GetComponent <CBuilding>().BuildingType;
                        building.Team         = tileGrid.buildingTileGrid[x, y].GetComponent <CBuilding>().Team;
                        building.Faction      = tileGrid.buildingTileGrid[x, y].GetComponent <CBuilding>().Faction;
                        building.X            = x;
                        building.Y            = y;

                        builings.Add(building);
                    }
                }
            }

            for (int x = 0; x < tileGrid.unitTileGrid.GetLength(0); x++)
            {
                for (int y = 0; y < tileGrid.unitTileGrid.GetLength(1); y++)
                {
                    if (tileGrid.unitTileGrid[x, y] != null)
                    {
                        SQLite_Unit unit = new SQLite_Unit();
                        unit.UnitType = tileGrid.unitTileGrid[x, y].GetComponent <CUnit>().UnitType;
                        unit.Team     = tileGrid.unitTileGrid[x, y].GetComponent <CUnit>().Team;
                        unit.Faction  = tileGrid.unitTileGrid[x, y].GetComponent <CUnit>().Faction;
                        unit.X        = x;
                        unit.Y        = y;

                        units.Add(unit);
                    }
                }
            }

            for (int x = 0; x < tileGrid.resourceTileGrid.GetLength(0); x++)
            {
                for (int y = 0; y < tileGrid.resourceTileGrid.GetLength(1); y++)
                {
                    if (tileGrid.resourceTileGrid[x, y] != null)
                    {
                        SQLite_Resource resource = new SQLite_Resource();
                        resource.resourcesType = tileGrid.resourceTileGrid[x, y].GetComponent <CResourceTile>().ResourcesType;
                        resource.X             = x;
                        resource.Y             = y;

                        resources.Add(resource);
                    }
                }
            }

            DoTheSQLSave(grounds, builings, units, resources);
        }