예제 #1
0
        public ImageSource GetColset()
        {
            int         pixelcount = Meth.Up(this.Parent.TileCollisionResolution.X * this.Parent.TileCollisionResolution.Y / 4.0);
            ImageSource @out       = new ImageSource(this.TileCount.X * pixelcount, this.TileCount.Y);

            for (int x = 0; x < this.TileCount.X; x++)
            {
                for (int y = 0; y < this.TileCount.Y; y++)
                {
                    Bunch <byte> bs = new Bunch <byte>();
                    for (int ty = 0; ty < this.Parent.TileCollisionResolution.Y; ty++)
                    {
                        for (int tx = 0; tx < this.Parent.TileCollisionResolution.X; tx++)
                        {
                            bs.Add(this.Colset[x, y][tx, ty]);
                        }
                    }
                    Bunch <Color> ps = new Bunch <Color>();
                    while (bs.Count > 0)
                    {
                        while (bs.Count < 4)
                        {
                            bs.Add(0);
                        }
                        ps.Add(new Color(bs.SubBunch(0, 4)));
                        bs = bs.SubBunch(4);
                    }
                    for (int i = 0; i < pixelcount; i++)
                    {
                        @out[x * pixelcount + i, y] = ps[i];
                    }
                }
            }
            return(@out);
        }
예제 #2
0
        public Areaset(MekaItem _file, Point _tilesize, Point _tilecollisionresolution)
        {
            if (_file["Info"]["Tilesize"].To <Point>() != _tilesize || _file["Info"]["Colsize"].To <Point>() != _tilecollisionresolution)
            {
                throw new Exception("Tilesize and/or Colsize don't match up with this game's.");
            }

            ImageSource tileset = GameBase.LoadImageSource(_file["Tileset"].Data);

            ImageSource[,] tiles = tileset.Split(tileset.Size / _tilesize);
            ImageSource colset = GameBase.LoadImageSource(_file["Colset"].Data);

            int pixelcount = Meth.Up(_tilecollisionresolution.X * _tilecollisionresolution.Y / 4.0);

            this.Size = new Point(tiles.GetLength(0), tiles.GetLength(1));

            for (int y = 0; y < this.Size.Y; y++)
            {
                for (int x = 0; x < this.Size.X; x++)
                {
                    this.Tiles.Add(tiles[x, y]);

                    Bunch <Color> cs = new Bunch <Color>();
                    for (int i = 0; i < pixelcount; i++)
                    {
                        cs.Add(colset[x * pixelcount + i, y]);
                    }

                    Bunch <byte> bs = new Bunch <byte>();
                    foreach (Color c in cs)
                    {
                        bs.Add(c.Bytes);
                    }

                    bs           = bs.SubBunch(0, _tilecollisionresolution.X * _tilecollisionresolution.Y);
                    bool[,] cols = new bool[_tilecollisionresolution.X, _tilecollisionresolution.Y];
                    for (int i = 0; i < bs.Count; i++)
                    {
                        cols[i % _tilecollisionresolution.X, Meth.Down(i / _tilecollisionresolution.X)] = bs[i] == 1;
                    }
                    this.Cols.Add(cols);
                }
            }
        }
예제 #3
0
        public override void OnInitialization()
        {
            this.Children.Add(this.EntityEditor);

            Dictionary <string, Bunch <EntityTile> > groups = new Dictionary <string, Bunch <EntityTile> >();

            foreach (EntityType t in this.Entities.Where(item => item.Name != "Decoration"))
            {
                if (!groups.ContainsKey(t.Group))
                {
                    groups[t.Group] = new Bunch <EntityTile>();
                }
                groups[t.Group].Add(new EntityTileNormal(t)
                {
                    Types = this.Entities
                });
            }

            foreach (Areaset a in this.Parent.Areasets.Select(item => item.Value).Where(item => item.Decorations.Count > 0))
            {
                groups["Decoration " + a.Name] = new Bunch <EntityTile>();
                foreach (KeyValuePair <string, ImageSource> decoration in a.Decorations)
                {
                    groups["Decoration " + a.Name].Add(new EntityTileDecoration(a, decoration.Key)
                    {
                        Types = this.Entities
                    });
                }
            }

            foreach (KeyValuePair <string, Bunch <EntityTile> > g in groups.OrderBy(item => item.Key.GetAlphabetIndex()))
            {
                int           height = Meth.Up(g.Value.Count / (double)this.Size.X);
                CollapseGroup c      = new CollapseGroup(FontBase.Consolas, g.Key, new EntityGroup(g.Value, this.Editor.TileEditor, this.EntityEditor, new Point(this.Size.X, height)))
                {
                    InnerHeight = height * this.Parent.TileSize.Y * 2, Width = this.Size.X * this.Parent.TileSize.X * 2
                };
                this.Groups.Add(c);
                this.Children.Add(c);
            }
        }
