示例#1
0
    public void AnimateXpGain(ReadyCallback readyCallback)
    {
        xpReadyCallback = readyCallback;
        updateSpeed     = Configs.main.UI.XpBarUpdateSpeed;
        xpGained        = Resource.Value;
        levelsAtStart   = Resource.Level;
        currentLevel    = levelsAtStart;

        levelsGained = 0;
        XPContainer.SetActive(false);
        if (xpGained > 0)
        {
            BarContainer.SetActive(true);
            IconContainer.SetActive(true);
            LevelContainer.SetActive(true);
        }
        xpsPerLevel         = new List <int>();
        currentLevelXpBound = Resource.XpPerLevel;
        while (xpGained >= Resource.XpPerLevel)
        {
            levelsGained++;
            xpGained -= Resource.XpPerLevel;
            xpsPerLevel.Add(Resource.XpPerLevel);
            Resource.Level++;
        }

        SetCurrentTarget();
        StartCoroutine("GainXP");
    }
示例#2
0
    private void Awake()
    {
        this.lines = this.gameObject.GetComponentsInChildren <LineController>();
        if (this.lines.Length != 4)
        {
            throw new NullReferenceException("Missing LineController object");
        }

        this.bar = new BarContainer(this as IBar);
    }
示例#3
0
        public void Update(NnGpuWin nnGpuWinInstance, int layerIndex)
        {
            // TODO: NEED TO FIX THE OUTPUT. NEED TO SHOW THE AVERAGE ERRORS PER X UINTS OF TIME

            NnGpuLayerDataGroup laterDataGroup = nnGpuWinInstance.GetLayerData(layerIndex);

            double largest  = laterDataGroup.GetLayerOfType(NnGpuLayerDataType.Forward).GetLargestDataValue();
            double smallest = laterDataGroup.GetLayerOfType(NnGpuLayerDataType.Forward).GetSmallestDataValue();

            double[] layerDataForward  = laterDataGroup.GetLayerOfType(NnGpuLayerDataType.Forward).data;
            double[] layerDataBackward = laterDataGroup.GetLayerOfType(NnGpuLayerDataType.Backward).data;

            Outputs.Insert(0, layerDataBackward);
            if (Outputs.Count > MaxPoints)
            {
                Outputs.RemoveAt(MaxPoints);
            }

            if (double.IsNaN(BarContainer.ActualWidth) ||
                double.IsNaN(BarContainer.ActualHeight))
            {
                return;
            }

            double highAve = 0;
            double lowAve  = 0;

            double[] aves = new double[Outputs.Count];
            for (int index = 0; index < Outputs.Count; index++)
            {
                double[] output = Outputs[index];

                double ave = 0;
                for (int outputIndex = 0; outputIndex < output.Length; outputIndex++)
                {
                    ave += output[outputIndex];
                }
                ave        /= output.Length;
                aves[index] = ave;

                if (ave > highAve)
                {
                    highAve = ave;
                }

                if (ave < lowAve)
                {
                    lowAve = ave;
                }
            }

            double scale = 1;

            if (System.Math.Abs(highAve) > System.Math.Abs(lowAve))
            {
                scale = (BarContainer.Height / System.Math.Abs(highAve)) / 2;
            }
            else
            {
                scale = (BarContainer.Height / System.Math.Abs(lowAve)) / 2;
            }

            if (scale < 0.3)
            {
                scale = 0.3;
            }

            BarContainer.Children.Clear();

            double xscale = this.ActualWidth / ((double)MaxPoints);

            Line baseline = new Line();

            baseline.X1              = 0;
            baseline.Y1              = BarContainer.ActualHeight / 2;
            baseline.X2              = BarContainer.ActualWidth;
            baseline.Y2              = BarContainer.ActualHeight / 2;
            baseline.Stroke          = new SolidColorBrush(Color.FromRgb(0, 0, 0));
            baseline.StrokeThickness = 1;
            BarContainer.Children.Add(baseline);

            double lastPointX = 0;
            double lastPointY = 0;

            for (int index = 0; index < Outputs.Count; index++)
            {
                double dataPointX = index * xscale;
                double dataPointY = ((aves[index] * -1) * scale) + (BarContainer.ActualHeight / 2);

                if (index > 0 &&
                    !double.IsNaN(lastPointY) &&
                    !double.IsNaN(dataPointY))
                {
                    Line l = new Line();
                    l.X1              = lastPointX;
                    l.Y1              = lastPointY;
                    l.X2              = dataPointX;
                    l.Y2              = dataPointY;
                    l.Stroke          = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    l.StrokeThickness = 1;
                    BarContainer.Children.Add(l);

                    BarContainer.Children.Add(new TextBlock()
                    {
                        Text   = Convert.ToString(Math.Round(aves[index], 4)),
                        Margin = new Thickness(dataPointX, dataPointY - 10, 0, 0)
                    });
                }

                lastPointX = dataPointX;
                lastPointY = dataPointY;
            }

            BarContainer.Children.Add(new TextBlock()
            {
                Text   = Convert.ToString(Math.Round(highAve, 4)),
                Margin = new Thickness(0, 0, 0, 0)
            });

            BarContainer.Children.Add(new TextBlock()
            {
                Text   = Convert.ToString(Math.Round(lowAve, 4)),
                Margin = new Thickness(0, BarContainer.Height - 20, 0, 0)
            });

            BarContainer.InvalidateArrange();
        }