Example #1
0
 private void _ShipExitedDockingDistance(PhysicsBody2D body)
 {
     if (body is IDockable t)
     {
         t.RevokeDock(this);
     }
 }
Example #2
0
 private void _on_key_body_entered(PhysicsBody2D body)
 {
     if (body.IsInGroup("Player"))
     {
         QueueFree();
     }
 }
Example #3
0
 public void _on_Star_body_entered(PhysicsBody2D body)
 {
     if (body.IsInGroup("Player"))
     {
         this.QueueFree();
     }
 }
Example #4
0
 private void HandleBodyExited(PhysicsBody2D other)
 {
     if (other is Player p)
     {
         p.GetGroundItemController().RemoveItem(this);
     }
 }
Example #5
0
 public void OnPlayerBodyEntered(PhysicsBody2D body)
 {
     GD.Print("AAA");
     Hide();         // Player disappears after being hit.
     EmitSignal("Hit");
     GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true);
 }
Example #6
0
 void OnBodyExited(PhysicsBody2D body)
 {
     if (body is PlayerKinematicBody2D player)
     {
         player.MountableRegion = null;
     }
 }
Example #7
0
 public void OnArea2DEntered(PhysicsBody2D body2D)
 {
     if (body2D.IsInGroup("Enemy"))
     {
         body2D.EmitSignal("TakeDamage", 2);
     }
 }
Example #8
0
 private void OnPlayerBodyEntered(PhysicsBody2D body)
 {
     Hide();
     EmitSignal("Hit");
     GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true);
     // Replace with function body.
 }
Example #9
0
    // Called when a tank shoots
    // Emits the Shoot signal for the Map to listen to
    public void Fire(int num, float spread, PhysicsBody2D target = null)
    {
        if (_canShoot && this.Ammo != 0)
        {
            SetAmmo(this.Ammo - 1);
            _canShoot = false;
            GetNode <Timer>("GunTimer").Start();

            Vector2 dir = new Vector2(1, 0).Rotated(GetNode <Sprite>("Turret").GlobalRotation);

            if (num > 1)
            {
                for (int i = 0; i < num; i++)
                {
                    float angle = -spread * i * (2 * spread) / (num - 1);
                    EmitSignal("Shoot", this.Bullet, GetNode <Position2D>("Turret/Muzzle").GlobalPosition, dir.Rotated(angle), target);
                }
            }
            else
            {
                EmitSignal("Shoot", this.Bullet, GetNode <Position2D>("Turret/Muzzle").GlobalPosition, dir, target);
            }

            // Play muzzle flash
            GetNode <AnimationPlayer>("Anim").Play("muzzle_flash");
        }
    }
Example #10
0
 public void BodyEntered(PhysicsBody2D body)
 {
     if (body is Rexy rexy)
     {
         rexy.Claw.NextToOven(this);
     }
 }
Example #11
0
 public void BodyExited(PhysicsBody2D body)
 {
     if (body is Rexy rexy)
     {
         rexy.Claw.LeaveOven(this);
     }
 }
Example #12
0
    private void OnPickupBodyEntered(PhysicsBody2D body)
    {
        var tank = body as Tank;

        switch (this.Type)
        {
        case PickupType.Health:

            if (tank.HasMethod("Heal"))
            {
                tank.Heal((int)GD.RandRange(Amount.x, Amount.y));
            }

            break;

        case PickupType.Ammo:

            if (tank.HasMethod("SetAmmo"))
            {
                tank.SetAmmo((int)GD.RandRange(Amount.x, Amount.y));
            }

            break;

        default:
            // Do nothing.
            break;
        }

        QueueFree();
    }
Example #13
0
 protected void OnBodyEnter(PhysicsBody2D body)
 {
     if (body.IsInGroup("floor"))
     {
         node.LookAt(body.Position);
     }
 }
Example #14
0
File: Bullet.cs Project: exts/ld44
 public void Hit(PhysicsBody2D body)
 {
     if (body is Enemy enemy)
     {
         EmitSignal(nameof(EnemyHit), enemy);
     }
 }
Example #15
0
 public void OnPlayerBodyEntered(PhysicsBody2D body)
 {
     Hide(); // Player disappears after being hit.
     EmitSignal(nameof(Hit));
     // Must be deferred as we can't change physics properties on a physics callback.
     GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true);
 }
Example #16
0
 public void _on_PreasurePlate_body_entered(PhysicsBody2D body)
 {
     if (body is Player)
     {
         EmitSignal("PlayerEntered");
     }
 }
Example #17
0
 void OnBodyEntered(PhysicsBody2D body)
 {
     if (body is PlayerKinematicBody2D player)
     {
         player.MountableRegion = this;
     }
 }
Example #18
0
 private void OnBodyEnter(PhysicsBody2D body)
 {
     if (body.IsInGroup("floor"))
     {
         activeFloor = body;
     }
 }
Example #19
0
 public void OnBodyEntered(PhysicsBody2D body)
 {
     lifes -= 1;
     Damaged.Show();
     isIvulnerable = true;
     Timeout("OnIvulnerableTimeout", ivulnerableTime);
 }
Example #20
0
 private void OnBodyExit(PhysicsBody2D body)
 {
     if (body == activeFloor)
     {
         activeFloor = null;
     }
 }
 public void _on_Area2D_body_entered(PhysicsBody2D body)
 {
     if (body.Name == "player")
     {
         canInteract = true;
     }
 }
Example #22
0
 public void _on_Area2D_body_entered(PhysicsBody2D body)
 {
     if (body is Player)
     {
         EmitSignal("PlayerEntered");
     }
 }
Example #23
0
 private void OnBodyExit(PhysicsBody2D body)
 {
     if (body is PlayerKinematicBody2D player)
     {
         player.OverBarrel = null;
     }
 }
Example #24
0
 // Drop the target
 private void OnDetectRadiusBodyExited(PhysicsBody2D body)
 {
     if (body == _target)
     {
         _target = null;
     }
 }
Example #25
0
 private void _ShipEnteredDockingDistance(PhysicsBody2D body)
 {
     if (body is IDockable t)
     {
         t.OfferDock(this);
     }
 }
Example #26
0
 void NextScene(PhysicsBody2D body2D)
 {
     if (body2D is Player)
     {
         GetTree().ChangeScene(nextScenePath);
     }
 }
 public void _on_PlayerCatcher_body_entered(PhysicsBody2D body)
 {
     if (body.Name == "player")
     {
         body.Position = playerStartPos;
     }
 }
    // ================================================================

    void PlayerEntered(PhysicsBody2D body)
    {
        if (body.IsInGroup("Player"))
        {
            Player.StepSound = sound;
        }
    }
Example #29
0
 private void OnPlayerBodyEntered(PhysicsBody2D body)
 {
     Hide();         // Player disapears after being hit
     EmitSignal("Hit");
     // Only get hit once by disabling the collision shape
     GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true);
 }
Example #30
0
 private void _on_Haste_body_entered(PhysicsBody2D body)
 {
     if ((body as Node2D).Name == "Player1" || (body as Node2D).Name == "Player2")
     {
         (body as Player).GiveHaste();
     }
     QueueFree();
 }