예제 #4
0
        public override void Update()
        {
            base.Update();

            this._Sides[0].Y = -75 - Meth.Up((this._Middle.Rotation / Meth.Tau * 10 * 30 + 5) % 30 - 5);
            this._Sides[1].Y = -75 + Meth.Up((this._Middle.Rotation / Meth.Tau * 10 * 30 + 25) % 30 - 25);

            DateTime start = DateTime.Now;

            while ((DateTime.Now - start).TotalMilliseconds < 3 && this._Loadables.Count > 0)
            {
                if (this._Loadables[0].FinishedLoading)
                {
                    this._Loadables.RemoveAt(0);
                    if (this._Loadables.Count == 0)
                    {
                        this._DoneLoading = true;
                        this.Skippable    = true;
                    }
                }
                else
                {
                    this._Loadables[0].LoadStep();
                }
            }

            if (this.Runtime % 110 == 0 && this._DoneLoading)
            {
                this._Done        = true;
                this._Middle.Done = true;
                this.Skippable    = true;
            }

            if (this._Done && this._DoneProgress0 < 100)
            {
                this._DoneProgress0++;

                this._Cutoffs[0].Position.Y += 1;
                this._Cutoffs[1].Position.Y -= 0.5;

                this.Position = this.Parent.Resolution / 2 - (Point)(new Vector(220, 70) * Meth.Smooth(this._DoneProgress0 / 100.0) * this.Scale);
            }

            if (this._Done && this._DoneProgress0 >= 50 && this._DoneProgress1 < 80)
            {
                this._DoneProgress1++;

                for (int i = 0; i < 6; i++)
                {
                    this._Letters[i].TextColor = Color.White * Meth.Limit(0, Meth.Smooth(this._DoneProgress1 / 80.0) * 6 - i, 1);
                }
            }

            if (this._DoneProgress1 >= 80 && this._DoneProgress1 < 120)
            {
                this._DoneProgress1++;
            }

            if (this._DoneProgress1 == 120)
            {
                this._DoneProgress2++;
                this.Color = Color.White * Meth.Smooth(1 - this._DoneProgress2 * 3 / 255.0);
                if (this._DoneProgress2 == 85)
                {
                    this.Kill();
                }
            }
        }
예제 #5
0
        public static VertexArray DrawMultiple(Vector[] _points, double _thickness, FrameCurve _curve, FrameCurve _r, FrameCurve _g, FrameCurve _b)
        {
            Bunch <Vector>[] npoints = new Bunch <Vector>[] { new Bunch <Vector>(), new Bunch <Vector>() };

            for (int i = 0; i < _points.Length - 1; i++)
            {
                double a = (_points[i + 1] - _points[i]).Angle;
                for (int x = 0; x < 2; x++)
                {
                    for (int y = 0; y < 2; y++)
                    {
                        npoints[y].Add(_points[i + x] + Vector.FromAngle(a + Meth.Tau / 4 + Meth.Tau / 2 * y, _curve.GetValue((i + x) / (double)(_points.Length - 1)) / 2 * _thickness));
                    }
                }
            }

            //VertexArray v = new VertexArray(VertexArrayType.Quads);
            //for (int i = 0; i < npoints[0].LastIndex; i++)
            //{
            //	Color c1 = GetColor(i / (double)npoints[0].LastIndex, _r, _g, _b);
            //	Color c2 = GetColor((i + 1) / (double)npoints[0].LastIndex, _r, _g, _b);

            //	v.Add(npoints[0][i], c1);
            //	v.Add(npoints[1][i], c1);
            //	v.Add(npoints[1][i + 1], c2);
            //	v.Add(npoints[0][i + 1], c2);
            //}

            VertexArray v = new VertexArray(VertexArrayType.Triangles)
            {
                Color = Color.Black
            };

            for (int i = 0; i < npoints[0].LastIndex; i++)
            {
                Color c1 = GetColor(i / (double)npoints[0].LastIndex, _r, _g, _b);
                Color c2 = GetColor((i + 1) / (double)npoints[0].LastIndex, _r, _g, _b);

                v.Add(npoints[0][i], c1);
                v.Add(npoints[1][i], c1);
                v.Add(npoints[1][i + 1], c2);

                v.Add(npoints[1][i + 1], c2);
                v.Add(npoints[0][i + 1], c2);
                v.Add(npoints[0][i], c1);
            }

            if (_points.Length > 1)
            {
                for (int n = 0; n < 2; n++)
                {
                    Vector p = _points[n * (_points.Length - 1)];
                    int    q = Meth.Up(_points.Length / 2.0);

                    Color  c = GetColor(n, _r, _g, _b);
                    double t = _thickness * _curve.GetValue(n) / 2;

                    double a = ((n == 0) ? (_points[0] - _points[1]).Angle : (_points[_points.Length - 1] - _points[_points.Length - 2]).Angle) - Meth.Tau / 4;

                    for (int i = 0; i < q; i++)
                    {
                        v.Add(p, c);
                        v.Add(p + Vector.FromAngle(a + i / (double)q * Meth.Tau / 2, t), c);
                        v.Add(p + Vector.FromAngle(a + (i + 1) / (double)q * Meth.Tau / 2, t), c);
                    }
                }
            }

            return(v);
        }