fixed wrong opposite random direction
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace FOU.Scripts.Elements;
|
||||
|
||||
public class Water : Solid {
|
||||
public const int MAX_VERTICAL_SPREAD = 3;
|
||||
|
||||
public Water(int x, int y, ref Level level) : base(x, y, ref level) {
|
||||
Color = AddColorVariance(Colors.Blue);
|
||||
Density = 1;
|
||||
@@ -17,21 +19,19 @@ public class Water : Solid {
|
||||
}
|
||||
|
||||
protected override void Tick() {
|
||||
int randomDirection = GD.Randi() % 2 != 0 ? 1 : -1;
|
||||
randomDirection *= GD.Randi() % 2 != 0 ? 1 : 2;
|
||||
Vector2I randomDirection = RandomDirectionDown();
|
||||
if (randomDirection.Y != 0)
|
||||
randomDirection *= Vector2I.Left * (int)(GD.Randi() % MAX_VERTICAL_SPREAD);
|
||||
|
||||
if (Level.IsEmpty(Position + Vector2I.Down)) {
|
||||
Level.Swap(this, Position + Vector2I.Down);
|
||||
return;
|
||||
} else if (Level.IsEmpty(Position + Vector2I.Right * randomDirection)) {
|
||||
|
||||
} else if (Level.IsEmpty(Position + randomDirection)) {
|
||||
Level.Swap(this, Position + Vector2I.Right * randomDirection);
|
||||
return;
|
||||
} else if (Level.IsEmpty(Position + Vector2I.Right * randomDirection * -1)) {
|
||||
Level.Swap(this, Position + Vector2I.Right*randomDirection);
|
||||
return;
|
||||
|
||||
} else if (Level.IsEmpty(Position + randomDirection)) {
|
||||
Level.Swap(this, Position + Vector2I.Right * randomDirection * VERTICAL_OPPOSITE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user