public void InitAi()
        {
            if (_player)
            {
                SetupHpbar();
                return;
            }
            try
            {
                LuaFunction start = _luaState.GetFunction("Start");
                if (start != null)
                {
                    start.Call();
                }

                _update = _luaState.GetFunction("Update");
                StartCoroutine(AiCaller(AiDelay));
            }
            catch (LuaScriptException ex)
            {
                string name = _luaState["Name"] as string;
                if (name == null)
                {
                    name = "";
                }

                Debug.LogError(name + ": Exception occured while starting Lua script: " + ex);
                _printer.Print(name + ": Exception occured while starting Lua script: " + ex, Color.red, true, false);
                _printer.Endl();
            }
        }
Exemplo n.º 2
0
        public void Render2D()
        {
            if (_rect.IsEmpty)
            {
                var te = _printer.Measure(_text, SystemFonts.MessageBoxFont, new RectangleF(0, 0, Viewport.Width, Viewport.Height));
                _rect         = te.BoundingBox;
                _rect.X      += 5;
                _rect.Y      += 2;
                _rect.Width  += 5;
                _rect.Height += 2;
            }

            GL.Disable(EnableCap.CullFace);

            _printer.Begin();
            if (_showing)
            {
                GL.Begin(PrimitiveType.Quads);
                GL.Color3(Viewport is Viewport3D ? View.ViewportBackground : Grid.Background);
                GL.Vertex2(0, 0);
                GL.Vertex2(_rect.Right, 0);
                GL.Vertex2(_rect.Right, _rect.Bottom);
                GL.Vertex2(0, _rect.Bottom);
                GL.End();
            }
            _printer.Print(_text, SystemFonts.MessageBoxFont, _showing ? Color.White : Grid.GridLines, _rect);
            _printer.End();

            GL.Enable(EnableCap.CullFace);
        }
Exemplo n.º 3
0
 public void DrawString(
     string text,
     double x,
     double y)
 {
     textPrinter.Print(this, text.ToString(), x, y);
 }
        public void Create()
        {
            _logger  = GameObject.Find("Logger").GetComponent <Text>();
            _printer = new TextPrinter(_logger);

            // Initializing variables
            _tank = GetComponent <Tank>();

            if (ScriptPath != "")
            {
                // Initializing LUA
                _luaState = new Lua();
                Debug.Log(Environment.CurrentDirectory);
                Debug.Log("Loading script: " + ScriptPath);
                try
                {
                    _mainFile = _luaState.LoadFile(ScriptPath);
                    _mainFile.Call();

                    SetupPrefs();
                    RegFuncs();
                }
                catch (LuaException ex)
                {
                    Debug.LogError("Exception occured while loading Lua script: " + ex);
                    _printer.Print("Exception occured while loading Lua script: " + ex, Color.red, true, false);
                    _printer.Endl();
                }
            }
            else
            {
                gameObject.AddComponent <ManualTankController>();
                _player = true;
            }
        }
Exemplo n.º 5
0
        public void Test_Printer_Prints()
        {
            //arrange
            TextPrinter printer = new TextPrinter("utterance");

            //act
            Assert.IsTrue(string.IsNullOrEmpty(printer.Printed));
            printer.Print();
            //assert
            Assert.IsTrue(printer.Printed == "utterance");
        }
Exemplo n.º 6
0
        public static void Render(params string[] message)
        {
            textPrinter.Begin();

            foreach (string msg in message)
            {
                textPrinter.Print(msg, Font, Color.Gray);
                GL.Translate(0, FontHeight, 0);
            }

            textPrinter.End();
        }
Exemplo n.º 7
0
        public void Render(RenderInfo info)
        {
            GL.ActiveTexture(TextureUnit.Texture0);

            textPrinter.Begin();

            Font  font = Control.DefaultFont;
            SizeF size = new SizeF(500, Objects.Count * (2 * font.SizeInPoints));

            textPrinter.Print(text, font, Color, new RectangleF(Location, size));

            textPrinter.End();
        }
Exemplo n.º 8
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);

            // We'll start printing from the lower left corner of the screen. The text
            // will slowly move updwards - the user can control the movement speed with
            // the keyboard arrows and the space bar.
            current_position += scroll_speed * (float)e.Time;
            if (scroll_speed > 0.0f && current_position > initial_position)
            {
                current_position = wraparound_position;
            }
            else if (scroll_speed < 0.0f && current_position < wraparound_position)
            {
                current_position = initial_position;
            }

            // TextPrinter.Begin() sets up a 2d orthographic projection, with the x axis
            // moving from 0 to viewport.Width (left to right) and the y axis from
            // 0 to viewport.Height (top to bottom). This is the typical coordinate system
            // used in 2d graphics, and is necessary for achieving pixel-perfect glyph rendering.
            // TextPrinter.End() restores your previous projection/modelview matrices.
            text.Begin();

            // Print FPS counter. Since the counter changes per frame,
            // it shouldn't be cached (TextPrinterOptions.NoCache).
            text.Print((1.0 / e.Time).ToString("F2"), sans, Color.SpringGreen, new RectangleF(0, 0, Width, 0), TextPrinterOptions.NoCache, TextAlignment.Far);

            // Print the actual text.
            GL.Translate(0, current_position, 0);
            text.Print(poem, serif, Color.White, new RectangleF(Width / 2, 0, Width / 2, 0), TextPrinterOptions.Default, TextAlignment.Far);
            text.Print(poem, serif, Color.White, new RectangleF(0, 0, Width / 2, 0));

            text.End();

            SwapBuffers();
        }
