added simple sleep state for elements

refactoring
This commit is contained in:
2024-03-23 18:47:24 +01:00
parent 015f86cec1
commit d44412c666
9 changed files with 76 additions and 41 deletions

View File

@@ -61,7 +61,8 @@ public class Level {
int Y = Mathf.Clamp(y + j, 0, SizeY-1);
object o = Activator.CreateInstance(type, X, Y, _this);
_elements[X,Y] = o as Element;
if (_elements[X,Y].GetType() != type)
_elements[X,Y] = o as Element;
}
}
}
@@ -75,7 +76,7 @@ public class Level {
return mImage;
}
public void Swap(Element what, Element swapTo) {
private void Swap(Element what, Element swapTo) {
Element swap = new Element(what);
if (what == null || swapTo == null) return;
@@ -85,6 +86,11 @@ public class Level {
swapTo.Position = swap.Position;
_elements[swap.Position.X, swap.Position.Y] = swapTo;
what.Active = true;
swapTo.Active = true;
what.LastMove = _frame;
swapTo.LastMove = _frame;
}
public void Swap(Element what, Vector2I pos) {