Beispiel #1
0
        public void UpdateFPS(float dt)
        {
            //var fps = 0.75f * 1 / dt + 0.25f * Timer.GetFPS();
            var fps = FPSCounter.GetFPS();

            UpdateGraph(fps, (Mathf.Floor(fps * 10) / 10).ToString("00.0"), dt);
        }
Beispiel #2
0
        /*
         *
         * // public void UpdateMem(float dt)
         * // {
         * //     var fps = 0.75f * 1 / dt + 0.25f * Timer.GetFPS();
         *  //     UpdateGraph(graph, mem, "Memory (KB): " .. math.floor(mem*10)/10, dt)
         * // }
         *
         *
         */

        public void DrawGraph()
        {
            Graphics.SetColor(0, 0, 0, 0.6f);
            Graphics.Rectangle(DrawMode.Fill, m_rect);

            Graphics.SetColor(Color.White);
            // loop through all of the graphs
            var   maxVal    = m_vals.Max();
            var   minVal    = 0;
            var   lastValue = m_vals.Peek();
            float stepX     = m_rect.width / m_vals.Count;
            int   index     = 0;

            Vector2 lastPoint = new Vector2(m_rect.Left, m_rect.Bottom - m_rect.height * (lastValue / (maxVal - minVal)));

            foreach (var v in m_vals)
            {
                Vector2 currentPoint = new Vector2(index * stepX + m_rect.x, m_rect.Bottom - m_rect.height * (v / (maxVal - minVal)));
                Graphics.Line(lastPoint, currentPoint);

                lastValue = v;
                index++;
                lastPoint = currentPoint;
            }

            Graphics.SetFont(FPSGraph_FONT);
            Graphics.Print("MAX:" + maxVal.ToString("00.0") + "\nFPS:" + FPSCounter.GetFPS(), m_rect.x, m_rect.Top);
        }
Beispiel #3
0
        private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled == true)
            {
                Debug.WriteLine("RunWorkerCompleted: {1}", "", "Canceled!");
            }
            else if (e.Error != null)
            {
                Debug.WriteLine("RunWorkerCompleted: {1}", "", "Error: " + e.Error.Message);
            }
            else
            {
                ClientType client = (ClientType)e.Result;
                client.DoFinish();

                System.Windows.Controls.Image             previewCaptureImage = (System.Windows.Controls.Image)RootElement.FindName("previewCaptureImage");
                System.Windows.Media.Imaging.BitmapSource bs = client.GetRenderTargetBitmapSource();
                // bs.Freeze();
                previewCaptureImage.Source = bs;

                System.Windows.Controls.TextBlock CapturePerSecond = (System.Windows.Controls.TextBlock)RootElement.FindName("CapturePerSecond");
                CapturePerSecond.Text = "FPS: " + client.FPS.ToString();

                System.Windows.Controls.TextBlock UIRedrawsPerSecond = (System.Windows.Controls.TextBlock)RootElement.FindName("UIRedrawsPerSecond");
                UIRedrawsPerSecond.Text = "DPS: " + drawCounter.GetFPS().ToString();



                GC.Collect();
                drawCounter.IncreaseFrame();
            }
        }
        public override void Update(float dt)
        {
            // Update the state with the delta time, apply it, and update the world transforms.
            var state    = list[activeSkeleton].state;
            var skeleton = list[activeSkeleton].skeleton;

            state.Update(dt);
            state.Apply(skeleton);
            skeleton.UpdateWorldTransform();

            //// vertex effect
            //skeletonRenderer.VertexEffect = swirl;
            //if (skeletonRenderer.VertexEffect != null)
            //{
            //    swirlTime = swirlTime + dt;
            //    var percent = swirlTime % 2;
            //    if (percent > 1) percent = 1 - (percent - 1);
            //    swirl.Angle = InterpolationApply(InterpolationPow2, -60f, 60f, percent);
            //}
            Window.SetTitle("fps : " + FPSCounter.GetFPS() + "  draw-call : " + skeletonRenderer.DrawCallCount);
        }
Beispiel #5
0
 public int GetLastFPS()
 {
     return(fpsCounter.GetFPS());
 }
Beispiel #6
0
    void Update()
    {
        float deltaTime = (unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime) * timescale;

        if (hitDelta.sqrMagnitude > 0)
        {
            hitDelta = Vector2.Lerp(hitDelta, Vector2.zero, FixedLerp.Fix(hitQuitSpeed, FPSCounter.GetFPS() / timescale));
        }

        float targetStrength = GetTargetStrength();
        float targetSpeed    = targetStrength > 0 ? speed : 0;


        if (quitDuration <= 0)
        {
            currentSpeed    = targetSpeed;
            currentStrength = targetStrength;
        }
        else
        {
            float speedMoveSpeed = (speed / quitDuration) * deltaTime;

            float strengthMoveSpeed = float.PositiveInfinity;
            float deltaSpeed        = Math.Abs(targetSpeed - currentSpeed);
            if (deltaSpeed > 0)
            {
                strengthMoveSpeed = (Mathf.Abs(currentStrength - targetStrength) /      //Quantite restante
                                     (deltaSpeed / speedMoveSpeed));                    //Nombre de frame restante
            }
            currentStrength = Mathf.MoveTowards(currentStrength, targetStrength, strengthMoveSpeed);
            currentSpeed    = Mathf.MoveTowards(currentSpeed, targetSpeed, speedMoveSpeed);
        }

        if (currentStrength > 0)
        {
            float height = (Mathf.PerlinNoise(time, 0) * 2 - 1) * currentStrength;
            float width  = (Mathf.PerlinNoise(0, time) * 2 - 1) * currentStrength;

            shakeDelta = new Vector2(height, width);
        }
        else
        {
            shakeDelta = Vector2.zero;
        }

        if (smoothFactor > 1)
        {
            realSmoothedDelta = Vector2.Lerp(realSmoothedDelta, hitDelta + shakeDelta, FixedLerp.Fix(1 / smoothFactor, FPSCounter.GetFPS() / timescale));
        }
        else
        {
            realSmoothedDelta = hitDelta + shakeDelta;
        }

        time += deltaTime * currentSpeed;
        UpdateTimedShakers(deltaTime);
    }