Beispiel #1
0
        private void InitStuff()
        {
            Atlases = new List <Atlas>();
            Atlases.Add(Atlas.FromAtlas("Atlases\\testboxes", Atlas.AtlasDataFormat.CrunchXmlOrBinary));

            _spriteBank = new SpriteBank(Atlases[0], "spriteData\\Sprites.xml");
        }
Beispiel #2
0
            public static void DumpAll()
            {
                bool prevDumpOnLoad = DumpOnLoad;

                DumpOnLoad = true;
                // TODO: Load and dump all other assets in original Content directory.

                // Dump atlases.

                // Noel on Discord:
                // not using it for the celeste assets but the "crunch" atlas packer is open source: https://github.com/ChevyRay/crunch
                // all celeste graphic assets use the Packer or PackerNoAtlas one tho

                // TODO: Find how to differentiate between Packer and PackerNoAtlas
                foreach (string file in Directory.EnumerateFiles(Path.Combine(PathContentOrig, "Graphics", "Atlases"), "*.meta", SearchOption.AllDirectories))
                {
                    Logger.Log("dump-all-atlas-meta", "file: " + file);
                    // THIS IS HORRIBLE.
                    try {
                        Atlas.FromAtlas(file.Substring(0, file.Length - 5), Atlas.AtlasDataFormat.Packer).Dispose();
                    } catch {
                        Atlas.FromAtlas(file.Substring(0, file.Length - 5), Atlas.AtlasDataFormat.PackerNoAtlas).Dispose();
                    }
                }

                DumpOnLoad = prevDumpOnLoad;
            }
        private void Initialize()
        {
            Atlases = new List <Atlas>();
            Atlases.Add(Atlas.FromAtlas("Atlases\\atlas", Atlas.AtlasDataFormat.CrunchXmlOrBinary));

            _SpriteBank = new SpriteBank(Atlases[0], "SpriteData\\Sprites.xml");
        }
        void Start()
        {
            Debug.Log("==读取GamePlay的Texture");
            Gfx.Game        = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
            foregroundTiles = new Tiles(Path.Combine(Util.GAME_PATH_CONTENT, Path.Combine("Graphics", "ForegroundTiles.xml")));
            backgroundTiles = new Tiles(Path.Combine(Util.GAME_PATH_CONTENT, Path.Combine("Graphics", "BackgroundTiles.xml")));
            AreaData.Load();
            Stage stage = new Stage(0, AreaMode.Normal);

            stage.Load();

            //生成地图数据
            Autotiler.Behaviour fgBehaviour = new Autotiler.Behaviour()
            {
                EdgesExtend             = true,
                EdgesIgnoreOutOfLevel   = false,
                PaddingIgnoreOutOfLevel = true
            };
            Autotiler.Behaviour bgBehaviour = new Autotiler.Behaviour()
            {
                EdgesExtend             = true,
                EdgesIgnoreOutOfLevel   = false,
                PaddingIgnoreOutOfLevel = false
            };
            VirtualMap <char> foregroundData = stage.ForegroundData;

            this.colliderGrid = new ColliderGrid(foregroundData.Columns, foregroundData.Rows, 8f, 8f);
            for (int x = 0; x < foregroundData.Columns; x += 50)
            {
                for (int y = 0; y < foregroundData.Rows; y += 50)
                {
                    if (foregroundData.AnyInSegmentAtTile(x, y))
                    {
                        int index1 = x;
                        for (int index2 = Math.Min(index1 + 50, foregroundData.Columns); index1 < index2; ++index1)
                        {
                            int index3 = y;
                            for (int index4 = Math.Min(index3 + 50, foregroundData.Rows); index3 < index4; ++index3)
                            {
                                if (foregroundData[index1, index3] != '0')
                                {
                                    this.colliderGrid[index1, index3] = true;
                                }
                                else
                                {
                                    this.colliderGrid[index1, index3] = false;
                                }
                            }
                        }
                    }
                }
            }
            //VirtualMap<char> backgroundData = stage.BackgroundData;
            foregroundTiles.GenerateTiles(this.fgTilemap, foregroundData, 0, 0, foregroundData.Columns, foregroundData.Rows, false, '0', fgBehaviour, colliderGrid);
            //bgTileDictionary.GenerateTiles(this.bgTilemap, backgroundData, 0, 0, backgroundData.Columns, backgroundData.Rows, false, '0', bgBehaviour);
        }
