void Update()
{
for (int y = 0; y < texture.height; y++)
{
for (int x = 0; x < texture.width; x++)
{
if (CellTypeDatabase.instance.colors.Contains(texture.GetPixel(x, y)) && x != texture.width - 1 && x != 0 && y != texture.height - 1 && y != 0)
{
CellObject cell = CellTypeDatabase.instance.cellObjects[CellTypeDatabase.instance.colors.IndexOf(texture.GetPixel(x, y))];
Color pixel = texture.GetPixel(x, y);
if (cell.useGravity)
{
if (texture.GetPixel(x, y - cell.gravity) == Color.white || texture.GetPixel(x, y - cell.gravity) == CellTypeDatabase.instance.cellObjects[2].color)
{
texture.SetPixel(x, y, texture.GetPixel(x, y - cell.gravity));
texture.SetPixel(x, y - cell.gravity, pixel);
}
else if (texture.GetPixel(x - cell.gravity, y - cell.gravity) == Color.white || texture.GetPixel(x - cell.gravity, y - cell.gravity) == CellTypeDatabase.instance.cellObjects[2].color)
{
texture.SetPixel(x, y, texture.GetPixel(x - cell.gravity, y - cell.gravity));
texture.SetPixel(x - cell.gravity, y - cell.gravity, pixel);
}
else if (texture.GetPixel(x + cell.gravity, y - cell.gravity) == Color.white || texture.GetPixel(x + cell.gravity, y - cell.gravity) == CellTypeDatabase.instance.cellObjects[2].color)
{
texture.SetPixel(x, y, texture.GetPixel(x + cell.gravity, y - cell.gravity));
texture.SetPixel(x + cell.gravity, y - cell.gravity, pixel);
}
}
}
else
{
continue;
}
}
}
texture.Apply();