Exemplo n.º 9
0
        public void Render(RenderInfo info)
        {
            GL.ActiveTexture(TextureUnit.Texture0);

            textPrinter.Begin();

            double spf = accumTime / timeBuffer.Count;

            textPrinter.Print(string.Format("SPF: {0:F3}{1}FPS: {2}",
                                            spf,
                                            Environment.NewLine,
                                            Math.Round(1 / spf)),
                              Control.DefaultFont,
                              Color,
                              new RectangleF(Location, new SizeF(200, 40)));

            textPrinter.End();
        }
Exemplo n.º 10
0
        public void Render2D(Viewport2D viewport, MapObject o)
        {
            if (viewport.Zoom < 1)
            {
                return;
            }

            var entityData = o.GetEntityData();

            if (entityData == null)
            {
                return;
            }

            var start = viewport.WorldToScreen(viewport.Flatten(o.BoundingBox.Start));
            var end   = viewport.WorldToScreen(viewport.Flatten(o.BoundingBox.End));

            if (start.X >= viewport.Width || end.X <= 0 || start.Y >= viewport.Height || end.Y <= 0)
            {
                return;
            }

            var text     = entityData.Name;
            var nameProp = entityData.GetPropertyValue("targetname");

            if (!String.IsNullOrWhiteSpace(nameProp))
            {
                text += ": " + nameProp;
            }

            // Center the text horizontally
            var wid    = _printer.Measure(text, _printerFont, new RectangleF(0, 0, viewport.Width, viewport.Height));
            var cx     = (float)(start.X + (end.X - start.X) / 2);
            var bounds = new RectangleF(cx - wid.BoundingBox.Width / 2, viewport.Height - (float)end.Y - _printerFont.Height - 6, viewport.Width, viewport.Height);

            _printer.Print(text, _printerFont, o.Colour, bounds);
        }
Exemplo n.º 11
0
        public static void Main(string[] args)
        {
            var data = "Hello World !";
            AbstractMediator abstractMediator = new Mediator.Mediator();

            AbstractPrinter textPrinter = new TextPrinter(abstractMediator);
            AbstractPrinter xmlPrinter  = new XmlPrinter(abstractMediator);
            AbstractPrinter htmlPrinter = new HtmlPrinter(abstractMediator);

            abstractMediator.Register(textPrinter);
            abstractMediator.Register(xmlPrinter);
            abstractMediator.Register(htmlPrinter);

            Console.WriteLine("Text Printer talking ......\n");
            textPrinter.Print(data, textPrinter.PrinterType);
            textPrinter.PrintToOtherFormat(data, xmlPrinter.PrinterType, textPrinter.PrinterType);

            Console.WriteLine("\nText Printer talking ......\n");
            xmlPrinter.Print(data, xmlPrinter.PrinterType);
            xmlPrinter.PrintToOtherFormat(data, textPrinter.PrinterType, xmlPrinter.PrinterType);

            Console.WriteLine("\nText Printer talking ......\n");
            htmlPrinter.PrintToOtherFormat(data, xmlPrinter.PrinterType, htmlPrinter.PrinterType);
        }
Exemplo n.º 12
0
 public void ShowEncounterMessage(InstancePokemonObject pokemon)
 {
     textPrinter.Print("A wild " + pokemon.name + " appeared!");
 }
