Beispiel #1
0
        public void Draw()
        {
            String pMsg = this.msg;

            float xTmp = this.xStart;
            float yTmp = this.yStart;

            float xEnd = this.xStart;

            for (int i = 0; i < pMsg.Length; i++)
            {
                int key = Convert.ToByte(pMsg[i]);

                Glyph pGlyph = GlyphMan.Find(key);
                Debug.Assert(pGlyph != null);

                xTmp = xEnd + pGlyph.width / 2;

                Azul.Sprite pAzulSprite = new Azul.Sprite(pGlyph.pFont,
                                                          new Azul.Rect(pGlyph.x, pGlyph.y, pGlyph.width, pGlyph.height),
                                                          new Azul.Rect(xTmp, yTmp, pGlyph.width, pGlyph.height),
                                                          new Azul.Color(1.0f, 1.0f, 1.0f));

                pAzulSprite.Update();
                pAzulSprite.Render();

                // move the starting to the next character
                xEnd = pGlyph.width / 2 + xTmp;
            }
        }
Beispiel #2
0
        private static GlyphMan privGetInstance()
        {
            if (pInstance == null)
            {
                pInstance = new GlyphMan();
            }

            // Safety - this forces users to call Create() first before using class
            Debug.Assert(pInstance != null);

            return(pInstance);
        }
Beispiel #3
0
        private GameManager()
        {
            destroyList = new List <GameObject>();
            gameObjList = new List <GameObject>();

            mainMenuSprite = new Azul.Sprite(loadScreenText, new Azul.Rect(0, 0, 800, 480), new Azul.Rect(400, 250, 800, 500));

            state = GAME_STATE.LOADSCREEN;

            //fontText20 = new Azul.Texture("Consolas20pt.tga");
            //GlyphMan.AddXml("Consolas20pt.xml", fontText20);
            fontText20 = new Azul.Texture("Arial20pt.tga");
            GlyphMan.AddXml("Arial20pt.xml", fontText20);

            GameOverText = new SpriteFont("", 0, 0);

            pLobby = new Lobby();
        }
Beispiel #4
0
        public static Glyph Find(int key)
        {
            GlyphMan pMan = GlyphMan.privGetInstance();

            Glyph pNode = pMan.pHead;

            while (pNode != null)
            {
                if (pNode.key == key)
                {
                    // found it
                    break;
                }

                pNode = pNode.pNext;
            }

            return(pNode);
        }
Beispiel #5
0
        public static void AddXml2(String assetName, Azul.Texture pFont)
        {
            // Singleton
            GlyphMan pMan = GlyphMan.privGetInstance();

            System.Xml.XmlTextReader reader = new XmlTextReader(assetName);

            int key    = -1;
            int x      = -1;
            int y      = -1;
            int width  = -1;
            int height = -1;

            // I'm sure there is a better way to do this... but this works for now
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:     // The node is an element.
                    if (reader.GetAttribute("key") != null)
                    {
                        key = Convert.ToInt32(reader.GetAttribute("key"));
                    }
                    else if (reader.Name == "x")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                x = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "y")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                y = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "width")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                width = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "height")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                height = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    break;

                case XmlNodeType.EndElement:     //Display the end of the element
                    if (reader.Name == "character")
                    {
                        // have all the data... so now create a glyph
                        //  Debug.WriteLine("key:{0} x:{1} y:{2} w:{3} h:{4}", key, x, y, width, height);
                        pMan.Add(pFont, key, x, y, width, height);
                    }
                    break;
                }
            }
        }