Esempio n. 1
0
            public Sky(bool dayTime)
                : base(0, 0, 1, 1)
            {
                _texture = new Gradient(dayTime ? Day : Night);

                var vertices = new float[16];

                _verticesBuffer = Quad.Create();

                vertices[2]  = 0.25f;
                vertices[6]  = 0.25f;
                vertices[10] = 0.75f;
                vertices[14] = 0.75f;

                vertices[3]  = 0;
                vertices[7]  = 1;
                vertices[11] = 1;
                vertices[15] = 0;


                vertices[0] = 0;
                vertices[1] = 0;

                vertices[4] = 1;
                vertices[5] = 0;

                vertices[8] = 1;
                vertices[9] = 1;

                vertices[12] = 0;
                vertices[13] = 1;

                _verticesBuffer.Position(0);
                _verticesBuffer.Put(vertices);
            }
Esempio n. 2
0
        public Font(SmartTexture tx, int width, int height, string chars)
            : base(tx)
        {
            Texture = tx;

            AutoUppercase = chars.Equals(LatinUpper);

            var length = chars.Length;

            var uw = (float)width / tx.Width;
            var vh = (float)height / tx.Height;

            var left   = 0;
            var top    = 0;
            var bottom = vh;

            for (var i = 0; i < length; i++)
            {
                left += (int)uw;
                var rect = new RectF(left, top, left, bottom);
                Add(chars[i], rect);

                if (left < 1)
                {
                    continue;
                }

                left    = 0;
                top     = (int)bottom;
                bottom += vh;
            }

            LineHeight = BaseLine = height;
        }
Esempio n. 3
0
        public WndHero()
        {
            icons = TextureCache.Get(Assets.BUFFS_LARGE);
            film  = new TextureFilm(icons, 16, 16);

            stats = new StatsTab(this);
            Add(stats);

            buffs = new BuffsTab(this);
            Add(buffs);

            var statsTab = new LabeledTab(this, TXT_STATS);

            statsTab.SelectAction = StatsSelect;
            Add(statsTab);

            var buffsTab = new LabeledTab(this, TXT_BUFFS);

            buffsTab.SelectAction = BuffsSelect;
            Add(buffsTab);

            foreach (var tab in Tabs)
            {
                tab.SetSize(TAB_WIDTH, TabHeight());
            }

            Resize(WIDTH, (int)Math.Max(stats.Height(), buffs.Height()));

            Select(0);
        }
Esempio n. 4
0
        public virtual void Copy(Image other)
        {
            texture = other.texture;
            frame   = new RectF(other.frame);

            _Width  = other.Width;
            _Height = other.Height;

            UpdateFrame();
            updateVertices();
        }
Esempio n. 5
0
        public Flare(int nRays, float radius)
            : base(0, 0, 0, 0)
        {
            // FIXME
            // Texture is incorrectly created every time we need
            // to show the effect, it must be refactored

            var gradient = new[] {
                Android.Graphics.Color.Argb(0xFF, 0xFF, 0xFF, 0xFF),
                Android.Graphics.Color.Argb(0x00, 0xFF, 0xFF, 0xFF)
            };

            _texture = new Gradient(gradient);

            _nRays = nRays;

            Angle        = 45;
            AngularSpeed = 180;

            _vertices = ByteBuffer.AllocateDirect((nRays * 2 + 1) * 4 * (sizeof(float))).Order(ByteOrder.NativeOrder()).AsFloatBuffer();

            _indices = ByteBuffer.AllocateDirect(nRays * 3 * sizeof(short)).Order(ByteOrder.NativeOrder()).AsShortBuffer();

            var v = new float[4];

            v[0] = 0;
            v[1] = 0;
            v[2] = 0.25f;
            v[3] = 0;
            _vertices.Put(v);

            v[2] = 0.75f;
            v[3] = 0;

            for (var i = 0; i < nRays; i++)
            {
                var a = i * 3.1415926f * 2 / nRays;
                v[0] = FloatMath.Cos(a) * radius;
                v[1] = FloatMath.Sin(a) * radius;
                _vertices.Put(v);

                a   += 3.1415926f * 2 / nRays / 2;
                v[0] = FloatMath.Cos(a) * radius;
                v[1] = FloatMath.Sin(a) * radius;
                _vertices.Put(v);

                _indices.Put(0);
                _indices.Put((short)(1 + i * 2));
                _indices.Put((short)(2 + i * 2));
            }

            _indices.Position(0);
        }
Esempio n. 6
0
        public Tilemap(object tx, TextureFilm tileset)
            : base(0, 0, 0, 0)
        {
            texture      = TextureCache.Get(tx);
            this.tileset = tileset;

            var r = tileset.Get(0);

            _cellW = tileset.Width(r);
            _cellH = tileset.Height(r);

            vertices = new float[16];

            updated = new Rect();
        }
Esempio n. 7
0
        public NinePatch(object tx, int x, int y, int w, int h, int Left, int Top, int Right, int Bottom)
            : base(0, 0, 0, 0)
        {
            texture = TextureCache.Get(tx);
            w       = w == 0 ? texture.Width : w;
            h       = h == 0 ? texture.Height : h;

            nWidth  = _Width = w;
            nHeight = _Height = h;

            vertices       = new float[16];
            verticesBuffer = Quad.CreateSet(9);

            marginLeft   = Left;
            marginRight  = Right;
            marginTop    = Top;
            marginBottom = Bottom;

            outterF = texture.UvRect(x, y, x + w, y + h);
            innerF  = texture.UvRect(x + Left, y + Top, x + w - Right, y + h - Bottom);

            UpdateVertices();
        }
Esempio n. 8
0
 public virtual void Texture(object tx)
 {
     texture = tx is SmartTexture ? (SmartTexture)tx : TextureCache.Get(tx);
     Frame(new RectF(0, 0, 1, 1));
 }
Esempio n. 9
0
 public TextureFilm(SmartTexture texture, int Width)
     : this(texture, Width, texture.Height)
 {
 }
Esempio n. 10
0
 protected override void CreateChildren()
 {
     texture = TextureCache.Get(Assets.BUFFS_SMALL);
     film    = new TextureFilm(texture, SIZE, SIZE);
 }
Esempio n. 11
0
 public Font(SmartTexture tx, int width, string chars)
     : this(tx, width, tx.Height, chars)
 {
 }
Esempio n. 12
0
 protected internal Font(SmartTexture tx)
     : base(tx)
 {
     Texture = tx;
 }