Exemplo n.º 13
0
        protected override void OnRenderFrame(OpenTK.FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.LoadIdentity();

            if ((gameState == GameState.StartingUp) ||
                (gameState == GameState.Running))
            {
                // Draw status text box
                GL.Color3(Themes.Black.Background);
                GL.Begin(BeginMode.Quads);
                GL.Vertex2(0, 0);
                GL.Vertex2(0, plotAreaTop);
                GL.Vertex2(this.Width, plotAreaTop);
                GL.Vertex2(this.Width, 0);
                GL.End();

                // Draw plots
                for (int plotIndex = 0; plotIndex < plots.Length; plotIndex++)
                {
                    var plotRectangle = plots[plotIndex];

                    GL.PushMatrix();
                    GL.Translate(plotRectangle.Left, plotRectangle.Top, 0);

                    GL.Color3(Themes.Green.Background);
                    GL.Begin(BeginMode.Quads);
                    GL.Vertex2(0, 0);
                    GL.Vertex2(0, plotRectangle.Height);
                    GL.Vertex2(plotRectangle.Width, plotRectangle.Height);
                    GL.Vertex2(plotRectangle.Width, 0);
                    GL.End();

                    GL.Color3(Themes.Green.Border);
                    GL.LineWidth(2);
                    GL.Begin(BeginMode.LineLoop);
                    GL.Vertex2(0, 0);
                    GL.Vertex2(0, plotRectangle.Height);
                    GL.Vertex2(plotRectangle.Width, plotRectangle.Height);
                    GL.Vertex2(plotRectangle.Width, 0);
                    GL.End();

                    var textOffset = plotNumberOffsets[plotIndex];

                    GL.Translate(textOffset.X, textOffset.Y, 0);
                    plotPrinter.Print((plotIndex + 1).ToString(),
                                      plotNumberFont, Themes.Green.Border);

                    GL.PopMatrix();

                    var emptyFood = emptyPlotFood[plotIndex];

                    if (emptyFood.IsPresent)
                    {
                        RenderFood(emptyFood.FoodTextureId, emptyFood.Count,
                                   plotRectangle.Left + (plotRectangle.Width / 2.0f),
                                   (plotRectangle.Top + (plotRectangle.Height / 2.0f)) + (playerSize / 2.0),
                                   emptyFood.Opacity);
                    }
                }

                // Draw players
                GL.Color3(Themes.Blue.Background);
                GL.Begin(BeginMode.Quads);
                GL.Vertex2(0, playerSectionTop);
                GL.Vertex2(0, this.Height);
                GL.Vertex2(this.Width, this.Height);
                GL.Vertex2(this.Width, playerSectionTop);
                GL.End();

                GL.LineWidth(2);
                GL.Color3(Themes.Blue.Border);
                GL.Begin(BeginMode.Lines);
                GL.Vertex2(0, playerSectionTop);
                GL.Vertex2(this.Width, playerSectionTop);
                GL.End();

                for (int playerIndex = 0; playerIndex < Settings.Players; playerIndex++)
                {
                    var    player = players[playerIndex];
                    double slotLeft = 0, slotTop = 0;
                    int    textureId = 0;

                    if (player.State == PlayerState.Traveling)
                    {
                        // Layout players left to right, top to bottom
                        slotLeft = (playerSlotSize * player.Position) % this.Width;

                        var playerSlotRow = (double)(player.Position / playersPerSectionRow);
                        slotTop = playerSectionTop + (playerSlotRow * playerSlotSize);

                        textureId = playerGrayTextureIds[playerIndex];
                    }
                    else if (player.State == PlayerState.WaitingForInput)
                    {
                        // Draw in plot
                        var plot = plots[player.PlotNumber];
                        var playersPerPlotRow = (int)Math.Max(1, Math.Floor(plot.Width / playerSlotSize));
                        slotLeft = plot.Left + ((player.Position % playersPerPlotRow) * playerSlotSize);
                        slotTop  = plot.Top + ((player.Position / playersPerPlotRow) * playerSlotSize);

                        textureId = playerTextureIds[playerIndex];
                    }
                    else
                    {
                        // Don't draw player during in-between states
                        continue;
                    }

                    // Center player in the slots
                    player.Left = slotLeft + ((playerSlotSize - playerSize) / 2.0);
                    player.Top  = slotTop + ((playerSlotSize - playerSize) / 2.0);

                    var actualPlayerTop = player.Top - player.TopOffset;

                    // Draw texture of player
                    GL.Color4(1, 1, 1, player.Opacity);
                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, textureId);

                    GL.Begin(BeginMode.Quads);
                    GL.TexCoord2(0, 0);
                    GL.Vertex2(player.Left, actualPlayerTop);

                    GL.TexCoord2(0, 1);
                    GL.Vertex2(player.Left, actualPlayerTop + playerSize);

                    GL.TexCoord2(1, 1);
                    GL.Vertex2(player.Left + playerSize, actualPlayerTop + playerSize);

                    GL.TexCoord2(1, 0);
                    GL.Vertex2(player.Left + playerSize, actualPlayerTop);
                    GL.End();

                    // Draw food if player has received some
                    if ((player.FoodOpacity > 0) && (player.FoodFound > 0))
                    {
                        RenderFood(player.FoodTextureId, player.FoodFound,
                                   player.Left + (playerSize / 2.0), actualPlayerTop + playerSize,
                                   player.FoodOpacity);
                    }

                    GL.Disable(EnableCap.Texture2D);
                }

                // Draw player shadows
                for (int playerIndex = 0; playerIndex < Settings.Players; playerIndex++)
                {
                    var shadow = playerShadows[playerIndex];

                    if (shadow.Opacity <= 0)
                    {
                        continue;
                    }

                    GL.Color4(1, 1, 1, shadow.Opacity);
                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, shadow.IsGray ?
                                   playerGrayTextureIds[shadow.PlayerId] : playerTextureIds[shadow.PlayerId]);

                    GL.Begin(BeginMode.Quads);
                    GL.TexCoord2(0, 0);
                    GL.Vertex2(shadow.Left, shadow.Top);

                    GL.TexCoord2(0, 1);
                    GL.Vertex2(shadow.Left, shadow.Top + playerSize);

                    GL.TexCoord2(1, 1);
                    GL.Vertex2(shadow.Left + playerSize, shadow.Top + playerSize);

                    GL.TexCoord2(1, 0);
                    GL.Vertex2(shadow.Left + playerSize, shadow.Top);
                    GL.End();

                    GL.Disable(EnableCap.Texture2D);
                }

                // Draw status text
                GL.PushMatrix();
                GL.Translate(statusTextPoint.X, statusTextPoint.Y, 0);
                statusPrinter.Print(statusText, statusFont, Themes.Black.Foreground,
                                    RectangleF.Empty, TextPrinterOptions.NoCache);

                GL.PopMatrix();
            }
            else if ((gameState == GameState.Blurring) ||
                     (gameState == GameState.BlurFinished) ||
                     (gameState == GameState.ShowingScoreBoard))
            {
                // Render background texture
                GL.Enable(EnableCap.Texture2D);
                GL.BindTexture(TextureTarget.Texture2D, endGameState.TextureId);

                GL.Color3(Color.White);
                GL.Begin(BeginMode.Quads);

                GL.TexCoord2(0, 1);
                GL.Vertex2(0, 0);

                GL.TexCoord2(0, 0);
                GL.Vertex2(0, this.Height);

                GL.TexCoord2(1, 0);
                GL.Vertex2(this.Width, this.Height);

                GL.TexCoord2(1, 1);
                GL.Vertex2(this.Width, 0);
                GL.End();

                if (gameState == GameState.Blurring)
                {
                    double centerLeft = this.Width / 2.0, centerTop = this.Height / 2.0;

                    GL.Translate(centerLeft, centerTop, 0);
                    GL.Rotate(endGameState.Rotation, 0, 0, 1);
                    GL.Translate(-centerLeft, -centerTop, 0);

                    // Render blur
                    GL.Color4(1, 1, 1, endGameState.BlurOpacity);
                    GL.Begin(BeginMode.Quads);

                    GL.TexCoord2(0 + endGameState.TextureOffset, 1 - endGameState.TextureOffset);
                    GL.Vertex2(0, 0);

                    GL.TexCoord2(0 + endGameState.TextureOffset, 0 + endGameState.TextureOffset);
                    GL.Vertex2(0, this.Height);

                    GL.TexCoord2(1 - endGameState.TextureOffset, 0 + endGameState.TextureOffset);
                    GL.Vertex2(this.Width, this.Height);

                    GL.TexCoord2(1 - endGameState.TextureOffset, 1 - endGameState.TextureOffset);
                    GL.Vertex2(this.Width, 0);
                    GL.End();

                    GL.CopyTexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb,
                                      0, 0, this.Width, this.Height, 0);

                    endGameState.BlurOpacity   -= (0.5 * e.Time);
                    endGameState.TextureOffset += (0.001 * e.Time);
                    endGameState.Rotation      += (1 * e.Time);

                    if (endGameState.BlurOpacity <= 0.0)
                    {
                        gameState = GameState.BlurFinished;
                    }
                } // Blurring
                else if (gameState == GameState.ShowingScoreBoard)
                {
                    var scoreBoardOpacity = (byte)(255 * endGameState.ScoreBoardOpacity);

                    // Score board background
                    GL.Disable(EnableCap.Texture2D);
                    GL.Color4(Color.FromArgb(scoreBoardOpacity, Themes.Blue.Background));
                    GL.Begin(BeginMode.Quads);

                    GL.Vertex2(endGameState.ScoreBoardLeft, endGameState.ScoreBoardTop);
                    GL.Vertex2(endGameState.ScoreBoardLeft, this.Height - endGameState.ScoreBoardTop);
                    GL.Vertex2(this.Width - endGameState.ScoreBoardLeft, this.Height - endGameState.ScoreBoardTop);
                    GL.Vertex2(this.Width - endGameState.ScoreBoardLeft, endGameState.ScoreBoardTop);

                    GL.End();

                    // Score board border
                    GL.Color4(Color.FromArgb(scoreBoardOpacity, Themes.Blue.Border));
                    GL.LineWidth(2);
                    GL.Begin(BeginMode.LineLoop);

                    GL.Vertex2(endGameState.ScoreBoardLeft, endGameState.ScoreBoardTop);
                    GL.Vertex2(endGameState.ScoreBoardLeft, this.Height - endGameState.ScoreBoardTop);
                    GL.Vertex2(this.Width - endGameState.ScoreBoardLeft, this.Height - endGameState.ScoreBoardTop);
                    GL.Vertex2(this.Width - endGameState.ScoreBoardLeft, endGameState.ScoreBoardTop);

                    GL.End();

                    // Player scores
                    for (int playerIndex = 0; playerIndex < Settings.Players; playerIndex++)
                    {
                        var player = players[playerIndex];

                        GL.Enable(EnableCap.Texture2D);
                        GL.BindTexture(TextureTarget.Texture2D, playerTextureIds[playerIndex]);
                        GL.Color4(1, 1, 1, endGameState.PlayerScoreBoardOpacity);

                        GL.Begin(BeginMode.Quads);
                        GL.TexCoord2(0, 0);
                        GL.Vertex2(player.Left, player.Top);

                        GL.TexCoord2(0, 1);
                        GL.Vertex2(player.Left, player.Top + playerSize);

                        GL.TexCoord2(1, 1);
                        GL.Vertex2(player.Left + playerSize, player.Top + playerSize);

                        GL.TexCoord2(1, 0);
                        GL.Vertex2(player.Left + playerSize, player.Top);
                        GL.End();

                        GL.Disable(EnableCap.Texture2D);

                        var scoreString  = string.Format(": {0}", player.Score);
                        var scoreExtents = statusPrinter.Measure(scoreString, scoreFont);

                        GL.PushMatrix();
                        GL.Translate(Math.Floor(player.Left + playerSlotSize),
                                     Math.Floor(player.Top + ((playerSlotSize - scoreExtents.BoundingBox.Height) / 2.0)), 0);

                        statusPrinter.Print(scoreString, scoreFont, Themes.Blue.Foreground);
                        GL.PopMatrix();
                    }
                } // ShowingScoreBoard

                GL.Disable(EnableCap.Texture2D);
            }

            SwapBuffers();
        }
