Ejemplo n.º 1
0
    static void EditLevel()
    {
        Print.Reset();

        string           PATH  = Print.Prompt("Path to level file:");
        LevelAssetBINARY level = LevelFactory.ReadLevel(PATH);

        if (Print.YesOrNo("Change level name?"))
        {
            level.name = Print.Prompt("Level name:");
        }

        if (Print.YesOrNo("Change level difficulty?"))
        {
            level.difficulty = int.Parse(Print.Prompt(difficultylevel, "Enter a number:"));
        }

        if (Print.YesOrNo("Change level map?"))
        {
            string image = Print.Prompt("Path to image:");
            level.image = LevelFactory.GetImageBytes(image);
        }

        if (Print.Prompt("Confirm changes Y/N?").ToLower() == "y")
        {
            LevelFactory.WriteLevel(PATH, level);
        }
    }
    public static void WriteLevel(string PATH, LevelAssetBINARY level)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(LevelAssetBINARY));

        using (Stream stream = new FileStream(PATH, FileMode.Create, FileAccess.Write, FileShare.None)) {
            serializer.Serialize(stream, level);
        }
    }
    public static LevelAssetBINARY ReadLevel(string PATH)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(LevelAssetBINARY));

        using (Stream stream = new FileStream(PATH, FileMode.Open, FileAccess.Read, FileShare.Read)) {
            LevelAssetBINARY level = (LevelAssetBINARY)serializer.Deserialize(stream);
            return(level);
        }
    }
Ejemplo n.º 4
0
    static void CreateLevel()
    {
        Print.Reset();

        LevelAssetBINARY level = new LevelAssetBINARY
        {
            name       = Print.Prompt("Level name:"),
            difficulty = int.Parse(Print.Prompt(difficultylevel, "Enter a number:")),
            PublicKey  = Print.Prompt("Public Key: "),
            PrivateKey = Print.Prompt("Private Key: "),
            Savekey    = Print.Prompt("Save Key: ")
        };

        string PATH = WD + "/Textures/" + Print.Prompt("Name of image (include the file extension):");

        level.image = LevelFactory.GetImageBytes(PATH);
        string saveName = Print.Prompt("file name:");

        LevelFactory.WriteLevel(WD + saveName + ".level", level);
    }