Esempio n. 1
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     if (DFKeyboard.Up.IsKeyDown)
     {
         y += 8;
         Render(game);
     }
     if (DFKeyboard.Down.IsKeyDown)
     {
         y -= 8;
         Render(game);
     }
     if (DFKeyboard.Left.IsKeyDown)
     {
         x /= 2;
         Render(game);
     }
     if (DFKeyboard.Right.IsKeyDown)
     {
         x *= 2;
         Render(game);
     }
     if (DFKeyboard.Space.IsKeyDown)
     {
         noise.Randomize();
         Render(game);
     }
 }
Esempio n. 2
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     if (DFKeyboard.Space && game.IsFocused)
     {
         router.ChangeScene <GameScene>();
     }
 }
Esempio n. 3
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     if (DFKeyboard.Escape.IsKeyUp)
     {
         router.ChangeScene <LauncherScene>();
     }
 }
Esempio n. 4
0
 public override void OnUpdate(Router router, DFEventArgs e)
 {
     if (Input.Keyboard.Space.IsPressed)
     {
         router.ChangeScene <SelectorScene>();
     }
 }
Esempio n. 5
0
        public override void OnUpdate(Router router, DFEventArgs e)
        {
            var    point = Input.Mouse.Position;
            Vector vec   = Vector.Zero;

            if (Input.Keyboard.Left)
            {
                vec.X = 1;
            }
            if (Input.Keyboard.Up)
            {
                vec.Y = 1;
            }
            if (Input.Keyboard.Right)
            {
                vec.X = -1;
            }
            if (Input.Keyboard.Down)
            {
                vec.Y = -1;
            }

            if (Input.Mouse.IsLeftClicked)
            {
                var delta = new Vector(point.X - prevPoint.X, point.Y - prevPoint.Y);
                frontMap.Location += delta / 2;
                backMap.Location  += delta / 2;
            }

            if (Input.Keyboard.Space.IsKeyDown)
            {
                var d = new Dictionary <string, object>();
                if (l == 5)
                {
                    if (a == 1)
                    {
                        d["level"] = 5;
                        d["area"]  = 2;
                    }
                    else
                    {
                        d["level"] = 1;
                        d["area"]  = 1;
                    }
                }
                else
                {
                    d["level"] = l + 1;
                    d["area"]  = 1;
                }
                router.ChangeScene <MapScene>(d);
            }

            frontMap.Location += vec * 128 * (float)e.DeltaTime;
            backMap.Location  += vec * 128 * (float)e.DeltaTime;
            prevPoint          = point;
        }
Esempio n. 6
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            game.ConsoleCursor += VectorInt.Up * 2;
            game.Print($@"Location: {audio.Time / 1000f:0.000} / {audio.Length / 1000f:0.000}
PRESS ESC TO RETURN");

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 7
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            if (DFKeyboard.Space.IsKeyUp)
            {
                player.PlayOneShotAsync(sfx);
            }

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 8
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     if (sprite != null)
     {
         sprite.Location = DFMouse.Position;
         sprite.Scale   += Vector.One * (DFMouse.Scroll.Y / 10);
     }
     if (DFKeyboard.Escape.IsKeyUp)
     {
         router.ChangeScene <LauncherScene>();
     }
 }
Esempio n. 9
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            UpdateTrail();
            RenderSnake();

            hud.Text = $"{Time.Fps}FPS SCORE:{score} Life:{life} Level{level}";

            if (introDone)
            {
                HandleKey();
                if (!prevIntroDone)
                {
                    PopulateApple();
                }
                tickCount++;
                if (tickCount > 2)
                {
                    IncrementScore(scoreAdditionByTick, false);
                    tickCount = 0;
                }
                prevIntroDone = introDone;
            }

            if (IntersectWithApple())
            {
                if (currentAppleType == AppleType.Normal)
                {
                    snake.Add(GenPart());
                    if (Length > 10)
                    {
                        level++;
                        snake.RemoveRange(1, Length - 1);
                        IncrementScore(scoreAdditionByLevelUp, false);
                        DisplayTextParticle("LEVEL UP!", snake.First().Location * 2);
                    }
                    else
                    {
                        IncrementScore(scoreAdditionByApple);
                    }
                }
                else
                {
                    life++;
                    IncrementScore(scoreAdditionByGoldApple);
                }
                if (currentApple != null)
                {
                    stageContainer.Remove(currentApple);
                }
                PopulateApple();
            }
        }
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            if (DFKeyboard.Escape.IsKeyUp)
            {
                cts.Cancel();
                router.ChangeScene <LauncherScene>();
            }

            if (sp != null)
            {
                sp.Location = DFMouse.Position;
            }
        }