Exemplo n.º 14
0
 /// <summary>
 /// Print a string. GL drawing must be ended before calling this function.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="font"></param>
 /// <param name="color"></param>
 public static void Print(string text, Font font, Color color)
 {
     instance.Begin();
     instance.Print(text, font, color);
     instance.End();
 }
Exemplo n.º 15
0
        private void glControl1_Render(object sender, EventArgs e)
        {
            GLControl senderControl = (sender as GLControl);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Scale(0.005, 0.005, 0.005);

            //if (shaderBinary == null) shaderBinary = new Shaders.DVLB(@"E:\- 3DS OoT Hacking -\romfs\CmbVShader.shbin");

            if (modelFile != null && !modelFile.Disposed && !renderError)
            {
                try
                {
                    modelFile.Render(meshToRender, animFile);
                }
                catch (AglexException aex)
                {
                    MessageBox.Show(aex.ToString());
                    renderError = true;
                }
            }

            if (zsiFile != null && !zsiFile.Disposed && !renderError)
            {
                if (zsiFile.SelectedSetup != null)
                {
                    zsiFile.SelectedSetup.RenderActors();
                }
            }

            if (Properties.Settings.Default.EnableHUD)
            {
                GL.AlphaFunc(AlphaFunction.Always, 0.0f);

                print.Begin(senderControl);
                print.Print(new OpenTK.Vector2d(-16.0, -16.0), hudBackColor, string.Format("F1: {0} ({1}/{2})", hudPage.DescriptionAttr(), (int)(hudPage + 1), Enum.GetValues(typeof(HudPages)).Length));
                print.Print(new OpenTK.Vector2d(-16.0, 16.0), hudBackColor, string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0.00} FPS", senderControl.FPS));

                print.Print(new OpenTK.Vector2d(16.0, -16.0), hudBackColor,
                            string.Format("F5: Textures (<color:{0}>{1}<color:>)\nF6: Vsync (<color:{2}>{3}<color:>)\nF7: Wireframe overlay (<color:{4}>{5}<color:>)\nF8: Lighting (<color:{6}>{7}<color:>)\nF9: Texture alpha (<color:{8}>{9}<color:>)",
                                          (Properties.Settings.Default.EnableTextures ? "AA,205,50" : "255,165,0"), (Properties.Settings.Default.EnableTextures ? "ON" : "OFF"),
                                          (senderControl.VSync ? "AA,205,50" : "255,165,0"), (senderControl.VSync ? "ON" : "OFF"),
                                          (Properties.Settings.Default.AddWireframeOverlay ? "AA,205,50" : "255,165,0"), (Properties.Settings.Default.AddWireframeOverlay ? "ON" : "OFF"),
                                          (Properties.Settings.Default.EnableLighting ? "AA,205,50" : "255,165,0"), (Properties.Settings.Default.EnableLighting ? "ON" : "OFF"),
                                          (!Properties.Settings.Default.DisableAlpha ? "AA,205,50" : "255,165,0"), (!Properties.Settings.Default.DisableAlpha ? "ON" : "OFF")));

                if (renderError)
                {
                    print.Print(new OpenTK.Vector2d(16.0, -128.0), hudBackColor, "<color:255,96,96>-- Model render error! Rendering disabled! --");
                }

                switch (hudPage)
                {
                case HudPages.ModelStats:
                    if (modelFile != null && !modelFile.Disposed)
                    {
                        print.Print(new OpenTK.Vector2d(16.0, 16.0), hudBackColor,
                                    string.Format("Filename: {0}\nModel name: {1}\nBones: {2}, Materials: {3}, Textures: {4}, Primitives: {5}\nVertices: {6}, Normals: {7}, Colors: {8}, Texture coords: {9}",
                                                  Path.GetFileName(modelFile.Filename), modelFile.Root.CmbName,
                                                  modelFile.Root.SklChunk.BoneCount, modelFile.Root.MatsChunk.MaterialCount, modelFile.Root.TexChunk.TextureCount, modelFile.Root.TotalPrimitives,
                                                  modelFile.Root.TotalVertices, modelFile.Root.TotalNormals, modelFile.Root.TotalColors, modelFile.Root.TotalTexCoords));
                    }
                    else
                    {
                        print.Print(new OpenTK.Vector2d(16.0, 16.0), hudBackColor, "No file loaded");
                    }
                    break;

                case HudPages.AnimStats:
                    print.Print(new OpenTK.Vector2d(16.0, 16.0), hudBackColor, "Sorry, almost completely unimplemented!\nNo animations and stuff parsed yet, just some structural data...");
                    break;

                case HudPages.SystemStats:
                    print.Print(new OpenTK.Vector2d(16.0, 16.0), hudBackColor, string.Format("OpenGL version: {0}\nVendor & renderer: {1}, {2}\n\nOpenTK version: {3}\n\nHelper ident: {4}",
                                                                                             Toolkit.VersionString, Toolkit.VendorString, Toolkit.RendererString, Toolkit.OpenTKVersion, Toolkit.GetVersion()));
                    break;
                }

                print.Flush();
            }
        }