Beispiel #5
0
        private static void _extract(string type)
        {
            Console.WriteLine("Start to extract {0}", type);
            AtlasInfo info  = _components[type];
            Atlas     atlas = Atlas.FromAtlas(info.Path, info.Format);

            foreach (VirtualTexture texture in atlas.Sources)
            {
                Console.WriteLine("Writing {0} to specified output directory...", Path.GetFileName(texture.Path));
                texture.SaveAsPng(Path.Combine(_output_dir, texture.Path) + ".png");
            }
        }
Beispiel #6
0
        private void LoadCompleteThread()
        {
            AreaData area = AreaData.Get(session);

            if ((completeMeta = area.GetMeta()?.CompleteScreen) != null && completeMeta.Atlas != null)
            {
                completeAtlas = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", completeMeta.Atlas), Atlas.AtlasDataFormat.PackerNoAtlas);
            }
            else if ((completeXml = area.CompleteScreenXml) != null && completeXml.HasAttr("atlas"))
            {
                completeAtlas = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", completeXml.Attr("atlas")), Atlas.AtlasDataFormat.PackerNoAtlas);
            }

            completeLoaded = true;
        }
        private void LoadCompleteThread()
        {
            Atlas atlas = null;

            if (meta != null)
            {
                atlas = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", meta.Atlas), Atlas.AtlasDataFormat.PackerNoAtlas);
            }
            else
            {
                atlas = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", xml.Attr("atlas")), Atlas.AtlasDataFormat.PackerNoAtlas);
            }

            renderer = new patch_CompleteRenderer(xml, atlas, 0f, () => slideFinished = true, meta);
            renderer.SlideDuration = 7.5f;

            ready = true;
        }
Beispiel #8
0
        public void Start()
        {
            //读取GamePlay的MTexture文件
            Debug.Log("==读取GamePlay的Texture");
            Gfx.Game        = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
            Gfx.BGAutotiler = new Autotiler(Path.Combine("Graphics", "BackgroundTiles.xml"));
            Gfx.FGAutotiler = new Autotiler(Path.Combine("Graphics", "ForegroundTiles.xml"));

            //Gfx.SceneryTiles = new Tileset(Gfx.Game["tilesets/scenery"], 8, 8);
            //Gfx.AnimatedTilesBank = new AnimatedTilesBank();
            //foreach (XmlElement xml in (XmlNode)XmlUtils.LoadContentXML(Path.Combine("Graphics", "AnimatedTiles.xml"))["Data"])
            //{
            //    if (xml != null)
            //        Gfx.AnimatedTilesBank.Add(xml.Attr("name"), xml.AttrFloat("delay", 0.0f), xml.AttrVector2("posX", "posY", Vector2.zero), xml.AttrVector2("origX", "origY", Vector2.zero), Gfx.Game.GetAtlasSubtextures(xml.Attr("path")));
            //}
            Debug.Log("==加载AreaData文件");
            SaveData.Start(new SaveData
            {
                Name        = "test001",
                AssistMode  = true,
                VariantMode = true
            }, 0);
            //加载区域
            AreaData.Load();

            Debug.Log("==创建Session,读取关卡地图");
            Session session = new Session(new AreaKey(0, AreaMode.Normal), null, null);
            bool    flag    = level != null && session.MapData.Get(level) != null;

            if (flag)
            {
                session.Level      = level;
                session.FirstLevel = false;
            }

            Debug.Log("==加载关卡LevelLoad");
            LevelLoader loader = new LevelLoader(session, null);

            //StartCoroutine(DrawTiles(loader.Level.BgTiles.Tiles));
            StartCoroutine(DrawTiles(loader.solidTiles.Tiles));
        }
Beispiel #9
0
        /// <summary>
        /// Unpacks any texture atlases that needs to be loaded.
        /// </summary>
        public static void UnpackAtlases()
        {
            GFX.Gameplay = Atlas.FromAtlas(Path.Combine(Settings.CelesteDirectory, "Content", "Graphics", "Atlases", "Gameplay"), AtlasFormat.Packer);
            GFX.Empty    = new DrawableTexture(GFX.Gameplay.Sources[0], 4094, 4094, 1, 1);
            GFX.Pixel    = new DrawableTexture(GFX.Gameplay.Sources[0], 13, 13, 1, 1);
            GFX.Scenery  = new Tileset(GFX.Gameplay["tilesets/scenery"], 8, 8);

            // PICO-8 font loading
            DrawableTexture font = GFX.Gameplay["pico8/font"];

            GFX.Font = new DrawableTexture[font.Width / 4 * (font.Height / 6)];
            for (int i = 0; i < font.Height / 6; i++)
            {
                for (int j = 0; j < font.Width / 4; j++)
                {
                    GFX.Font[j + i * (font.Width / 4)] = new DrawableTexture(font, j * 4, i * 6, 4, 6);
                }
            }

            Finished = true;
        }
