Beispiel #1
0
    private void _warp_juni(Juni juni)
    {
        if (juni.dead)
        {
            return;
        }                          // If juni is dead, ignore warps

        // Calculate the warp
        var area       = CurrentArea.Area;
        var jgp        = juni.GlobalPosition;
        var new_coords = GDKnyttWorld.getAreaCoords(jgp);

        if (new_coords.Equals(area.Position))
        {
            return;
        }                                                 // Area may change if warp is deferred
        var wc = area.Warp.getWarpCoords(new_coords, area.Position);

        // Apply the warp
        jgp += new Vector2(GDKnyttArea.Width * wc.x, GDKnyttArea.Height * wc.y);
        var after_warp_coords = GDKnyttWorld.getAreaCoords(jgp);

        // Apply flag warps
        var found_warp = getFlagWarp(after_warp_coords, juni);

        if (found_warp != null)
        {
            jgp += new Vector2(GDKnyttArea.Width * found_warp.Value.x, GDKnyttArea.Height * found_warp.Value.y);
        }
        var after_flag_warp_coords = GDKnyttWorld.getAreaCoords(jgp);

        juni.GlobalPosition = jgp;
        changeArea(after_flag_warp_coords, regenerate_same: false);
    }
Beispiel #2
0
    public void loadArea(GDKnyttWorld world, KnyttArea area)
    {
        this.GDWorld = world;
        this.Area    = area;

        this.Name = area.Position.ToString();

        this.Position = new Vector2(area.Position.x * Width, area.Position.y * Height);

        // If it's an empty area, quit loading here
        if (area.Empty)
        {
            return;
        }

        // Setup gradient
        GetNode <GDKnyttBackground>("Background").initialize(world.AssetManager.getGradient(area.Background));

        // Initialize the Layers
        Tiles = tiles_scene.Instance() as GDAreaTiles;
        this.Tiles.initTiles(this);
        AddChild(Tiles);

        // Area should start deactivated
        this.deactivateArea();
    }
Beispiel #3
0
    public void warpJuni(Juni juni)
    {
        // Calculate the warp
        var area       = CurrentArea.Area;
        var jgp        = juni.GlobalPosition;
        var new_coords = GDKnyttWorld.getAreaCoords(jgp);
        var wc         = area.Warp.getWarpCoords(new_coords, area.Position);

        // Apply the warp
        jgp += new Vector2(GDKnyttArea.Width * wc.x, GDKnyttArea.Height * wc.y);
        juni.GlobalPosition = jgp;
        var after_warp_coords = GDKnyttWorld.getAreaCoords(jgp);

        changeArea(after_warp_coords, regenerate_same: false);
    }
    public GDKnyttAssetManager(GDKnyttWorld gdworld, int tile_cache, int gradient_cache, int song_cache, int ambiance_cache, int object_cache)
    {
        this.GDWorld = gdworld;
        Directories  = new Dictionary <string, string>();

        TileSetCache          = new ObjectCache <int, TileSet>(tile_cache);
        TileSetCache.OnCreate = (int num) => buildTileSet(num);

        GradientCache          = new ObjectCache <int, Texture>(gradient_cache);
        GradientCache.OnCreate = (int num) => buildGradient(num);

        SongCache          = new ObjectCache <int, AudioStream>(song_cache);
        SongCache.OnCreate = (int num) => buildSong(num);

        AmbianceCache          = new ObjectCache <int, AudioStream>(ambiance_cache);
        AmbianceCache.OnCreate = (int num) => buildAmbiance(num);

        ObjectCache          = new ObjectCache <KnyttPoint, GDKnyttObjectBundle>(object_cache);
        ObjectCache.OnCreate = (KnyttPoint id) => GDKnyttObjectFactory.buildKnyttObject(id);
    }