Exemplo n.º 16
0
        protected override void OnRenderFrame(OpenTK.FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.LoadIdentity();

            // Draw status text box
            GL.Color3(Themes.Blue.Background);
            GL.Begin(BeginMode.Quads);
            GL.Vertex2(0, 0);
            GL.Vertex2(0, plotBounds.Top);
            GL.Vertex2(this.Width, plotBounds.Top);
            GL.Vertex2(this.Width, 0);
            GL.End();

            GL.LineWidth(2);
            GL.Color3(Themes.Blue.Border);
            GL.Begin(BeginMode.Lines);
            GL.Vertex2(0, plotBounds.Top - 2);
            GL.Vertex2(this.Width, plotBounds.Top - 2);
            GL.End();

            // Draw status text
            GL.PushMatrix();
            GL.Translate(statusTextPoint.X, statusTextPoint.Y, 0);
            printer.Print(statusText, statusFont, Themes.Blue.Foreground,
                          RectangleF.Empty, TextPrinterOptions.NoCache);

            GL.PopMatrix();

            // Draw plot surface
            plotSurface.DrawWithOpenGL(plotBounds);

            // Draw players
            GL.Color3(Themes.Black.Background);
            GL.Begin(BeginMode.Quads);
            GL.Vertex2(0, playerSectionTop);
            GL.Vertex2(0, this.Height);
            GL.Vertex2(this.Width, this.Height);
            GL.Vertex2(this.Width, playerSectionTop);
            GL.End();

            GL.LineWidth(2);
            GL.Color3(Themes.Black.Border);
            GL.Begin(BeginMode.Lines);
            GL.Vertex2(0, playerSectionTop);
            GL.Vertex2(this.Width, playerSectionTop);
            GL.End();

            for (int playerIndex = 0; playerIndex < Settings.Players; playerIndex++)
            {
                // Layout players left to right, top to bottom
                var slotLeft = (playerSlotSize * playerIndex) % this.Width;

                var playerSlotRow = (double)(playerIndex / playersPerSectionRow);
                var slotTop       = playerSectionTop + (playerSlotRow * playerSlotSize);

                // Draw highlighted background if player has answered
                var opacity = (int)(players[playerIndex].HighlightOpacity * 255.0);

                GL.Color4(Color.FromArgb(opacity, Themes.Yellow.Background));
                GL.Begin(BeginMode.Quads);
                GL.Vertex2(slotLeft, slotTop);
                GL.Vertex2(slotLeft, slotTop + playerSlotSize);
                GL.Vertex2(slotLeft + playerSlotSize, slotTop + playerSlotSize);
                GL.Vertex2(slotLeft + playerSlotSize, slotTop);
                GL.End();

                // Center players in their slots
                var playerLeft = slotLeft + ((playerSlotSize - playerSize) / 2.0);
                var playerTop  = slotTop + ((playerSlotSize - playerSize) / 2.0);

                GL.Enable(EnableCap.Texture2D);
                GL.Color3(Color.White);
                GL.BindTexture(TextureTarget.Texture2D, playerTextureIds[playerIndex]);
                GL.Begin(BeginMode.Quads);
                GL.TexCoord2(0, 0);
                GL.Vertex2(playerLeft, playerTop);

                GL.TexCoord2(0, 1);
                GL.Vertex2(playerLeft, playerTop + playerSize);

                GL.TexCoord2(1, 1);
                GL.Vertex2(playerLeft + playerSize, playerTop + playerSize);

                GL.TexCoord2(1, 0);
                GL.Vertex2(playerLeft + playerSize, playerTop);
                GL.End();
                GL.Disable(EnableCap.Texture2D);
            }

            SwapBuffers();
        }
