public static MoveableUnit[] GetMoveableUnitPositions( List <Text> texts, NumberableUnitType numberableUnitType, int unitCount) { var unitPositions = new MoveableUnit[unitCount]; int unitCounter = -1; for (int i = 0; i < texts.Count; i++) { if (!CurrentTextIsMatchingType(texts, numberableUnitType, i)) { continue; } unitCounter++; unitPositions[unitCounter] = new MoveableUnit() { StartPosition = i }; if (PastTheFirstUnit( unitCounter)) { SetEndPositionOfPreviousItem(unitPositions, unitCounter, i); } if (IsLastUnit( unitCount, unitCounter)) { SetEndPositionOfFinalItem( texts, unitPositions); } } return(unitPositions); }
private static bool CurrentTextIsMatchingType(List <Text> texts, NumberableUnitType numberableUnitType, int i) { return((numberableUnitType == NumberableUnitType.Timer && texts[i].IsTimer) || (numberableUnitType == NumberableUnitType.Modifier && texts[i].IsModifier)); }