Beispiel #1
0
 public void juniJumped(Juni juni)
 {
     if (bouncer_data.jump_trigger && !in_air)
     {
         launch();
     }
 }
Beispiel #2
0
    // Changes the current area
    public void changeArea(KnyttPoint new_area, bool force_jump = false, bool regenerate_same = true)
    {
        // Regenerate current area if no change, else deactivate old area
        if (this.CurrentArea != null)
        {
            if (CurrentArea.Area.Position.Equals(new_area))
            {
                if (regenerate_same)
                {
                    CurrentArea.regenerateArea(regenerate_same: regenerate_same);
                }
                return;
            }

            CurrentArea.scheduleDeactivation();
        }

        // Update the paging
        GDWorld.Areas.setLocation(new_area);
        var area = GDWorld.getArea(new_area);

        if (area == null)
        {
            return;
        }

        this.CurrentArea = area;
        this.CurrentArea.activateArea();
        this.beginTransitionEffects(force_jump);

        Juni.stopHologram(cleanup: true);
    }
Beispiel #3
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();
    }
Beispiel #4
0
 // On load a save file
 public void createJuni()
 {
     Juni = juni_scene.Instance() as Juni;
     Juni.initialize(this);
     this.AddChild(Juni);
     Juni.Connect("PowerChanged", UI, "powerUpdate");
 }
Beispiel #5
0
    public void _on_Area2D_body_entered(Node body)
    {
        if (bouncer_data.deadly && body is Juni)
        {
            Juni.die();
            return;
        }

        if (!in_air)
        {
            return;
        }
        if (!GDArea.isIn(GlobalPosition))
        {
            return;
        }                                             // ignore all collisions if out of the area
        if (vel < 0f)
        {
            vel = -vel; return;
        }

        in_air = false;

        var p = Position;

        p.y      = start_y;
        Position = p;

        GetNode <AnimatedSprite>("AnimatedSprite").Play(Anim, true);
    }
Beispiel #6
0
 public void execute(Juni juni)
 {
     if ([email protected] || GDArea.Selector.IsObjectSelected(this))
     {
         executeAnyway(juni);
     }
 }
Beispiel #7
0
 private void _on_EnterArea_body_entered(Juni juni)
 {
     if (juni.juniInput.DownHeld)
     {
         juni.CanJump = false;
     }
     junis.Add(juni);
 }
Beispiel #8
0
 public void _on_Area2D_body_entered(Node body)
 {
     if (!(body is Juni))
     {
         return;
     }
     Juni.die();
 }
Beispiel #9
0
 private void _on_EnterArea_body_exited(Juni juni)
 {
     if (juni.juniInput.DownHeld)
     {
         juni.CanJump = true;
     }
     junis.Remove(juni);
 }
Beispiel #10
0
 public void updateItems(Juni juni)
 {
     foreach (var child in GetNode <Node>("ItemContainer").GetChildren())
     {
         ItemInfo ii = child as ItemInfo;
         ii.updateItem(juni.Powers);
     }
 }
Beispiel #11
0
    public WalkRunState(Juni juni, bool walk_run) : base(juni)
    {
        this.walk_run = walk_run;
        juni.MotionParticles.CurrentMotion = walk_run ? JuniMotionParticles.JuniMotion.RUN : JuniMotionParticles.JuniMotion.WALK;

        // Calculate the leeway frames to fall in a frame independent manner
        fall_frames  = Mathf.FloorToInt(FALL_LEEWAY / (1f / ((int)ProjectSettings.GetSetting("physics/common/physics_fps"))));
        current_fall = fall_frames;
    }
Beispiel #12
0
 public void executeAnyway(Juni juni)
 {
     if ([email protected] && alreadyExecuted)
     {
         return;
     }
     alreadyExecuted = true;
     CallDeferred("_execute", juni);
 }
Beispiel #13
0
    public void init(KnyttWorld world, Juni juni)
    {
        SetProcessInput(false);
        SetProcess(false);
        SetPhysicsProcess(false);

        if (world == null || juni == null)
        {
            return;
        }
        this.world = world;
        this.juni  = juni;

        this.RectSize = new Vector2(
            (world.MaxBounds.x - world.MinBounds.x + 1) * XSIZE,
            (world.MaxBounds.y - world.MinBounds.y + 1) * YSIZE);

        foreach (var area in world.Map)
        {
            if (area?.ExtraData == null)
            {
                continue;
            }
            var coord = area.Position;

            int?map_x = int.TryParse(area.ExtraData["MapX"], out var i) ? i : null as int?;
            int?map_y = int.TryParse(area.ExtraData["MapY"], out i) ? i : null as int?;
            if (map_x != null || map_y != null)
            {
                spoofing[coord] = new KnyttPoint(map_x ?? coord.x, map_y ?? coord.y);
            }

            if (area.ExtraData["MapVisible"]?.ToLower() == "true")
            {
                visible[coord] = true;
            }
            if (area.ExtraData["MapVisible"]?.ToLower() == "false")
            {
                visible[coord] = false;
            }

            int?color = int.TryParse(area.ExtraData["MapColor"], out i) ? i : null as int?;
            if (color != null)
            {
                if (color == 64)
                {
                    visible[coord] = false;
                }
                else
                {
                    colors[coord] = new Color((color.Value % 4) / 3f, ((color.Value / 4) % 4) / 3f, ((color.Value / 16) % 4) / 3f);
                }
            }
        }
    }
Beispiel #14
0
    public void _on_Area2D_body_entered(Node body)
    {
        if (!(body is Juni))
        {
            return;
        }

        string ending = GDArea.Area.getExtraData("Ending");

        Juni.win(ending == null ? "Ending" : ending);
    }
Beispiel #15
0
 public void _on_Area2D_body_entered(Node body)
 {
     if (body is Juni)
     {
         Juni.die(); return;
     }
     if (wait_timer.TimeLeft > 0f)
     {
         return;
     }
     stop();
 }
Beispiel #16
0
    public void juniJumped(Juni juni)
    {
        if (in_air)
        {
            return;
        }

        // Calculate and test jump chance
        if (!in_air && juni.Hologram == null && Mathf.Abs(juni.ApparentPosition.x - Center.x) < 150 + random.Next(80))
        {
            launch();
        }
    }
Beispiel #17
0
    public override void _PhysicsProcess(float delta)
    {
        base._PhysicsProcess(delta);
        float distance = Juni.distance(Center);

        if (distance > JUNI_MIN_DISTANCE)
        {
            var inertia          = 0.9f - delta * 3; // TODO: replace this magic formula with more correct and fps-independent behaviour
            var new_speed_vector = speed * SPEED_SCALE * (Juni.ApparentPosition - Center) / distance;
            speedVector = speedVector * inertia + new_speed_vector * (1 - inertia);
        }
        Translate(speedVector * delta);
    }