Exemplo n.º 17
0
        protected override void OnRenderFrame(OpenTK.FrameEventArgs e)
        {
            lock (animator)
            {
                animator.Update(e.Time);
            }

            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.LoadIdentity();

            // Draw game description text
            if (!string.IsNullOrEmpty(Settings.GameDescription))
            {
                // Draw box background
                GL.Color3(Themes.Black.Background);
                GL.Begin(BeginMode.Quads);
                GL.Vertex2(0, 0);
                GL.Vertex2(0, boardTop + 1);
                GL.Vertex2(this.Width, boardTop + 1);
                GL.Vertex2(this.Width, 0);
                GL.End();

                // Draw description text
                GL.PushMatrix();
                GL.Translate(descriptionPoint.X, descriptionPoint.Y, 0);
                printer.Print(Settings.GameDescription, descriptionFont, Themes.Black.Foreground);
                GL.PopMatrix();
            }

            // Draw entire board
            for (int pixelIndex = 0; pixelIndex < pixelCount; pixelIndex++)
            {
                var    currentPixel = pixels[pixelIndex];
                double pixelLeft    = boardLeft + (currentPixel.TileLeft * pixelSize);
                double pixelTop     = boardTop + (currentPixel.TileTop * pixelSize);

                // Draw pixel background
                GL.Color3(currentPixel.Red, currentPixel.Green, currentPixel.Blue);

                GL.Disable(EnableCap.Texture2D);
                GL.Begin(BeginMode.Quads);
                GL.Vertex2(pixelLeft, pixelTop);
                GL.Vertex2(pixelLeft, pixelTop + pixelSize);
                GL.Vertex2(pixelLeft + pixelSize, pixelTop + pixelSize);
                GL.Vertex2(pixelLeft + pixelSize, pixelTop);
                GL.End();

                // Don't draw anything else for fixed pixels
                if (currentPixel.State == PixelState.Fixed)
                {
                    continue;
                }

                // Draw player
                GL.Color3(Color.White);
                GL.Enable(EnableCap.Texture2D);
                GL.BindTexture(TextureTarget.Texture2D, playerTextureIds[currentPixel.PlayerId]);
                GL.Begin(BeginMode.Quads);

                GL.TexCoord2(0, 0);
                GL.Vertex2(pixelLeft + textureOffset, pixelTop + textureOffset);

                GL.TexCoord2(0, 1);
                GL.Vertex2(pixelLeft + textureOffset, pixelTop + pixelSize - textureOffset);

                GL.TexCoord2(1, 1);
                GL.Vertex2(pixelLeft + pixelSize - textureOffset,
                           pixelTop + pixelSize - textureOffset);

                GL.TexCoord2(1, 0);
                GL.Vertex2(pixelLeft + pixelSize - textureOffset, pixelTop + textureOffset);

                GL.End();

                // Draw button box
                double buttonLeft = pixelLeft + pixelSize - buttonSize;
                double buttonTop  = pixelTop + pixelSize - buttonSize;

                GL.Disable(EnableCap.Texture2D);
                GL.Color3(buttonTheme.Background);

                GL.Begin(BeginMode.Quads);
                GL.Vertex2(buttonLeft, buttonTop);
                GL.Vertex2(buttonLeft, buttonTop + buttonSize);
                GL.Vertex2(buttonLeft + buttonSize, buttonTop + buttonSize);
                GL.Vertex2(buttonLeft + buttonSize, buttonTop);

                GL.End();

                // Draw box outline
                GL.Color3(buttonTheme.Border);
                GL.LineWidth(1);

                GL.Begin(BeginMode.LineLoop);
                GL.Vertex2(buttonLeft, buttonTop);
                GL.Vertex2(buttonLeft, buttonTop + buttonSize);
                GL.Vertex2(buttonLeft + buttonSize, buttonTop + buttonSize);
                GL.Vertex2(buttonLeft + buttonSize, buttonTop);

                GL.End();

                // Draw button number
                var buttonString = currentPixel.GetButtonString();

                if (!string.IsNullOrEmpty(buttonString))
                {
                    var buttonTextSize = printer.Measure(buttonString, pixelFont)[0];

                    GL.PushMatrix();
                    GL.Translate(buttonLeft + ((buttonSize - buttonTextSize.Width) / 2.0f) - 1.0f,
                                 buttonTop + ((buttonSize - buttonTextSize.Height) / 2.0f) - 1.0f, 0);

                    printer.Print(buttonString, pixelFont, buttonTheme.Foreground);
                    GL.PopMatrix();
                }
            }

            // Draw board lines
            GL.Disable(EnableCap.Texture2D);
            GL.Color3(Color.DarkBlue);
            GL.LineWidth(2);

            for (int tileIndex = 0; tileIndex <= tiles; tileIndex++)
            {
                GL.Begin(BeginMode.Lines);

                // Vertical line
                GL.Vertex2(boardLeft + (tileIndex * pixelSize), boardTop);
                GL.Vertex2(boardLeft + (tileIndex * pixelSize), boardTop + boardSize);

                // Horizontal line
                GL.Vertex2(boardLeft, boardTop + (tileIndex * pixelSize));
                GL.Vertex2(boardLeft + boardSize, boardTop + (tileIndex * pixelSize));

                GL.End();
            }

            SwapBuffers();
        }
