コード例 #1
0
    void Render()
    {
        CompanyName.text            = entity.company.Name;
        LinkToProjectView.CompanyId = entity.company.Id;

        //var current = CompanyStatisticsUtils.GetCurrentAnnualReport(GameContext);
        //var prev = CompanyStatisticsUtils.GetPreviousAnnualReport(GameContext);

        //var metrics = MyCompany.metricsHistory.Metrics
        //    .Where(m => CompanyStatisticsUtils.GetLastCalendarYearMetrics(m, CurrentIntDate - 360))
        //    .OrderBy(m => m.Date);

        //Debug.Log("Metrics count: " + metrics.Count());
        //if (metrics.Count() < 11)
        //    return;

        //var current = metrics.Last().Income;

        //var last =  metrics.First().Income;
        //if (last == 0)
        //    last = 1;



        //var growthAbsolute = current - last;
        //var growthRelative = growthAbsolute / last;
        var growthAbsolute = CompanyStatisticsUtils.GetIncomeGrowthAbsolute(entity, 12);
        var growthRelative = CompanyStatisticsUtils.GetIncomeGrowth(entity, 12);

        bool isGrowing = growthAbsolute >= 0;

        Value.text  = (isGrowing ? "+" : "") + Format.MinifyMoney(growthAbsolute);
        Value.color = Visuals.GetColorFromString(isGrowing ? Colors.COLOR_POSITIVE : Colors.COLOR_NEGATIVE);

        Value.GetComponent <Hint>().SetHint($"Income growth: {Format.Sign(growthAbsolute, true)} ({Format.Sign(growthRelative)}%)");
    }