Example #1
0
    private void RefreshParticipantHistogram(AgeTransform tableitem, EmpireInfo empireInfo, int index)
    {
        EmpireInfo empireInfo2   = this.EmpireInfos.FirstOrDefault((EmpireInfo iterator) => iterator.IsActiveOrLocalPlayer);
        int        observerIndex = -1;

        if (empireInfo2 != null)
        {
            observerIndex = empireInfo2.EmpireIndex;
        }
        if (this.IsEmpireVisible(empireInfo, observerIndex))
        {
            tableitem.Visible = true;
            AgePrimitiveHistogramLinear component = tableitem.GetComponent <AgePrimitiveHistogramLinear>();
            component.TintColor = empireInfo.FactionColor;
            Snapshot[] snapshots = this.Snapshot.Snapshots;
            float[]    array     = new float[snapshots.Length];
            for (int i = 0; i < snapshots.Length; i++)
            {
                string   name = string.Format("Turn #{0}", i);
                Snapshot snapshot;
                Snapshot snapshot2;
                if (this.Snapshot.TryGetSnapshot(name, out snapshot) && snapshot.TryGetSnapshot(empireInfo.EmpireName, out snapshot2))
                {
                    snapshot2.TryRead(this.CurrentScoreDefinition.Name, out array[i]);
                }
            }
            component.Values = array;
        }
        else
        {
            tableitem.Visible = false;
        }
    }
Example #2
0
    private void RefreshScores()
    {
        this.CalculateELCPScaling();
        this.ParticipantsScoreTable.ReserveChildren(this.EmpireInfos.Length, this.ParticipantScoreLinePrefab, "Item");
        this.ParticipantsScoreTable.RefreshChildrenArray <EmpireInfo>(this.EmpireInfos, new AgeTransform.RefreshTableItem <EmpireInfo>(this.RefreshParticipantScoreLine), true, false);
        this.ScoreHistogramContainer.ReserveChildren(this.EmpireInfos.Length, this.ScoreHistogramPrefab, "Item");
        this.ScoreHistogramContainer.RefreshChildrenArray <EmpireInfo>(this.EmpireInfos, new AgeTransform.RefreshTableItem <EmpireInfo>(this.RefreshParticipantHistogram), true, false);
        float num  = float.NegativeInfinity;
        float num2 = 0f;

        for (int i = 0; i < this.ScoreHistogramContainer.GetChildren().Count; i++)
        {
            float[] values = this.ScoreHistogramContainer.GetChildren()[i].GetComponent <AgePrimitiveHistogramLinear>().Values;
            for (int j = 0; j < values.Length; j++)
            {
                if (values[j] > num)
                {
                    num = values[j];
                }
                if (values[j] < num2)
                {
                    num2 = values[j];
                }
            }
        }
        if (num - num2 != 0f)
        {
            for (int k = 0; k < this.ScoreHistogramContainer.GetChildren().Count; k++)
            {
                AgePrimitiveHistogramLinear component = this.ScoreHistogramContainer.GetChildren()[k].GetComponent <AgePrimitiveHistogramLinear>();
                float[] values2 = component.Values;
                for (int l = 0; l < values2.Length; l++)
                {
                    values2[l] -= num2;
                    values2[l] /= num - num2;
                }
                component.Values = values2;
            }
        }
        this.verticalGridValues.Clear();
        this.verticalGridHeights.Clear();
        if (num - num2 > 0f)
        {
            float num3 = Mathf.Log10(num - num2);
            float num4 = Mathf.Floor(num3);
            float num5 = Mathf.Pow(10f, num4);
            if (num3 - num4 < 0.7f && num4 > 0f)
            {
                num5 *= 0.5f;
            }
            int num6 = 0;
            if (num2 < 0f)
            {
                num6 = Mathf.CeilToInt(num2 / num5);
            }
            int num7 = 0;
            if (num > 0f)
            {
                num7 = Mathf.FloorToInt(num / num5);
            }
            float num8 = num5 * (float)num6;
            for (int m = num6; m <= num7; m++)
            {
                bool flag = false;
                for (int n = 0; n < this.verticalGridValues.Count; n++)
                {
                    if (num8 == this.verticalGridValues[0])
                    {
                        flag = true;
                        n    = this.verticalGridValues.Count;
                    }
                }
                if (!flag)
                {
                    this.verticalGridValues.Add(num8);
                    this.verticalGridHeights.Add(this.VerticalGridContainer.Height * (1f - (num8 - num2) / (num - num2)));
                }
                num8 += num5;
            }
        }
        this.VerticalGridContainer.ReserveChildren(this.verticalGridValues.Count, this.ScoreVerticalGridPrefab, "Item");
        this.VerticalGridContainer.RefreshChildrenIList <float>(this.verticalGridValues, new AgeTransform.RefreshTableItem <float>(this.RefreshVerticalGridLine), false, false);
    }