balance changes
This commit is contained in:
parent
0fc71532e2
commit
040d419a27
16 changed files with 203 additions and 17 deletions
41
scripts/components/particles/FallFloor.cs
Normal file
41
scripts/components/particles/FallFloor.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class FallFloor : Node2D
|
||||
{
|
||||
private static FallFloor Instance;
|
||||
private Array<StaticBody2D> bodies = [];
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
foreach (StaticBody2D body in GetChildren())
|
||||
{
|
||||
bodies.Add(body);
|
||||
}
|
||||
}
|
||||
public static StaticBody2D GetNearest(Vector2 point)
|
||||
{
|
||||
var selected = Instance.bodies[0];
|
||||
foreach (StaticBody2D body in Instance.bodies)
|
||||
{
|
||||
if (Math.Abs(selected.GlobalPosition.Y - point.Y) > Math.Abs(body.GlobalPosition.Y - point.Y))
|
||||
{
|
||||
selected = body;
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
public static Array<StaticBody2D> GetEverythingElse(StaticBody2D except)
|
||||
{
|
||||
Array<StaticBody2D> bodys = [];
|
||||
foreach (StaticBody2D body in Instance.bodies)
|
||||
{
|
||||
if (except != body)
|
||||
{
|
||||
bodys.Add(body);
|
||||
}
|
||||
}
|
||||
return bodys;
|
||||
}
|
||||
}
|
||||
1
scripts/components/particles/FallFloor.cs.uid
Normal file
1
scripts/components/particles/FallFloor.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://blpu7t8tf6277
|
||||
20
scripts/components/particles/FallParticle.cs
Normal file
20
scripts/components/particles/FallParticle.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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;
|
||||
public void FallOff()
|
||||
{
|
||||
SetDeferred("freeze", false);
|
||||
foreach (var floor in FallFloor.GetEverythingElse(FallFloor.GetNearest(data.GlobalPosition)))
|
||||
{
|
||||
AddCollisionExceptionWith(floor);
|
||||
}
|
||||
Callable.From(()=>{ Reparent(PoolContainer.Instance.Zombies); }).CallDeferred();
|
||||
deathTimer.Start();
|
||||
}
|
||||
}
|
||||
1
scripts/components/particles/FallParticle.cs.uid
Normal file
1
scripts/components/particles/FallParticle.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dt5uj25u0g6y3
|
||||
Loading…
Add table
Add a link
Reference in a new issue