示例#1
0
文件: JS.cs 项目: MSylvia/disaster5
        public void Update(double deltaTime)
        {
            if (stopped)
            {
                if (Raylib.IsKeyPressed(KeyboardKey.KEY_R))
                {
                    Assets.UnloadAll();
                    Reset();
                    stopped = false;
                }
                return;
            }

            try
            {
                DisasterAPI.Input.Update();

                updateFunction.Call(null, deltaTime);
            }
            catch (JavaScriptException e)
            {
                if (Assets.LoadPath("fontsmall.png", out string fontPath))
                {
                    SoftwareCanvas.LoadFont(fontPath);
                }
                string message = $"line:{e.LineNumber} {e.Message}";
                Program.LoadingMessage(message, new Color32(255, 50, 0));
                Program.LoadingMessage("press R to reload", new Color32(255, 50, 0));
                stopped = true;
            }
        }
示例#2
0
文件: JS.cs 项目: Sievaxx/disaster5
        public void Update(double deltaTime)
        {
            if (stopped)
            {
                if (Raylib.IsKeyPressed(KeyboardKey.KEY_R))
                {
                    Assets.UnloadAll();
                    Assets.assignedDefaultShader = false;
                    ScreenController.instance.ReloadShader();
                    Reset();
                    stopped = false;
                }
                return;
            }

            try
            {
                DisasterAPI.Input.Update();

                updateFunction.Call(null, deltaTime);
            }
            catch (JavaScriptException e)
            {
                if (Assets.LoadPath("fontsmall.png", out string fontPath))
                {
                    SoftwareCanvas.LoadFont(fontPath);
                }
                string message = $"line:{e.LineNumber} {e.Message}\nPress R to restart";

                //Program.LoadingMessage(message, new Color32(255, 50, 0));
                //Program.LoadingMessage("press R to reload", new Color32(255, 50, 0));
                int x     = 32;
                int y     = 32;
                int chars = 32;
                int lines = ((message.Length / chars) + message.Count(f => f == '\n')) + 2;

                SoftwareCanvas.FillRect(x - 4, y - 4, chars * SoftwareCanvas.fontWidth + 8, lines * SoftwareCanvas.fontHeight + 8, new Color32(255, 180, 0));

                for (int i = x - 4; i < x + chars * SoftwareCanvas.fontWidth + 4; i++)
                {
                    for (int j = y - 4; j < y + lines * SoftwareCanvas.fontHeight + 4; j++)
                    {
                        if ((i + j) % 6 < 3)
                        {
                            SoftwareCanvas.Pixel(i, j, new Color32(0, 0, 0));
                        }
                    }
                }

                SoftwareCanvas.FillRect(x - 1, y - 1, chars * SoftwareCanvas.fontWidth + 2, lines * SoftwareCanvas.fontHeight + 2, new Color32(12, 12, 12));

                SoftwareCanvas.Paragraph(x, y, new Color32(255, 50, 0), message, chars);
                stopped = true;
            }
        }
示例#3
0
        public void Update(double deltaTime)
        {
            if (stopped)
            {
                return;
            }

            try
            {
                DisasterAPI.Input.UpdateMouse();

                updateFunction.Call(null, deltaTime);
            }
            catch (JavaScriptException e)
            {
                string message = $"path: {e.SourcePath}:{e.LineNumber} message: {e.Message}";
                Program.LoadingMessage(message, new Color32(255, 50, 0));
                stopped = true;
            }
        }
示例#4
0
文件: ImpactGame.cs 项目: Kevnz/JS360
        public void setInterval(Jurassic.Library.FunctionInstance callback, int ms)
        {
            float target = ms < 34 ? 0 : (float)ms / 1000; // make sure a timer with a target <= 33ms is fired each frame

            timers.Create(target, true, () => callback.Call(js.Global));
        }
示例#5
0
文件: ImpactGame.cs 项目: Kevnz/JS360
 // set/clear timeout/inveral
 public void setTimeout(Jurassic.Library.FunctionInstance callback, int ms)
 {
     timers.Create((float)ms / 1000, false, () => callback.Call(js.Global));
 }