//gets swipe data from swipemanager and decides what to do public void setSwipe(SwipeData _data) { if (isSwipeAvailable) { deactivateSwipe(); GridZone _zone = activeGrid; List <Cube> _cubeGrid = new List <Cube>(_zone.getMovableCubes()); Cube[] _orderedCubes = orderCubeList(_data, _cubeGrid); //Order cubes decideMovement(_data, _orderedCubes); //Calculate coordinate to move for each cube } }
//Compare all cube coordinates by true positions of stage //return true if all cube coordinates match by true positions which means stage completed //else return false which means stage is not completed private bool checkCubeStatus(StageCubeData _cubeData, GridZone _zone) { int _trueCount = 0; foreach (Vector2Int _trueCoord in _cubeData.cubePlacements) { foreach (var _cube in _zone.getMovableCubes()) { if (_trueCoord == _cube.gridCoord) { _trueCount++; } } } if (_trueCount == _cubeData.cubePlacements.Length) { return(true); } else { return(false); } }