예제 #1
0
    private void setupWorld()
    {
        GDKnyttWorldImpl world;

        if (GDKnyttDataStore.KWorld != null)
        {
            world = GDKnyttDataStore.KWorld;
        }
        else
        {
            world = new GDKnyttWorldImpl();
            world.setDirectory(this.demoWorld, "");
            var save_data = GDKnyttAssetManager.loadTextFile(this.demoWorld + "/DefaultSavegame.ini");
            world.CurrentSave = new KnyttSave(world, save_data, 1);
        }

        GDWorld.setWorld(this, world);
        createJuni();
        GDWorld.loadWorld();

        this.changeArea(GDWorld.KWorld.CurrentSave.getArea(), true);
        Juni.moveToPosition(CurrentArea, GDWorld.KWorld.CurrentSave.getAreaPosition());

        UI.initialize(this);
        UI.updatePowers();
    }
예제 #2
0
    private void setupWorld()
    {
        GDKnyttWorldImpl world = GDKnyttDataStore.KWorld;

        GDWorld.setWorld(this, world);
        GDWorld.loadWorld();
        createJuni();

        this.changeArea(GDWorld.KWorld.CurrentSave.getArea(), true);
        Juni.moveToPosition(CurrentArea, GDWorld.KWorld.CurrentSave.getAreaPosition());
        saveGame(Juni, false);

        UI.initialize(this);
        UI.updatePowers();

        mapPanel = GetNode <MapPanel>("UICanvasLayer/MapBackgroundPanel/MapPanel");
        if (hasMap())
        {
            mapPanel.init(GDWorld.KWorld, Juni);
            GetNode <TouchPanel>("UICanvasLayer/TouchPanel").InstallMap();
        }
        else
        {
            mapPanel.init(null, null);
        }
    }
예제 #3
0
    public void initialize(string path)
    {
        KWorld = new GDKnyttWorldImpl();
        if (new Directory().DirExists(path))
        {
            KWorld.setDirectory(path, GDKnyttAssetManager.extractFilename(path));
        }
        else
        {
            var loader = new KnyttBinWorldLoader(GDKnyttAssetManager.loadFile(path));
            KWorld.setBinMode(loader);
            KWorld.setDirectory(path, loader.RootDirectory);
        }
        string ini = GDKnyttAssetManager.loadTextFile(KWorld.getWorldData("World.ini"));

        KWorld.loadWorldConfig(ini);

        Texture info = (KWorld.worldFileExists("Info+.png") ? KWorld.getWorldTexture("Info+.png") :
                        KWorld.worldFileExists("Info.png") ? KWorld.getWorldTexture("Info.png") : null) as Texture;

        if (info != null)
        {
            info.Flags |= (uint)Texture.FlagsEnum.Filter;
            GetNode <TextureRect>("InfoRect").Texture = info;
        }

        GetNode <SlotButton>("InfoRect/Slot1Button").BaseFile = "user://Saves/" + KWorld.WorldDirectoryName;
        GetNode <SlotButton>("InfoRect/Slot2Button").BaseFile = "user://Saves/" + KWorld.WorldDirectoryName;
        GetNode <SlotButton>("InfoRect/Slot3Button").BaseFile = "user://Saves/" + KWorld.WorldDirectoryName;
        GetNode <Button>("InfoRect/RatePanel/VBoxContainer/UninstallButton").Disabled = KWorld.WorldDirectory.StartsWith("res://");
    }
예제 #4
0
 public void initialize(Texture icon, GDKnyttWorldImpl world)
 {
     this.KWorld = world;
     GetNode <TextureRect>("MainContainer/IconTexture").Texture           = icon;
     GetNode <TextureRect>("MainContainer/IconTexture").RectSize          = new Vector2(30, 30);
     GetNode <Label>("MainContainer/TextContainer/NameLabel").Text        = $"{world.Info.Name} ({world.Info.Author})";
     GetNode <Label>("MainContainer/TextContainer/DescriptionLabel").Text = world.Info.Description;
 }
