コード例 #1
0
ファイル: WorldController.cs プロジェクト: pierreyoda/GameInc
 public void OnProjectCompleted(GameDevCompany company, Project project)
 {
     if (project.Type() == Project.ProjectType.GameProject)
     {
         engineFeaturesController.CheckFeatures(this);
     }
     hudController.CanStartNewProject(true);
 }
コード例 #2
0
ファイル: WorldController.cs プロジェクト: pierreyoda/GameInc
    public void OnGameStarted(Database.Database db, DateTime date,
                              GameDevCompany playedCompany)
    {
        database      = db;
        playerCompany = playedCompany;
        gameDateTime  = date;

        // load script functions
        scriptFunctions = Function <bool> .DefaultFunctions();

        scriptGlobalVariables = GameVariables();
        // additional local variables
        Assert.IsTrue(ScriptContext.AddLocalVariable(this,
                                                     "Employee_HiringCost", new FloatSymbol(0), true));
        Assert.IsTrue(ScriptContext.AddLocalVariable(this,
                                                     "Employee_Salary", new FloatSymbol(0), true));
        // parser context
        ParserContext parserContext = new ParserContext {
            Grammar         = Grammar.DefaultGrammar(),
            LocalVariables  = scriptVariables,
            GlobalVariables = scriptGlobalVariables,
            Functions       = scriptFunctions,
        };

        // test
        const string script     = @"
            //{
                let b: int = b;
            //}
            b
        ";
        Executable   executable = Executable.FromScript(script, parserContext);

        if (executable != null)
        {
            int result;
            executable.ExecuteExpecting(this, out result);
            Debug.LogWarning($"===> executable result = {result}");
        }

        // scripts parsing
        eventsController.CreateEvents(db.Events.Collection, parserContext);
        playerCompany.Init(database.Skills, parserContext);
        engineFeaturesController.CreateFeatures(db.EngineFeatures.Collection,
                                                parserContext);
        engineFeaturesController.CheckFeatures(this);
        newsController.CreateNews(db.News.Collection, date);

        // events OnInit calls
        Assert.IsTrue(eventsController.InitEvents(this));

        float    hiringCost;
        Employee employee = playedCompany.EmployeesManager.GenerateRandomEmployee(
            this,
            db.HiringMethod.FindById("CompSciGraduates"),
            db.Names.FindById("CommonNamesUSA"),
            db.Skills,
            out hiringCost);

        playedCompany.AddEmployee(employee);
        Debug.Log($"Generated Random Employee : hiring cost = {hiringCost}.");
    }
コード例 #3
0
 public void OnCompanyChanged(GameDevCompany playerCompany)
 {
     playerCompanyNameText.text  = $"{playerCompany.CompanyName}";
     playerCompanyMoneyText.text = $"{playerCompany.Money:0.#} k";
 }