Sun scoring and zombie hat impulse

This commit is contained in:
Rendo 2025-06-28 03:36:18 +05:00
commit 6608fb8389
9 changed files with 62 additions and 7 deletions

View file

@ -1,12 +1,16 @@
using Godot;
using Newlon.Components.Level;
using Newlon.Components.Zombies;
using System;
public partial class FallParticle : RigidBody2D
{
[Export] private RuntimeZombieData data;
[Export] private Timer deathTimer;
[Export] private Vector2 falloffImpulseMin = Vector2.Zero;
[Export] private Vector2 falloffImpulseMax = Vector2.Zero;
[Export] private Vector2 falloffOffsetMin = Vector2.Zero;
[Export] private Vector2 falloffOffsetMax = Vector2.Zero;
[Export] private float Impulse;
public void FallOff()
{
SetDeferred("freeze", false);
@ -14,7 +18,17 @@ public partial class FallParticle : RigidBody2D
{
AddCollisionExceptionWith(floor);
}
Callable.From(()=>{ Reparent(PoolContainer.Instance.Zombies); }).CallDeferred();
Callable.From(() =>
{
Reparent(PoolContainer.Instance.Zombies);
ApplyImpulse(RandomVector(falloffImpulseMin, falloffImpulseMax).Normalized() * Impulse, RandomVector(falloffOffsetMin, falloffOffsetMax));
}).CallDeferred();
deathTimer.Start();
}
private Vector2 RandomVector(Vector2 min, Vector2 max)
{
return new Vector2((float)GD.RandRange(min.X,max.X),(float)GD.RandRange(min.Y,max.Y));
}
}