예제 #5
0
    public void addWorld(GDKnyttWorldImpl world, Texture icon, bool focus)
    {
        var game_node = this.game_scene.Instance() as GameButton;

        game_node.initialize(icon, world);
        game_node.Connect("GamePressed", GetNode <LevelSelection>("../../.."), "_on_GamePressed");
        AddChild(game_node);
        if (focus)
        {
            game_node.GrabFocus();
        }
    }
예제 #6
0
    private KnyttWorldInfo getWorldInfo(byte[] ini_bin, KeyDataCollection merge_to = null)
    {
        string           ini   = GDKnyttAssetManager.loadTextFile(ini_bin);
        GDKnyttWorldImpl world = new GDKnyttWorldImpl();

        world.loadWorldConfig(ini);
        if (merge_to != null)
        {
            merge_to.Merge(world.INIData["World"]);
        }
        return(world.Info);
    }
예제 #7
0
    private KnyttWorldManager <Texture> .WorldEntry generateDirectoryWorld(string world_dir, string name)
    {
        Texture icon;
        string  txt;

        lock (file_lock) { icon = GDKnyttAssetManager.loadExternalTexture(world_dir + "/Icon.png"); }
        lock (file_lock) { txt = GDKnyttAssetManager.loadTextFile(world_dir + "/World.ini"); }
        GDKnyttWorldImpl world = new GDKnyttWorldImpl();

        world.setDirectory(world_dir, name);
        world.loadWorldConfig(txt);
        return(new KnyttWorldManager <Texture> .WorldEntry(world, icon));
    }
예제 #8
0
    public void loadTutorial()
    {
        var binloader          = new KnyttBinWorldLoader(GDKnyttAssetManager.loadFile("res://knytt/worlds/Nifflas - Tutorial.knytt.bin"));
        var txt                = GDKnyttAssetManager.loadTextFile(binloader.GetFile("World.ini"));
        GDKnyttWorldImpl world = new GDKnyttWorldImpl();

        world.setDirectory("res://knytt/worlds", binloader.RootDirectory);
        world.loadWorldConfig(txt);
        var save_txt = GDKnyttAssetManager.loadTextFile(binloader.GetFile("DefaultSavegame.ini"));

        world.CurrentSave = new KnyttSave(world, save_txt, 1);
        world.setBinMode(binloader);
        GDKnyttDataStore.KWorld = world;
    }
예제 #9
0
    public void initialize(GDKnyttWorldImpl world)
    {
        this.KWorld = world;
        if (world.BinMode)
        {
            world.setBinMode(new KnyttBinWorldLoader(GDKnyttAssetManager.loadFile(world.WorldDirectory)));
        }
        var info = world.getWorldTexture("Info.png");

        GetNode <TextureRect>("InfoRect").Texture    = (Texture)info;
        GetNode <SlotButton>("Slot1Button").BaseFile = "user://Saves/" + world.WorldDirectoryName;
        GetNode <SlotButton>("Slot2Button").BaseFile = "user://Saves/" + world.WorldDirectoryName;
        GetNode <SlotButton>("Slot3Button").BaseFile = "user://Saves/" + world.WorldDirectoryName;
    }
예제 #10
0
    private KnyttWorldManager <Texture> .WorldEntry generateBinWorld(string world_dir)
    {
        Texture             icon;
        string              txt;
        KnyttBinWorldLoader binloader;

        lock (file_lock) { binloader = new KnyttBinWorldLoader(GDKnyttAssetManager.loadFile(world_dir)); }
        lock (file_lock) { icon = GDKnyttAssetManager.loadTexture(binloader.GetFile("Icon.png")); }
        lock (file_lock) { txt = GDKnyttAssetManager.loadTextFile(binloader.GetFile("World.ini")); }
        GDKnyttWorldImpl world = new GDKnyttWorldImpl();

        world.setDirectory(world_dir, binloader.RootDirectory);
        world.loadWorldConfig(txt);
        world.setBinMode(null);
        return(new KnyttWorldManager <Texture> .WorldEntry(world, icon));
    }
예제 #11
0
 public void setWorld(GDKnyttGame game, GDKnyttWorldImpl world)
 {
     this.KWorld = world;
     this.Game   = game;
 }