Exemplo n.º 1
0
            /// <summary>
            /// Applied after ConfigureGraph runs.
            /// </summary>
            internal static void Postfix(RetiredColonyData.RetiredColonyStatistic statistic,
                                         Dictionary <string, GameObject> ___activeColonyWidgets,
                                         Dictionary <string, Color> ___statColors)
            {
                var reports = ReportManager.Instance?.reports;

                if (___activeColonyWidgets.TryGetValue(statistic.name, out GameObject obj))
                {
                    // Find first remaining report's cycle index
                    int minReport = ((reports?.Count ?? 0) < 1) ? 0 : reports[0].day;
                    var graph     = obj.GetComponentInChildren <GraphBase>();
                    var lineLayer = obj.GetComponentInChildren <LineLayer>();
                    if (graph != null && lineLayer != null)
                    {
                        // Update the graph min X value to that cycle #
                        graph.axis_x.min_value = minReport;
                        graph.RefreshGuides();
                        lineLayer.ClearLines();
                        // Recreate the line with the correct scale
                        var graphedLine    = lineLayer.NewLine(statistic.value, statistic.id);
                        var lineFormatting = lineLayer.line_formatting;
                        int lastIndex      = lineFormatting.Length - 1;
                        // Reassign the color (yes lots of duplicate work but a transpiler
                        // would be super annoying)
                        if (___statColors.TryGetValue(statistic.id, out Color color))
                        {
                            lineFormatting[lastIndex].color = color;
                        }
                        graphedLine.line_renderer.color = lineFormatting[lastIndex].color;
                    }
                }
            }
Exemplo n.º 2
0
    private void ConfigureGraph(RetiredColonyData.RetiredColonyStatistic statistic, GameObject layoutBlockGameObject)
    {
        GameObject gameObject = Util.KInstantiateUI(lineGraphPrefab, layoutBlockGameObject, true);

        activeColonyWidgets.Add(statistic.name, gameObject);
        GraphBase componentInChildren = gameObject.GetComponentInChildren <GraphBase>();

        componentInChildren.graphName = statistic.name;
        componentInChildren.label_title.SetText(componentInChildren.graphName);
        componentInChildren.axis_x.name = statistic.nameX;
        componentInChildren.axis_y.name = statistic.nameY;
        componentInChildren.label_x.SetText(componentInChildren.axis_x.name);
        componentInChildren.label_y.SetText(componentInChildren.axis_y.name);
        LineLayer componentInChildren2 = gameObject.GetComponentInChildren <LineLayer>();

        componentInChildren.axis_y.min_value       = 0f;
        componentInChildren.axis_y.max_value       = statistic.GetByMaxValue().second * 1.2f;
        componentInChildren.axis_x.min_value       = 0f;
        componentInChildren.axis_x.max_value       = statistic.GetByMaxKey().first;
        componentInChildren.axis_x.guide_frequency = (componentInChildren.axis_x.max_value - componentInChildren.axis_x.min_value) / 10f;
        componentInChildren.axis_y.guide_frequency = (componentInChildren.axis_y.max_value - componentInChildren.axis_y.min_value) / 10f;
        componentInChildren.RefreshGuides();
        Tuple <float, float>[] value       = statistic.value;
        GraphedLine            graphedLine = componentInChildren2.NewLine(value, statistic.id);

        if (statColors.ContainsKey(statistic.id))
        {
            componentInChildren2.line_formatting[componentInChildren2.line_formatting.Length - 1].color = statColors[statistic.id];
        }
        graphedLine.line_renderer.color = componentInChildren2.line_formatting[componentInChildren2.line_formatting.Length - 1].color;
    }
