示例#1
0
        private void NewMapTexture(int screenw, int screenh)
        {
            Textures["mapRender"] = WorldMap.GetMapImage();
            Effect.Texture        = Textures["mapRender"];

            float testScale = 64f / (screenh);

            //defaultScale = testScale;
            defaultScale = 0.08f;

            var map = Textures["mapRender"];
            //var mapx = (map.Width > screenw) ? Textures["mapRender"].Width / screenw : 1;
            //var mapy = (map.Height > screenh) ? Textures["mapRender"].Height / screenh : 1;
            var mapx = Textures["mapRender"].Width / (float)screenw;
            var mapy = Textures["mapRender"].Height / (float)screenh;

            MapAspect = new Vector2(mapx / mapy, mapy / mapx);

            var loc = this.WorldMap.WorldMapLocationToVector2(this.WorldMap.Player.Location);

            namedQuads["map"] = new PositionedQuad(aspect * mapx, 1f * mapy)
            {
                Texture  = Textures["mapRender"],
                Position = new Vector2(0, 0),
                Show     = true
            };
            Camera = new Vector3(loc.X, loc.Y - 0.2f, Camera.Z);
            Target = new Vector3(loc.X, loc.Y, -1000);

            WorldMap.MapChanged = false;
        }
示例#2
0
        internal PositionedQuad Write(string text, int screenx, int screeny, Vector3 rotation, float scale = 1)
        {
            Texture2D tex        = Textures["bmpFont"];
            int       columns    = 8;
            int       pixelwidth = 64;

            Color[] data = new Color[tex.Width * tex.Height];
            //useless padding.
            Color[] letters = new Color[(64 * text.Length) * 64];
            tex.GetData <Color>(data);
            int letterindex = 0;

            foreach (char letter in text.ToLower())
            {
                int gid = 0;
                if (Char.IsNumber(letter))
                {
                    gid = 31 + (int)Char.GetNumericValue(letter);
                }
                else if (letter >= 'a')
                {
                    gid = letter - 'a';
                }
                else if (letter.Equals(' '))
                {
                    gid = 63;
                }
                else
                { //period
                    gid = 30;
                }

                //int xmod = (gid % columns) * pixelwidth;
                //int ymod = (int)(Math.Floor((float)gid / columns)) * (tex.Width);
                for (int y = 0; y < 64; y++)
                {
                    for (int x = 0; x < pixelwidth; x++)
                    {
                        //int dataindex = x + xmod + ((int)y * ymod);
                        //int dataindex = x + xmod + (y * tex.Width) + (ymod * 64);
                        int dataindex          = x + (gid % columns) * pixelwidth + (y * tex.Width) + ((int)(Math.Floor((float)gid / columns)) * (tex.Width) * 64);
                        int stringTextureIndex = (y * (64 * text.Length)) + (64 * letterindex) + x;
                        letters[stringTextureIndex] = data[dataindex];
                    }
                }
                letterindex++;
            }

            Texture2D texture = new Texture2D(GraphicsDevice, 64 * text.Length, 64);

            texture.SetData <Color>(letters);

            PositionedQuad pq = new PositionedQuad(scale, scale / text.Length)
            {
                Texture  = texture,
                Position = PixelPositionToVector2(screenx, screeny)
            };

            return(pq);
            //this.positionedQuads.Add(pq);
        }