Example #1
0
        PieceQuad ParseBlockLine(int width, List <string> bits)
        {
            var c = new PieceQuad();

            c.Init(null, Tools.BasicEffect);

            bool IsTile = Tools.BitsHasBit(bits, "tile");

            if (IsTile)
            {
                c.Data.RepeatWidth  = 2000;
                c.Data.RepeatHeight = 2000;
                c.Data.UV_Multiples = new Vector2(0, 0);
                c.Center.U_Wrap     = c.Center.V_Wrap = true;
            }
            else
            {
                c.Data.RepeatWidth  = 2000;
                c.Data.RepeatHeight = 2000;
                c.Data.UV_Multiples = new Vector2(1, 0);
                c.Center.U_Wrap     = c.Center.V_Wrap = false;

                c.FixedHeight = 0; // Flag to tell ParseExtra to set the height properly
            }

            ParseExtraBlockInfo(c, width, bits);

            return(c);
        }
Example #2
0
        public void Add(int width, PieceQuad piece)
        {
            if (!Dict.ContainsKey(width))
            {
                Dict.Add(width, new List <PieceQuad>());
            }

            Dict[width].Add(piece);
        }
Example #3
0
        void ParseExtraBlockInfo(PieceQuad c, int width, List <string> bits)
        {
            c.Center.SetTextureOrAnim(bits[1]);
            //c.Center.TextureName = bits[1];

            //int tex_width = c.Center.MyTexture.Width;
            //int tex_height = c.Center.MyTexture.Height;
            int tex_width  = c.Center.TexWidth;
            int tex_height = c.Center.TexHeight;

            for (int i = 2; i < bits.Count; i++)
            {
                switch (bits[i])
                {
                case "upside_down": c.Data.UpsideDown = true; break;

                case "mirror": c.Data.Mirror = true; break;

                case "box_height": c.BoxHeight = 2 * float.Parse(bits[i + 1]); break;

                case "width": c.Data.RepeatWidth = 2 * float.Parse(bits[i + 1]); break;

                case "height": c.Data.RepeatHeight = 2 * float.Parse(bits[i + 1]); break;

                case "left": c.Data.Center_BL_Shift.X = float.Parse(bits[i + 1]); break;

                case "right": c.Data.Center_TR_Shift.X = float.Parse(bits[i + 1]); break;

                case "top":
                    var shift = float.Parse(bits[i + 1]);
                    c.Data.Center_TR_Shift.Y = shift;
                    c.Data.Center_BL_Shift.Y = shift;
                    break;
                }
            }

            // Extend the quad down to properly scale quad
            if (c.FixedHeight == 0)
            {
                float sprite_width = 2 * width + c.Data.Center_TR_Shift.X - c.Data.Center_BL_Shift.X;
                c.FixedHeight = sprite_width * (float)tex_height / (float)tex_width;
            }
        }
Example #4
0
 public void Add(PieceQuad piece)
 {
     Add(piece.Pillar_Width, piece);
 }