コード例 #1
0
 public void BeginTiming()
 {
     if (m_state != TimingState.IDLE)
     {
         return;
     }
     Reset();
     m_state = TimingState.TIMING;
 }
コード例 #2
0
 private void CheckTimePassedThreshhold()
 {
     if (m_timePassed < m_time)
     {
         return;
     }
     m_timePassed = 0f;
     m_state      = TimingState.IDLE;
     m_onTimingFinished?.Invoke();
 }
コード例 #3
0
        private void UpdateControl(Control control, TimingState time)
        {
            Rectangle controlRect = control.Rectangle;

            if (control is IControlContainer)
            {
                IControlContainer container = (IControlContainer)control;

                foreach (Control child in container.Controls)
                    this.UpdateControl(control, time);
            }
        }
コード例 #4
0
        public void Update(TimingState time, Control root)
        {
            if (time == null)
                throw new ArgumentNullException("time");

            if (root == null)
                throw new ArgumentNullException("root");

            this.mouse.Update(time);

            this.UpdateControl(root, time);
        }
コード例 #5
0
ファイル: Canvas2DGame.cs プロジェクト: HaKDMoDz/Samurai
        protected override void Draw(TimingState time)
        {
            this.Graphics.Clear();

            this.canvas.Begin();

            Vector2 center = new Vector2(this.Window.Width / 2, this.Window.Height / 2);

            this.solidColorBrush.Color = Color4.Yellow;
            this.canvas.DrawLine(Vector2.Zero, new Vector2(this.Window.Width, this.Window.Height), 1, solidColorBrush);
            this.canvas.DrawLine(new Vector2(0, this.Window.Height), new Vector2(this.Window.Width, 0), 1, solidColorBrush);

            this.textureBrush.Texture = this.lineStripe;
            this.textureBrush.Tint = Color4.Blue;
            this.textureBrush.Source = null;

            this.linearGradientBrush.Angle = MathHelper.ToRadians(this.rotation);
            this.linearGradientBrush.StartColor = Color4.Red;
            this.linearGradientBrush.EndColor = Color4.Green;
            //this.canvas.DrawTriangleStrip(this.polygonPositions, this.linearGradientBrush);
            this.canvas.DrawRectangle(new Rectangle(400, 400, 200, 200), this.linearGradientBrush);

            this.textureBrush.Texture = this.samuraiLogo;
            this.textureBrush.Tint = Color4.White;

            this.canvas.DrawCircle(new Vector2(128, 128), 128, this.textureBrush);

            this.canvas.DrawTriangle(
                new Vector2(center.X - 128, center.Y + 128),
                new Vector2(center.X + 128, center.Y + 128),
                new Vector2(center.X, center.Y - 128),
                this.textureBrush);

            this.textureBrush.Source = new Rectangle(96, 96, 64, 64);
            this.canvas.DrawRectangle(new Rectangle((int)center.X - 32, (int)center.Y - 32, 64, 64), this.textureBrush);

            this.rotation += (float)time.ElapsedTime.TotalSeconds * 36.0f;

            this.textureBrush.Texture = this.lineStripe;
            this.textureBrush.Tint = Color4.Red;
            this.textureBrush.Source = null;

            Vector2 end = new Vector2(center.X, center.Y - 300);
            Vector2.RotateAboutOrigin(ref end, ref center, MathHelper.ToRadians(this.rotation), out end);
            float distance = Vector2.Distance(center, end);
            this.canvas.DrawLine(center, end, 5.0f, this.textureBrush);

            this.canvas.End();

            this.Graphics.SwapBuffers();
        }
コード例 #6
0
ファイル: Demo2DGame.cs プロジェクト: HaKDMoDz/Samurai
        protected override void Draw(TimingState time)
        {
            this.Graphics.Clear(Color4.Black);

            this.spriteRenderer.Begin(this.shaderProgram);

            string text = string.Format("FPS: {0}", fps);

            Size textSize = this.font.MeasureString(text);
            int halfWindowWidth = this.Window.Width / 2;
            int halfWindowHeight = this.Window.Height / 2;
            int halfTextWidth = textSize.Width / 2;
            int halfTextHeight = textSize.Height / 2;

            this.spriteRenderer.DrawString(
                this.font,
                text,
                new Rectangle(halfWindowWidth - halfTextWidth, halfWindowHeight - halfTextHeight, textSize.Width, textSize.Height),
                tint: Color4.CornflowerBlue,
                origin: new Vector2(halfTextWidth, halfTextHeight),
                rotation: MathHelper.ToRadians(45.0f),
                layerDepth: 0.5f);

            foreach (Plane plane in this.planes)
            {
                this.spriteRenderer.Draw(
                    this.planeSpriteSheet,
                    plane.StartFrame + plane.FrameOffset,
                    plane.Position,
                    origin: new Vector2(32, 32),
                    rotation: MathHelper.ToRadians(plane.Rotation)
                );
            }

            this.spriteRenderer.End();

            this.Graphics.SwapBuffers();

            this.fpsCount++;
            this.fpsTimer += (float)time.ElapsedTime.TotalSeconds;
            if (this.fpsTimer >= 1.0f)
            {
                this.fps = this.fpsCount;
                this.fpsTimer -= 1.0f;
                this.fpsCount = 0;
            }
        }
コード例 #7
0
ファイル: DemoGame.cs プロジェクト: HaKDMoDz/Samurai
        protected override void Update(TimingState time)
        {
            this.gamePad1.Update();

            Vector2 leftThumbStick = this.gamePad1.LeftThumbStick;
            this.rotationZ += (float)(2.0f * time.ElapsedTime.TotalSeconds * -leftThumbStick.X);
            this.translationX += (float)(5.0f * time.ElapsedTime.TotalSeconds * Math.Sin(this.rotationZ) * leftThumbStick.Y);
            this.translationZ += (float)(5.0f * time.ElapsedTime.TotalSeconds * Math.Cos(this.rotationZ) * leftThumbStick.Y);
        }
コード例 #8
0
ファイル: DemoGame.cs プロジェクト: HaKDMoDz/Samurai
        protected override void Draw(TimingState time)
        {
            this.Graphics.Clear(Color4.CornflowerBlue);

            Vector3 eye = new Vector3(-this.translationX, 0, this.translationZ);
            Vector3 target = new Vector3(-this.translationX + (float)Math.Sin(this.rotationZ), 0, this.translationZ + (float)-Math.Cos(this.rotationZ));
            Vector3 up = Vector3.UnitY;

            Matrix4 projection =
                Matrix4.LookAt(ref eye, ref target, ref up) *
                Matrix4.PerspectiveFOV(120.0f, (float)this.Window.Width / (float)this.Window.Height, 0.1f, 100.0f);

            this.Graphics.ShaderProgram = this.shaderProgram;
            this.shaderProgram.SetValue("projection", ref projection);
            this.shaderProgram.SetValue("texture0", this.texture1);

            this.Graphics.Draw(PrimitiveType.Triangles, this.vertexBuffer, this.indexBuffer);

            this.controlRenderer.Begin();
            this.panel.Draw(this.controlRenderer);
            this.controlRenderer.End();

            this.Graphics.SwapBuffers();
        }
コード例 #9
0
ファイル: Demo2DGame.cs プロジェクト: HaKDMoDz/Samurai
        protected override void Update(TimingState time)
        {
            this.keyboard.Update();
            this.mouse.Update(time);

            if (this.keyboard.IsKeyPressed(Key.Escape))
                this.Exit();

            foreach (Plane plane in this.planes)
            {
                plane.Update(time.ElapsedTime);
            }
        }