Beispiel #10
0
 public void Awake()
 {
     Debug.Log("Game Awake");
     instance = this;
     Gfx.Game = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
 }
Beispiel #11
0
 void Awake()
 {
     Gfx.Game = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
 }
Beispiel #12
0
 private void Initialize()
 {
     Atlases = new List <Atlas>();
     Atlases.Add(Atlas.FromAtlas("Sprites/Spritesheets/spritesheet_0", Atlas.AtlasDataFormat.CrunchXmlOrBinary));
     spriteBank = new SpriteBank(Atlases[0], "Sprites/sprite_data_0.xml");
 }
Beispiel #13
0
    void Start()
    {
        //读取配置文件
        Gfx.Game = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
        Gfx.Misc = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Misc"), Atlas.AtlasDataFormat.PackerNoAtlas);

        Gfx.SceneryTiles = new Tileset(Gfx.Game["tilesets/scenery"], 8, 8);
        //读取前景配置文件
        Gfx.BGAutotiler = new Autotiler(Path.Combine("Graphics", "BackgroundTiles.xml"));
        Gfx.FGAutotiler = new Autotiler(Path.Combine("Graphics", "ForegroundTiles.xml"));

        Debug.Log("==加载AreaData文件");
        SaveData.Start(new SaveData
        {
            Name        = "test001",
            AssistMode  = true,
            VariantMode = true
        }, 0);
        //加载区域
        AreaData.Load();

        Debug.Log("==创建Session,读取关卡地图");

        Session session = new Session(new AreaKey(0, AreaMode.Normal), null, null);

        MapData   mapData   = session.MapData;
        LevelData levelData = mapData.Levels[0];

        Debug.Log(levelData);

        Rectangle         tileBounds1 = mapData.TileBounds;
        VirtualMap <char> data1       = new VirtualMap <char>(tileBounds1.Width, tileBounds1.Height, '0');
        VirtualMap <char> data2       = new VirtualMap <char>(tileBounds1.Width, tileBounds1.Height, '0');
        VirtualMap <bool> virtualMap  = new VirtualMap <bool>(tileBounds1.Width, tileBounds1.Height, false);
        Regex             regex       = new Regex("\\r\\n|\\n\\r|\\n|\\r");

        foreach (LevelData level in mapData.Levels)
        {
            Rectangle tileBounds2 = level.TileBounds;
            int       left1       = tileBounds2.Left;
            tileBounds2 = level.TileBounds;
            int      top1      = tileBounds2.Top;
            string[] strArray1 = regex.Split(level.Bg);
            for (int index1 = top1; index1 < top1 + strArray1.Length; ++index1)
            {
                for (int index2 = left1; index2 < left1 + strArray1[index1 - top1].Length; ++index2)
                {
                    data1[index2 - tileBounds1.X, index1 - tileBounds1.Y] = strArray1[index1 - top1][index2 - left1];
                }
            }

            string[] strArray2 = regex.Split(level.Solids);
            for (int index1 = top1; index1 < top1 + strArray2.Length; ++index1)
            {
                for (int index2 = left1; index2 < left1 + strArray2[index1 - top1].Length; ++index2)
                {
                    data2[index2 - tileBounds1.X, index1 - tileBounds1.Y] = strArray2[index1 - top1][index2 - left1];
                }
            }
            tileBounds2 = level.TileBounds;
            int left2 = tileBounds2.Left;
            while (true)
            {
                int num1 = left2;
                tileBounds2 = level.TileBounds;
                int right = tileBounds2.Right;
                if (num1 < right)
                {
                    tileBounds2 = level.TileBounds;
                    int top2 = tileBounds2.Top;
                    while (true)
                    {
                        int num2 = top2;
                        tileBounds2 = level.TileBounds;
                        int bottom = tileBounds2.Bottom;
                        if (num2 < bottom)
                        {
                            virtualMap[left2 - tileBounds1.Left, top2 - tileBounds1.Top] = true;
                            ++top2;
                        }
                        else
                        {
                            break;
                        }
                    }
                    ++left2;
                }
                else
                {
                    break;
                }
            }
            Gfx.FGAutotiler.LevelBounds.Add(new Rectangle(level.TileBounds.X - tileBounds1.X, level.TileBounds.Y - tileBounds1.Y, level.TileBounds.Width, level.TileBounds.Height));
        }

        foreach (Rectangle rectangle in mapData.Filler)
        {
            for (int left = rectangle.Left; left < rectangle.Right; ++left)
            {
                for (int top = rectangle.Top; top < rectangle.Bottom; ++top)
                {
                    char ch1 = '0';
                    if (rectangle.Top - tileBounds1.Y > 0)
                    {
                        char ch2 = data2[left - tileBounds1.X, rectangle.Top - tileBounds1.Y - 1];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0' && rectangle.Left - tileBounds1.X > 0)
                    {
                        char ch2 = data2[rectangle.Left - tileBounds1.X - 1, top - tileBounds1.Y];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0' && rectangle.Right - tileBounds1.X < tileBounds1.Width - 1)
                    {
                        char ch2 = data2[rectangle.Right - tileBounds1.X, top - tileBounds1.Y];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0' && rectangle.Bottom - tileBounds1.Y < tileBounds1.Height - 1)
                    {
                        char ch2 = data2[left - tileBounds1.X, rectangle.Bottom - tileBounds1.Y];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0')
                    {
                        ch1 = '1';
                    }
                    data2[left - tileBounds1.X, top - tileBounds1.Y]      = ch1;
                    virtualMap[left - tileBounds1.X, top - tileBounds1.Y] = true;
                }
            }
        }
        using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
        {
label_85:
            while (enumerator.MoveNext())
            {
                LevelData current     = enumerator.Current;
                Rectangle tileBounds2 = current.TileBounds;
                int       left1       = tileBounds2.Left;
                while (true)
                {
                    int num1 = left1;
                    tileBounds2 = current.TileBounds;
                    int right = tileBounds2.Right;
                    if (num1 < right)
                    {
                        tileBounds2 = current.TileBounds;
                        int  top = tileBounds2.Top;
                        char ch1 = data1[left1 - tileBounds1.X, top - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, top - tileBounds1.Y - index]; ++index)
                        {
                            data1[left1 - tileBounds1.X, top - tileBounds1.Y - index] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num2 = tileBounds2.Bottom - 1;
                        char ch2  = data1[left1 - tileBounds1.X, num2 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, num2 - tileBounds1.Y + index]; ++index)
                        {
                            data1[left1 - tileBounds1.X, num2 - tileBounds1.Y + index] = ch2;
                        }
                        ++left1;
                    }
                    else
                    {
                        break;
                    }
                }
                tileBounds2 = current.TileBounds;
                int num3 = tileBounds2.Top - 4;
                while (true)
                {
                    int num1 = num3;
                    tileBounds2 = current.TileBounds;
                    int num2 = tileBounds2.Bottom + 4;
                    if (num1 < num2)
                    {
                        tileBounds2 = current.TileBounds;
                        int  left2 = tileBounds2.Left;
                        char ch1   = data1[left2 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left2 - tileBounds1.X - index, num3 - tileBounds1.Y]; ++index)
                        {
                            data1[left2 - tileBounds1.X - index, num3 - tileBounds1.Y] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num4 = tileBounds2.Right - 1;
                        char ch2  = data1[num4 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[num4 - tileBounds1.X + index, num3 - tileBounds1.Y]; ++index)
                        {
                            data1[num4 - tileBounds1.X + index, num3 - tileBounds1.Y] = ch2;
                        }
                        ++num3;
                    }
                    else
                    {
                        goto label_85;
                    }
                }
            }
        }

        using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
        {
label_100:
            while (enumerator.MoveNext())
            {
                LevelData current     = enumerator.Current;
                Rectangle tileBounds2 = current.TileBounds;
                int       left        = tileBounds2.Left;
                while (true)
                {
                    int num1 = left;
                    tileBounds2 = current.TileBounds;
                    int right = tileBounds2.Right;
                    if (num1 < right)
                    {
                        tileBounds2 = current.TileBounds;
                        int top = tileBounds2.Top;
                        if (data2[left - tileBounds1.X, top - tileBounds1.Y] == '0')
                        {
                            for (int index = 1; index < 8; ++index)
                            {
                                virtualMap[left - tileBounds1.X, top - tileBounds1.Y - index] = true;
                            }
                        }
                        tileBounds2 = current.TileBounds;
                        int num2 = tileBounds2.Bottom - 1;
                        if (data2[left - tileBounds1.X, num2 - tileBounds1.Y] == '0')
                        {
                            for (int index = 1; index < 8; ++index)
                            {
                                virtualMap[left - tileBounds1.X, num2 - tileBounds1.Y + index] = true;
                            }
                        }
                        ++left;
                    }
                    else
                    {
                        goto label_100;
                    }
                }
            }
        }
        using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
        {
label_122:
            while (enumerator.MoveNext())
            {
                LevelData current     = enumerator.Current;
                Rectangle tileBounds2 = current.TileBounds;
                int       left1       = tileBounds2.Left;
                while (true)
                {
                    int num1 = left1;
                    tileBounds2 = current.TileBounds;
                    int right = tileBounds2.Right;
                    if (num1 < right)
                    {
                        tileBounds2 = current.TileBounds;
                        int  top = tileBounds2.Top;
                        char ch1 = data2[left1 - tileBounds1.X, top - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, top - tileBounds1.Y - index]; ++index)
                        {
                            data2[left1 - tileBounds1.X, top - tileBounds1.Y - index] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num2 = tileBounds2.Bottom - 1;
                        char ch2  = data2[left1 - tileBounds1.X, num2 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, num2 - tileBounds1.Y + index]; ++index)
                        {
                            data2[left1 - tileBounds1.X, num2 - tileBounds1.Y + index] = ch2;
                        }
                        ++left1;
                    }
                    else
                    {
                        break;
                    }
                }
                tileBounds2 = current.TileBounds;
                int num3 = tileBounds2.Top - 4;
                while (true)
                {
                    int num1 = num3;
                    tileBounds2 = current.TileBounds;
                    int num2 = tileBounds2.Bottom + 4;
                    if (num1 < num2)
                    {
                        tileBounds2 = current.TileBounds;
                        int  left2 = tileBounds2.Left;
                        char ch1   = data2[left2 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left2 - tileBounds1.X - index, num3 - tileBounds1.Y]; ++index)
                        {
                            data2[left2 - tileBounds1.X - index, num3 - tileBounds1.Y] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num4 = tileBounds2.Right - 1;
                        char ch2  = data2[num4 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[num4 - tileBounds1.X + index, num3 - tileBounds1.Y]; ++index)
                        {
                            data2[num4 - tileBounds1.X + index, num3 - tileBounds1.Y] = ch2;
                        }
                        ++num3;
                    }
                    else
                    {
                        goto label_122;
                    }
                }
            }
        }
        Vector2         position        = new Vector2((float)tileBounds1.X, (float)tileBounds1.Y) * 8f;
        BackgroundTiles backgroundTiles = new BackgroundTiles(position, data1);


        //MTexture mTexture = Gfx.Game["tilesets/dirt"];
        //草地等等
        //MTexture mTexture = Gfx.Game["tilesets/scenery"];
        //StartCoroutine(DrawTiles(backgroundTiles.Tiles, Vector3.zero));


        /////////////////////////////////////////////////////
        ///构建BgTiles
        /////////////////////////////////////////////////////
        int  l8     = levelData.TileBounds.Left;
        int  t8     = levelData.TileBounds.Top;
        int  w8     = levelData.TileBounds.Width;
        int  h8     = levelData.TileBounds.Height;
        bool flag14 = !string.IsNullOrEmpty(levelData.BgTiles);

        if (flag14)
        {
            int[,] tiles = Util.ReadCSVIntGrid(levelData.BgTiles, w8, h8);
            backgroundTiles.Tiles.Overlay(Gfx.SceneryTiles, tiles, l8 - tileBounds1.X, t8 - tileBounds1.Y);
        }

        //BackdropRenderer backgroundRenderer = new BackdropRenderer();
        //backgroundRenderer.Backdrops = mapData.CreateBackdrops(mapData.Background);

        //BackdropRenderer foregroundRenderer = new BackdropRenderer();
        //foregroundRenderer.Backdrops = mapData.CreateBackdrops(mapData.Foreground);
        //foreach(Backdrop backdrop in backgroundRenderer.Backdrops)
        //{
        //    if(backdrop is Parallax)
        //    {
        //        ShowSprite((backdrop as Parallax).Texture);
        //    }

        //}
        //StartCoroutine(DrawTiles(backgroundTiles.Tiles, Vector3.zero));



        //foreach (DecalData bgDecal in levelData.BgDecals)
        //{
        //    new Decal(bgDecal.Texture, Vector3.zero + bgDecal.Position, bgDecal.Scale, 9000);
        //}
    }
 private void LoadingThread()
 {
     Gfx     = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "WaveDashing"), Atlas.AtlasDataFormat.Packer);
     loading = false;
 }