Beispiel #1
0
    private void Start()
    {
        // Database loading
        Debug.Log("Loading the game database...", gameObject);
        database = new Database.Database();
        const string filesPrefix = "Assets/Resources/Core";

        database = database.AddDataFile($"{filesPrefix}/events.json", DataFileType.Event)
                   .AddDataFolder("Assets/Resources/Core/news", DataFileType.News)
                   .AddDataFile($"{filesPrefix}/genres.json", DataFileType.GameGenre)
                   .AddDataFile($"{filesPrefix}/themes.json", DataFileType.GameTheme)
                   .AddDataFolder("Assets/Resources/Core/platforms", DataFileType.GamingPlatform)
                   .AddDataFolder("Assets/Resources/Core/games", DataFileType.GameSeries)
                   .AddDataFile($"{filesPrefix}/engine_features.json", DataFileType.EngineFeature)
                   .AddDataFile($"{filesPrefix}/rooms.json", DataFileType.Room)
                   .AddDataFile($"{filesPrefix}/objects.json", DataFileType.RoomObject)
                   .AddDataFile($"{filesPrefix}/skills.json", DataFileType.Skill)
                   .AddDataFile($"{filesPrefix}/hiring.json", DataFileType.HiringMethod)
                   .AddDataFolder("Assets/Resources/Core/names", DataFileType.CommonNames)
                   .Load();
        if (database == null)
        {
            Debug.LogError($"World.Start() : Database loading error.");
            #if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
            #endif
            Application.Quit();
            return;
        }
        database.PrintDatabaseInfo();

        Debug.Log("Instanciating the game world...", gameObject);

        dayPercentage = 0f;
        gameDateTime  = new DateTime(gameStartYear, gameStartMonth, gameStartDay);

        globalMarket.Init(gameDateTime, database.GameSeries.Collection);
        worldController.OnGameStarted(database, gameDateTime, playerCompany);
        worldController.OnDateModified(gameDateTime);
        worldController.OnPlayerCompanyModified();

        var employeesParentObject = transform.Find("Employees");
        for (int i = 0; i < employeesParentObject.childCount; i++)
        {
            playerCompany.AddEmployee(employeesParentObject.GetChild(i).GetComponent <Employee>());
        }

        gameMenu.ShowMenu();
    }