private bool IsCellActive(FractionDifficulty d, int idx) { bool active; if (solvedPerc[d] < 0.5f) { active = idx < FloatMath.Ceiling(solvedPerc[d] * 15); } else { active = idx <= FloatMath.Floor(solvedPerc[d] * 15); } if (FlickerTime > COLLAPSE_TIME) { return(active); } else { if (active) { return(FloatMath.GetRandom() < (0.5f + FloatMath.FunctionEaseInOutCubic(FlickerTime / COLLAPSE_TIME) / 2f)); } else { return(FloatMath.GetRandom() < (0.5f - FloatMath.FunctionEaseInOutCubic(FlickerTime / COLLAPSE_TIME) / 2f)); } } }
public void RegisterBlockedLine(FPoint start, FPoint end) { var delta = end - start; var angle = delta.ToAngle(); if ((angle + FloatMath.RAD_POS_045) % FloatMath.RAD_POS_180 < FloatMath.RAD_POS_090) { // HORZ if (start.X > end.X) { var tmp = start; start = end; end = tmp; } int firstX = FloatMath.Ceiling((start.X - 8f) / GDConstants.TILE_WIDTH); int lastX = FloatMath.Floor((end.X + 8f) / GDConstants.TILE_WIDTH); int lastoy = FloatMath.Round((start.Y + (end.Y - start.Y) * ((firstX * GDConstants.TILE_WIDTH - start.X) / (end.X - start.X))) / GDConstants.TILE_WIDTH); for (int ox = firstX + 1; ox <= lastX; ox++) { var oy = FloatMath.Round((start.Y + (end.Y - start.Y) * ((ox * GDConstants.TILE_WIDTH - start.X) / (end.X - start.X))) / GDConstants.TILE_WIDTH); if (oy != lastoy) { BlockSegmentVert(ox + MAX_EXTENSION_X - 1, lastoy + MAX_EXTENSION_Y, oy + MAX_EXTENSION_Y); } BlockSegmentHorz(oy + MAX_EXTENSION_Y, ox - 1 + MAX_EXTENSION_X, ox + MAX_EXTENSION_X); lastoy = oy; } } else { // VERT if (start.Y > end.Y) { var tmp = start; start = end; end = tmp; } int firstY = FloatMath.Ceiling((start.Y - 8f) / GDConstants.TILE_WIDTH); int lastY = FloatMath.Floor((end.Y + 8f) / GDConstants.TILE_WIDTH); int lastox = FloatMath.Round((start.X + (end.X - start.X) * ((firstY * GDConstants.TILE_WIDTH - start.Y) / (end.Y - start.Y))) / GDConstants.TILE_WIDTH); for (int oy = firstY + 1; oy <= lastY; oy++) { var ox = FloatMath.Round((start.X + (end.X - start.X) * ((oy * GDConstants.TILE_WIDTH - start.Y) / (end.Y - start.Y))) / GDConstants.TILE_WIDTH); if (ox != lastox) { BlockSegmentHorz(oy + MAX_EXTENSION_Y - 1, lastox + MAX_EXTENSION_X, ox + MAX_EXTENSION_X); } BlockSegmentVert(ox + MAX_EXTENSION_X, oy - 1 + MAX_EXTENSION_Y, oy + MAX_EXTENSION_Y); lastox = ox; } } }