Exemplo n.º 1
0
        public static void Seed(BusTicketsContext context)
        {
            Town[] towns = TownGenerator.GenerateTowns();
            context.Towns.AddRange(towns);

            BusCompany[] companies = BusCompanyGenerator.GenerateBusCompanies();
            context.BusCompanies.AddRange(companies);

            BusStation[] stations = BusStationGenerator.GenerateBusStations(towns);
            context.BusStations.AddRange(stations);

            Customer[] customers = CustomerGenerator.GenerateCustomers(towns);
            context.Customers.AddRange(customers);

            BankAccount[] accounts = BankAccountGenerator.GenerateBankAccounts(customers);
            context.BankAccounts.AddRange(accounts);

            //BusCompany[] companiesFromDb = context.BusCompanies.ToArray();
            Review[] reviews = ReviewGenerator.GenerateReviews(companies, customers);
            context.Reviews.AddRange(reviews);

            Trip[] trips = TripGenerator.GenerateTrips(stations, companies);
            context.Trips.AddRange(trips);

            Ticket[] tickets = TicketGenerator.GenerateTicket(customers, trips);
            context.Tickets.AddRange(tickets);

            context.SaveChanges();

            Console.WriteLine("Sample data inserted successfully.");
        }
Exemplo n.º 2
0
    public override void OnInspectorGUI() 
    {
        DrawDefaultInspector();

        EditorGUILayout.Space();

        TownGenerator generator = (TownGenerator) target;
        if (GUILayout.Button("Generate")) 
        {
            generator.Generate(false);
            EditorUtility.SetDirty(target);
        }
    }
        private static void ResetDatabase()
        {
            using (var db = new BusTicketContext())
            {
                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();

                TownGenerator.GenerateTowns(db);
                BusCompanyGenerator.GenerateCompaines(db);
                BusStationGenerator.GenerateBusStations(db);
                CustomerGenerator.GenerateCustomers(db);
                TripGenerator.GenerateTrips(db);
                BankAccountGenerator.GenerateBankAccounts(db);
                ReviewGenerator.GenerateReview(db);
                TicketGenrator.GenerateTickets(db);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialize base settings
        /// </summary>
        public void Initialize()
        {
            //create a town generator object when it doesn't exist yet
            if (_townGenerator != null) return;

            //Access towngenerator
            _townGenerator = TownGenerator.GetInstance();

            //Set default settings
            _generationSettings = new GenerationSettings
            {
                VoronoiAlgorithm = VoronoiAlgorithm.Fortune,
                PointAlgorithm = PointGenerationAlgorithm.CityLike
            };

            //City settings
            _citySettings = new CitySettings();
            _citySettings.DebugMode = false;

            //Create a base district type
            CreatePrefabSelection("Grass");

            //Terrain settings editor
            _terrainEditor = new TerrainEditor(new TerrainSettings(), this);

            //Define a style for the foldout
            _foldoutStyle = new GUIStyle(EditorStyles.foldout)
            {
                fontStyle = FontStyle.Bold,
            };

            var c = Color.black;
            _foldoutStyle.onActive.textColor = c;
            _foldoutStyle.normal.textColor = c;
            _foldoutStyle.onNormal.textColor = c;
            _foldoutStyle.hover.textColor = c;
            _foldoutStyle.onHover.textColor = c;
            _foldoutStyle.focused.textColor = c;
            _foldoutStyle.onFocused.textColor = c;
            _foldoutStyle.active.textColor = c;
            _foldoutStyle.onActive.textColor = c;
        }