Exemplo n.º 3
0
    private void DisplayStatistics(RetiredColonyData data)
    {
        GameObject gameObject = Util.KInstantiateUI(specialMediaBlock, statsContainer, true);

        activeColonyWidgetContainers.Add(gameObject);
        activeColonyWidgets.Add("timelapse", gameObject);
        DisplayTimelapse(data, gameObject);
        GameObject duplicantBlock = Util.KInstantiateUI(tallFeatureBlock, statsContainer, true);

        activeColonyWidgetContainers.Add(duplicantBlock);
        activeColonyWidgets.Add("duplicants", duplicantBlock);
        duplicantBlock.GetComponent <HierarchyReferences>().GetReference <LocText>("Title").SetText(UI.RETIRED_COLONY_INFO_SCREEN.TITLES.DUPLICANTS);
        PageView pageView = duplicantBlock.GetComponentInChildren <PageView>();

        pageView.OnChangePage = delegate(int page)
        {
            DisplayDuplicants(data, duplicantBlock.GetComponent <HierarchyReferences>().GetReference("Content").gameObject, page * pageView.ChildrenPerPage, (page + 1) * pageView.ChildrenPerPage);
        };
        DisplayDuplicants(data, duplicantBlock.GetComponent <HierarchyReferences>().GetReference("Content").gameObject, -1, -1);
        GameObject gameObject2 = Util.KInstantiateUI(tallFeatureBlock, statsContainer, true);

        activeColonyWidgetContainers.Add(gameObject2);
        activeColonyWidgets.Add("buildings", gameObject2);
        gameObject2.GetComponent <HierarchyReferences>().GetReference <LocText>("Title").SetText(UI.RETIRED_COLONY_INFO_SCREEN.TITLES.BUILDINGS);
        DisplayBuildings(data, gameObject2.GetComponent <HierarchyReferences>().GetReference("Content").gameObject);
        int num = 2;

        for (int i = 0; i < data.Stats.Length; i += num)
        {
            GameObject gameObject3 = Util.KInstantiateUI(standardStatBlock, statsContainer, true);
            activeColonyWidgetContainers.Add(gameObject3);
            for (int j = 0; j < num; j++)
            {
                if (i + j <= data.Stats.Length - 1)
                {
                    RetiredColonyData.RetiredColonyStatistic retiredColonyStatistic = data.Stats[i + j];
                    ConfigureGraph(GetStatistic(retiredColonyStatistic.id, data), gameObject3);
                }
            }
        }
        StartCoroutine(ComputeSizeStatGrid());
    }
    private static RetiredColonyData LoadRetiredColony(string file, bool skipStats, Encoding enc)
    {
        RetiredColonyData retiredColonyData = new RetiredColonyData();

        using (FileStream stream = File.Open(file, FileMode.Open))
        {
            using (StreamReader reader = new StreamReader(stream, enc))
            {
                using (JsonReader jsonReader = new JsonTextReader(reader))
                {
                    string        a    = string.Empty;
                    List <string> list = new List <string>();
                    List <Tuple <string, int> > list2 = new List <Tuple <string, int> >();
                    List <RetiredColonyData.RetiredDuplicantData>   list3 = new List <RetiredColonyData.RetiredDuplicantData>();
                    List <RetiredColonyData.RetiredColonyStatistic> list4 = new List <RetiredColonyData.RetiredColonyStatistic>();
                    while (jsonReader.Read())
                    {
                        JsonToken tokenType = jsonReader.TokenType;
                        if (tokenType == JsonToken.PropertyName)
                        {
                            a = jsonReader.Value.ToString();
                        }
                        if (tokenType == JsonToken.String && a == "colonyName")
                        {
                            retiredColonyData.colonyName = jsonReader.Value.ToString();
                        }
                        if (tokenType == JsonToken.String && a == "date")
                        {
                            retiredColonyData.date = jsonReader.Value.ToString();
                        }
                        if (tokenType == JsonToken.Integer && a == "cycleCount")
                        {
                            retiredColonyData.cycleCount = int.Parse(jsonReader.Value.ToString());
                        }
                        if (tokenType == JsonToken.String && a == "achievements")
                        {
                            list.Add(jsonReader.Value.ToString());
                        }
                        if (tokenType == JsonToken.StartObject && a == "Duplicants")
                        {
                            string a2 = null;
                            RetiredColonyData.RetiredDuplicantData retiredDuplicantData = new RetiredColonyData.RetiredDuplicantData();
                            retiredDuplicantData.accessories = new Dictionary <string, string>();
                            while (true)
                            {
                                if (jsonReader.Read())
                                {
                                    tokenType = jsonReader.TokenType;
                                    switch (tokenType)
                                    {
                                    case JsonToken.PropertyName:
                                        a2 = jsonReader.Value.ToString();
                                        goto default;

                                    default:
                                        if (a2 == "name" && tokenType == JsonToken.String)
                                        {
                                            retiredDuplicantData.name = jsonReader.Value.ToString();
                                        }
                                        if (a2 == "age" && tokenType == JsonToken.Integer)
                                        {
                                            retiredDuplicantData.age = int.Parse(jsonReader.Value.ToString());
                                        }
                                        if (a2 == "skillPointsGained" && tokenType == JsonToken.Integer)
                                        {
                                            retiredDuplicantData.skillPointsGained = int.Parse(jsonReader.Value.ToString());
                                        }
                                        if (a2 == "accessories")
                                        {
                                            string text = null;
                                            while (true)
                                            {
                                                if (jsonReader.Read())
                                                {
                                                    tokenType = jsonReader.TokenType;
                                                    switch (tokenType)
                                                    {
                                                    case JsonToken.PropertyName:
                                                        text = jsonReader.Value.ToString();
                                                        goto default;

                                                    default:
                                                        if (text != null && jsonReader.Value != null && tokenType == JsonToken.String)
                                                        {
                                                            string value = jsonReader.Value.ToString();
                                                            retiredDuplicantData.accessories.Add(text, value);
                                                        }
                                                        continue;

                                                    case JsonToken.EndObject:
                                                        break;
                                                    }
                                                }
                                                break;
                                            }
                                        }
                                        continue;

                                    case JsonToken.EndObject:
                                        break;
                                    }
                                }
                                break;
                            }
                            list3.Add(retiredDuplicantData);
                        }
                        if (tokenType == JsonToken.StartObject && a == "buildings")
                        {
                            string a3 = null;
                            string a4 = null;
                            int    b  = 0;
                            while (true)
                            {
                                if (jsonReader.Read())
                                {
                                    tokenType = jsonReader.TokenType;
                                    switch (tokenType)
                                    {
                                    case JsonToken.PropertyName:
                                        a3 = jsonReader.Value.ToString();
                                        goto default;

                                    default:
                                        if (a3 == "first" && tokenType == JsonToken.String)
                                        {
                                            a4 = jsonReader.Value.ToString();
                                        }
                                        if (a3 == "second" && tokenType == JsonToken.Integer)
                                        {
                                            b = int.Parse(jsonReader.Value.ToString());
                                        }
                                        continue;

                                    case JsonToken.EndObject:
                                        break;
                                    }
                                }
                                break;
                            }
                            Tuple <string, int> item = new Tuple <string, int>(a4, b);
                            list2.Add(item);
                        }
                        if (tokenType == JsonToken.StartObject && a == "Stats")
                        {
                            if (skipStats)
                            {
                                break;
                            }
                            string a5 = null;
                            RetiredColonyData.RetiredColonyStatistic retiredColonyStatistic = new RetiredColonyData.RetiredColonyStatistic();
                            List <Tuple <float, float> >             list5 = new List <Tuple <float, float> >();
                            while (true)
                            {
                                if (jsonReader.Read())
                                {
                                    tokenType = jsonReader.TokenType;
                                    switch (tokenType)
                                    {
                                    case JsonToken.PropertyName:
                                        a5 = jsonReader.Value.ToString();
                                        goto default;

                                    default:
                                        if (a5 == "id" && tokenType == JsonToken.String)
                                        {
                                            retiredColonyStatistic.id = jsonReader.Value.ToString();
                                        }
                                        if (a5 == "name" && tokenType == JsonToken.String)
                                        {
                                            retiredColonyStatistic.name = jsonReader.Value.ToString();
                                        }
                                        if (a5 == "nameX" && tokenType == JsonToken.String)
                                        {
                                            retiredColonyStatistic.nameX = jsonReader.Value.ToString();
                                        }
                                        if (a5 == "nameY" && tokenType == JsonToken.String)
                                        {
                                            retiredColonyStatistic.nameY = jsonReader.Value.ToString();
                                        }
                                        if (a5 == "value" && tokenType == JsonToken.StartObject)
                                        {
                                            string a6 = null;
                                            float  a7 = 0f;
                                            float  b2 = 0f;
                                            while (true)
                                            {
                                                if (jsonReader.Read())
                                                {
                                                    tokenType = jsonReader.TokenType;
                                                    switch (tokenType)
                                                    {
                                                    case JsonToken.PropertyName:
                                                        a6 = jsonReader.Value.ToString();
                                                        goto default;

                                                    default:
                                                        if (a6 == "first" && (tokenType == JsonToken.Float || tokenType == JsonToken.Integer))
                                                        {
                                                            a7 = float.Parse(jsonReader.Value.ToString());
                                                        }
                                                        if (a6 == "second" && (tokenType == JsonToken.Float || tokenType == JsonToken.Integer))
                                                        {
                                                            b2 = float.Parse(jsonReader.Value.ToString());
                                                        }
                                                        continue;

                                                    case JsonToken.EndObject:
                                                        break;
                                                    }
                                                }
                                                break;
                                            }
                                            Tuple <float, float> item2 = new Tuple <float, float>(a7, b2);
                                            list5.Add(item2);
                                        }
                                        continue;

                                    case JsonToken.EndObject:
                                        break;
                                    }
                                }
                                break;
                            }
                            retiredColonyStatistic.value = list5.ToArray();
                            list4.Add(retiredColonyStatistic);
                        }
                    }
                    retiredColonyData.Duplicants   = list3.ToArray();
                    retiredColonyData.Stats        = list4.ToArray();
                    retiredColonyData.achievements = list.ToArray();
                    retiredColonyData.buildings    = list2;
                    return(retiredColonyData);
                }
            }
        }
    }