Esempio n. 11
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            game.Cls();
            game.Print($"Time: {Time.Now}");
            game.Print($"DeltaTime: {Time.DeltaTime}");
            game.Print($"Fps: {Time.Fps}");
            game.Print("Press [ESC] to return");

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 12
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            if (!initialized)
            {
                return;
            }
            Title = $"{Time.Fps} FPS";

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 13
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     time += e.DeltaTime;
     if (time > 0.125f)
     {
         var t = new TextDrawable($"Test {count++}", Font.GetDefault(Random.Next(8, 48)), Random.NextColor());
         t.Location = Random.NextVector(game.Width, game.Height) / (int)game.Dpi;
         Root.Add(t);
         time = 0;
     }
     if (DFKeyboard.Escape.IsKeyUp)
     {
         router.ChangeScene <LauncherScene>();
     }
 }
Esempio n. 14
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     if (DFKeyboard.Up)
     {
         container.Scale += Vector.One * 0.25f * Time.DeltaTime;
     }
     if (DFKeyboard.Down)
     {
         container.Scale -= Vector.One * 0.25f * Time.DeltaTime;
     }
     container.Location += DFMouse.Scroll * new Vector(-1, 1);
     if (DFKeyboard.Escape.IsKeyUp)
     {
         router.ChangeScene <LauncherScene>();
     }
 }
Esempio n. 15
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            game.Cls();
            game.Print("Keyboard State");
            game.Print($@"Pressing: {string.Join(",", DFKeyboard.AllPressedKeys.Select(d => d.ToString()))}");
            game.Print($@"Pressed: {string.Join(",", DFKeyboard.AllDownKeys.Select(d => d.ToString()))}");
            game.Print($@"Released: {string.Join(",", DFKeyboard.AllUpKeys.Select(d => d.ToString()))}");
            game.Print($@"Input Buffer: {buf}");
            game.Print("Press [ESC] to return");
            buf += DFKeyboard.GetString();

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 16
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            game.Cls();
            game.Print("Mouse State");
            game.Print($"Left: {Left()}");
            game.Print($"Middle: {Middle()}");
            game.Print($"Right: {Right()}");
            game.Print($"Scroll: {DFMouse.Scroll}");
            game.Print($"Pos: {DFMouse.Position}");
            game.Print("Press [ESC] to return");

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 17
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            timeCount += e.DeltaTime;
            if (timeCount > 5 && coroutine !.IsRunning)
            {
                // Stop the coroutine
                // コルーチンを停止
                game.StopCoroutine(coroutine !);
                game.Print("Stopped the coroutine!");
                game.Print("Press [ESC] to return");
            }

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 18
0
        public override void OnUpdate(Router router, DFEventArgs e)
        {
            var d      = Input.Keyboard.D.IsPressed;
            var f      = Input.Keyboard.F.IsPressed;
            var j      = Input.Keyboard.J.IsPressed;
            var k      = Input.Keyboard.K.IsPressed;
            var space  = Input.Keyboard.Space.IsPressed;
            var escape = Input.Keyboard.Escape.IsPressed;

            if (d && !prevD || k && !prevK)
            {
                index += d ? -1 : 1;
                if (index < 0)
                {
                    index = scores.Length - 1;
                }
                if (index > scores.Length - 1)
                {
                    index = 0;
                }
                player.Stop();
                // while (player.IsPlaying)
                //  Thread.Sleep(1);
                player.Play(CurrentScore?.Source, 0);
                Console.WriteLine(CurrentScore?.ToString() ?? "NULL");
                UpdateView(router);
            }
            if (f && !prevF || j && !prevJ)
            {
                router.ChangeScene <PlayScene>(new Dictionary <string, object> {
                    { "score", CurrentScore }
                });
            }
            if (escape && !prevEscape)
            {
                router.ChangeScene <TitleScene>();
            }

            prevD      = d;
            prevF      = f;
            prevJ      = j;
            prevK      = k;
            prevSpace  = space;
            prevEscape = escape;
        }
Esempio n. 19
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }

            // sprites location
            sprite.Location    = new Vector(game.Width / 4 - 128, 64);
            nineslice.Location = new Vector(game.Width / 4 + 32, 64);

            // text location
            t1.Location = new Vector(sprite.Location.X, sprite.Location.Y - 24);
            t2.Location = new Vector(nineslice.Location.X, nineslice.Location.Y - 24);

            sprite.Width  = nineslice.Width = (int)(64 + 64 * Math.Abs(Math.Sin(Time.Now * 2)));
            sprite.Height = nineslice.Height = (int)(64 + 256 * Math.Abs(Math.Sin(Time.Now * 2)));
        }