Exemplo n.º 18
0
        //static int _width;
        //static int _height;
        //static Point _target;
        //public struct Point {
        //    public static int x;
        //    public static int y;
        //    public int X;
        //    public int Y;
        //}
        static void Main(string[] args)
        {
            while (true)
            {
                string input = ReadLine();
                _consoleHistory.Add(input);
                input = input.ToLower().Trim();

                if (input == "jog")
                {
                    Jogger.Jog(5, 5);
                    System.Threading.Thread.Sleep(1000);
                    Jogger.Bottom();
                    System.Threading.Thread.Sleep(1000);
                    Jogger.CenterHorizontal();
                    System.Threading.Thread.Sleep(1000);
                    Jogger.CenterVertical();
                    System.Threading.Thread.Sleep(1000);
                    Jogger.End();
                    System.Threading.Thread.Sleep(1000);
                    Jogger.Home();
                    System.Threading.Thread.Sleep(1000);
                    Jogger.Top();
                }

                if (input == "strobe")
                {
                    _backgroundEffects.StrobeRandom(count: 30, new Milliseconds(10));
                }

                if (input == "print")
                {
                    _textPrinter = new TextPrinter("Print a thing");
                    _textPrinter.Print();
                    _textPrinter.Type();
                }

                if (input == "cycle")
                {
                    _backgroundEffects.CycleRandom(new Milliseconds(10));
                }
            }

            //_width = Console.WindowWidth;
            //_height = Console.WindowHeight;

            //Console.BackgroundColor = ConsoleColor.Yellow;
            //Console.Clear();
            //SetTarget(new Random().Next(0, _width), new Random().Next(0, _height));
            //while (true)
            //{

            //    string input = Console.ReadLine();
            //    Fire(input);
            //    ////Speak(input);
            //    //int ceilingX = Console.WindowWidth;
            //    //int ceilingY = Console.WindowHeight;
            //    //Point.x = new Random().Next(0, ceilingX);
            //    //Point.y = new Random().Next(0, ceilingY);

            //    //SetCursor();
            //    //Color();
            //    //Stroke(1);


            //    //System.Threading.Thread.Sleep(5);

            //    //    Color();
            //    //    Stroke(1);

            //    //_width = Console.WindowWidth;
            //    //_height = Console.WindowHeight;

            //    //Point.x = Console.CursorLeft;
            //    //Point.y = Console.CursorTop;
            //    ////object character = Console.Read();
            //    ////object key = Console.ReadKey();
            //    //string input = Console.ReadLine().ToLower();
            //    //if (input == "d")
            //    //{
            //    //    Speak($"Width: {_width}");
            //    //    Speak($"Height: {_height}");
            //    //    Speak($"Point: {Point.x}:{Point.y}");
            //    //    //Speak($"key: { key }");
            //    //    //Speak($"character: { character }");
            //    //}
            //    ////NOTE: sample input color x y
            //    //if (input.StartsWith("color"))
            //    //{
            //    //    SetCursor(int.Parse(input.Split(' ')[1]), int.Parse(input.Split(' ')[2]));
            //    //    Color();
            //    //    Stroke(1);
            //    //}
            //}
        }