private void _ShipExitedDockingDistance(PhysicsBody2D body) { if (body is IDockable t) { t.RevokeDock(this); } }
private void _on_key_body_entered(PhysicsBody2D body) { if (body.IsInGroup("Player")) { QueueFree(); } }
public void _on_Star_body_entered(PhysicsBody2D body) { if (body.IsInGroup("Player")) { this.QueueFree(); } }
private void HandleBodyExited(PhysicsBody2D other) { if (other is Player p) { p.GetGroundItemController().RemoveItem(this); } }
public void OnPlayerBodyEntered(PhysicsBody2D body) { GD.Print("AAA"); Hide(); // Player disappears after being hit. EmitSignal("Hit"); GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true); }
void OnBodyExited(PhysicsBody2D body) { if (body is PlayerKinematicBody2D player) { player.MountableRegion = null; } }
public void OnArea2DEntered(PhysicsBody2D body2D) { if (body2D.IsInGroup("Enemy")) { body2D.EmitSignal("TakeDamage", 2); } }
private void OnPlayerBodyEntered(PhysicsBody2D body) { Hide(); EmitSignal("Hit"); GetNode <CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true); // Replace with function body. }
// 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"); } }
public void BodyEntered(PhysicsBody2D body) { if (body is Rexy rexy) { rexy.Claw.NextToOven(this); } }
public void BodyExited(PhysicsBody2D body) { if (body is Rexy rexy) { rexy.Claw.LeaveOven(this); } }
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(); }
protected void OnBodyEnter(PhysicsBody2D body) { if (body.IsInGroup("floor")) { node.LookAt(body.Position); } }
public void Hit(PhysicsBody2D body) { if (body is Enemy enemy) { EmitSignal(nameof(EnemyHit), enemy); } }
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); }
public void _on_PreasurePlate_body_entered(PhysicsBody2D body) { if (body is Player) { EmitSignal("PlayerEntered"); } }
void OnBodyEntered(PhysicsBody2D body) { if (body is PlayerKinematicBody2D player) { player.MountableRegion = this; } }
private void OnBodyEnter(PhysicsBody2D body) { if (body.IsInGroup("floor")) { activeFloor = body; } }
public void OnBodyEntered(PhysicsBody2D body) { lifes -= 1; Damaged.Show(); isIvulnerable = true; Timeout("OnIvulnerableTimeout", ivulnerableTime); }
private void OnBodyExit(PhysicsBody2D body) { if (body == activeFloor) { activeFloor = null; } }
public void _on_Area2D_body_entered(PhysicsBody2D body) { if (body.Name == "player") { canInteract = true; } }
public void _on_Area2D_body_entered(PhysicsBody2D body) { if (body is Player) { EmitSignal("PlayerEntered"); } }
private void OnBodyExit(PhysicsBody2D body) { if (body is PlayerKinematicBody2D player) { player.OverBarrel = null; } }
// Drop the target private void OnDetectRadiusBodyExited(PhysicsBody2D body) { if (body == _target) { _target = null; } }
private void _ShipEnteredDockingDistance(PhysicsBody2D body) { if (body is IDockable t) { t.OfferDock(this); } }
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; } }
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); }
private void _on_Haste_body_entered(PhysicsBody2D body) { if ((body as Node2D).Name == "Player1" || (body as Node2D).Name == "Player2") { (body as Player).GiveHaste(); } QueueFree(); }