Esempio n. 20
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            var mouse = DFMouse.Position;

            if (DFMouse.IsRightDown)
            {
                g.Clear();
            }

            if (DFMouse.IsLeft)
            {
                g.Line(prevMouse, mouse, Color.White);
            }

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }

            prevMouse = mouse;
        }
Esempio n. 21
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            game.Cls();
            game.Print($@"Playing {freq}Hz Sine Wave
[←]:Down Frequency [→]: Up Frequency
PRESS ESC TO RETURN");

            if (DFKeyboard.Right)
            {
                freq += 10;
            }
            else if (DFKeyboard.Left)
            {
                freq -= 10;
            }

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 22
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            editorView.Text = buf.ToString() + '_';
            if ((DFKeyboard.BackSpace.ElapsedFrameCount == 1 || DFKeyboard.BackSpace.ElapsedTime > 0.5f && DFKeyboard.BackSpace.ElapsedFrameCount % 3 == 0) && buf.Length > 0)
            {
                buf.Length--;
            }
            if (DFKeyboard.Enter.ElapsedFrameCount == 1 || DFKeyboard.Enter.ElapsedTime > 0.5f && DFKeyboard.Enter.ElapsedFrameCount % 3 == 0)
            {
                buf.Append('\n');
            }

            if (DFKeyboard.HasChar())
            {
                buf.Append(DFKeyboard.GetString());
            }

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 23
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     if (DFKeyboard.Escape.IsKeyUp)
     {
         router.ChangeScene <LauncherScene>();
     }
     else if (DFKeyboard.Number1.IsKeyUp)
     {
         game.WindowMode = WindowMode.NoFrame;
     }
     else if (DFKeyboard.Number2.IsKeyUp)
     {
         game.WindowMode = WindowMode.Resizable;
     }
     else if (DFKeyboard.Number3.IsKeyUp)
     {
         game.WindowMode = WindowMode.Fixed;
     }
     else if (DFKeyboard.Number4.IsKeyUp)
     {
         game.IsFullScreen ^= true;
     }
 }
Esempio n. 24
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            text.Text = $@"Container: {(VectorInt)container.Location}
Relative: {(VectorInt)text.Location}
Absolute: {(VectorInt)text.AbsoluteLocation}";
            if (!DFKeyboard.ShiftLeft)
            {
                container.Location += Vector.One * 32 * way * e.DeltaTime;
                if (container.Location.X > 256)
                {
                    way = -1;
                }
                if (container.Location.X < 0)
                {
                    way = 1;
                }
            }

            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 25
0
        public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
        {
            VectorInt Rnd() => Random.NextVectorInt(game.Width, game.Height);

            time += e.DeltaTime;
            if (time > 0.125f)
            {
                switch (Random.Next(5))
                {
                case 0:
                    g.Line(Rnd(), Rnd(), Random.NextColor());
                    break;

                case 1:
                    g.Rect(Rnd(), Rnd(), Random.NextColor(), Random.Next(4), Random.NextColor());
                    break;

                case 2:
                    g.Ellipse(Rnd(), Rnd(), Random.NextColor(), Random.Next(4), Random.NextColor());
                    break;

                case 3:
                    g.Pixel(Rnd(), Random.NextColor());
                    break;

                case 4:
                    g.Triangle(Rnd(), Rnd(), Rnd(), Random.NextColor(), Random.Next(4), Random.NextColor());
                    break;
                }
                time = 0;
            }
            if (DFKeyboard.Escape.IsKeyUp)
            {
                router.ChangeScene <LauncherScene>();
            }
        }
Esempio n. 26
0
 public override void OnUpdate(Router router, GameBase game, DFEventArgs e)
 {
     Title           = $"DotFeather Demo - {DemoOS.CurrentDirectory.Name.ToUpperInvariant()}";
     listView.Width  = game.Width - 32;
     listView.Height = game.Height - 16 - (int)listView.Location.Y;
 }
Esempio n. 27
0
 public override void OnUpdate(Router router, DFEventArgs e)
 {
 }
Esempio n. 28
0
 protected override void OnUpdate(object sender, DFEventArgs e)
 {
     router.Update(e);
 }
Esempio n. 29
0
 public override void OnUpdate(Router router, DFEventArgs e)
 {
     statText.Text     = statusText;
     statText.Location = new Vector(router.Game.Width / 2 - statText.Texture.Size.Width / 2, router.Game.Height - 32);
     DrawBar(router.Game);
 }