/// <summary> /// Convert number that is less Billion to string /// </summary> /// <param name="language"></param> /// <param name="number"></param> /// <param name="cameFrom"></param> /// <returns></returns> private string CalculateStringMillions(Language language, int number, CameFrom cameFrom = CameFrom.Millions) { string numberStr = String.Empty; NumberSringView internalView = NumberSringView.Default; if (number < million) { numberStr = CalculateStringThousands(language, number); } else if (number < billion) { int millions = number - number % million; int thousands = number - millions; millions = millions / million; if (language == Language.Ukrainian) { if (millions.ToString().EndsWith("1") && !millions.ToString().EndsWith("11")) { internalView = NumberSringView.Single; } else if ((millions.ToString().EndsWith("2") || millions.ToString().EndsWith("3") || millions.ToString().EndsWith("4")) && !(millions.ToString().EndsWith("12") || millions.ToString().EndsWith("13") || millions.ToString().EndsWith("14"))) { internalView = NumberSringView.Plural; } } numberStr = CalculateStringHundreds(language, millions, CameFrom.Millions) + " " + convertNumbDictionary.ConvertDictionary[million].langDictionary[language].NumFormsDictionary[internalView] + " " + CalculateStringThousands(language, thousands); } return(numberStr); }
/// <summary> /// Convert number that is less million to string /// </summary> /// <param name="language"></param> /// <param name="number"></param> /// <param name="cameFrom"></param> /// <returns></returns> private string CalculateStringThousands(Language language, int number, CameFrom cameFrom = CameFrom.Thousans) { string numberStr = String.Empty; NumberSringView internalView = NumberSringView.Default; if (number < 1000) { numberStr = CalculateStringHundreds(language, number); } else if (number < million) { int thousands = number - number % 1000; int hundreds = number - thousands; thousands = thousands / 1000; if (language == Language.Ukrainian) { if (thousands.ToString().EndsWith("1") && !thousands.ToString().EndsWith("11")) { internalView = NumberSringView.Single; } else if ((thousands.ToString().EndsWith("2") || thousands.ToString().EndsWith("3") || thousands.ToString().EndsWith("4")) && !(thousands.ToString().EndsWith("12") || thousands.ToString().EndsWith("13") || thousands.ToString().EndsWith("14"))) { internalView = NumberSringView.Plural; } } numberStr = CalculateStringHundreds(language, thousands) + " " + convertNumbDictionary.ConvertDictionary[1000].langDictionary[language].NumFormsDictionary[internalView] + " " + CalculateStringHundreds(language, hundreds); } return(numberStr); }
public void Move() { if (_currentRail is Dock) { return; } if (IsMovingAway()) { return; } int direction = _random.Next(1, 8); switch (direction) { case 1: // up CameFrom = GetOpposite(Direction.Up); if (CameFrom.Equals(Direction.Up)) { Move(_currentRail.Below); } else { Move(_currentRail.Above); } break; case 2: // down CameFrom = GetOpposite(Direction.Down); Move(_currentRail.Below); break; case 3: // left CameFrom = GetOpposite(Direction.Left); if (_currentRail.Previous.Previous == null) { Move(); } Move(_currentRail.Previous); break; case 4: // right CameFrom = GetOpposite(Direction.Right); Move(_currentRail.Next); break; default: Move(_currentRail.Below); break; } }
/// <summary> /// Convert number that is less 1000 to string /// </summary> /// <param name="language"></param> /// <param name="number"></param> /// <param name="cameFrom"></param> /// <returns></returns> private string CalculateStringHundreds(Language language, int number, CameFrom cameFrom = CameFrom.Hundreds) { NumberSringView view = NumberSringView.Default; string numberStr = String.Empty; if (number <= 100) { numberStr = CalculateStringDozens(language, number, cameFrom); } else { int hundreds = number - number % 100; numberStr = convertNumbDictionary.ConvertDictionary[hundreds].langDictionary[language].NumFormsDictionary[view] + " " + CalculateStringDozens(language, number - hundreds, cameFrom); } return(numberStr); }
/// <summary> /// Convert number that is less 100 to string /// </summary> /// <param name="language"></param> /// <param name="number"></param> /// <param name="cameFrom"></param> /// <returns></returns> private string CalculateStringDozens(Language language, int number, CameFrom cameFrom = CameFrom.Dozens) { NumberSringView internalView = NumberSringView.Default; NumberSringView intsInternalView = NumberSringView.Default; NumberSringView dozensInternalView = NumberSringView.Default; String internalSeparator = " "; string numberStr = String.Empty; if (number <= 20) { if (language == Language.Ukrainian && (cameFrom == CameFrom.Millions || cameFrom == CameFrom.Billions)) { if (number == 1 || number == 2) { internalView = NumberSringView.Other; } } numberStr = convertNumbDictionary.ConvertDictionary[number].langDictionary[language].NumFormsDictionary[internalView]; } else if (number <= 100) { int dozrens = number - (number % 10); int ints = (number % 10); if (language == Language.English && ints != 0) { dozensInternalView = NumberSringView.Plural; internalSeparator = String.Empty; } if (language == Language.Ukrainian && (cameFrom == CameFrom.Millions || cameFrom == CameFrom.Billions)) { if (ints == 1 || ints == 2) { intsInternalView = NumberSringView.Other; } } numberStr = convertNumbDictionary.ConvertDictionary[dozrens].langDictionary[language].NumFormsDictionary[dozensInternalView] + internalSeparator + convertNumbDictionary.ConvertDictionary[ints].langDictionary[language].NumFormsDictionary[intsInternalView]; } return(numberStr); }
private int getDistanceToPointsSpot(Point point, int distance, CameFrom from) { if (distance > maxDist) return distance; if (World.Instance.IsSpot(point, World.DOT) || World.Instance.IsSpot(point, World.POWER)) { return distance; } else { distance++; int tempdistance; int lowestdistance = Int32.MaxValue; if (World.Instance.CanLeft(point)) { if (!World.Instance.IsThereAGhostAtPixel(GridToPixel(point)) && from != CameFrom.Right) { tempdistance = getDistanceToPointsSpot(new Point(point.X - 1, point.Y), distance, CameFrom.Left); } else tempdistance = Int32.MaxValue; if (tempdistance < lowestdistance) lowestdistance = tempdistance; } if (World.Instance.CanRight(point)) { if (!World.Instance.IsThereAGhostAtPixel(GridToPixel(point)) && from != CameFrom.Left) { tempdistance = getDistanceToPointsSpot(new Point(point.X + 1, point.Y), distance, CameFrom.Right); } else tempdistance = Int32.MaxValue; if (tempdistance < lowestdistance) lowestdistance = tempdistance; } if (World.Instance.CanDown(point)) { if (!World.Instance.IsThereAGhostAtPixel(GridToPixel(point)) && from != CameFrom.Up) { tempdistance = getDistanceToPointsSpot(new Point(point.X, point.Y + 1), distance, CameFrom.Down); } else tempdistance = Int32.MaxValue; if (tempdistance < lowestdistance) lowestdistance = tempdistance; } if (World.Instance.CanUp(point)) { if (!World.Instance.IsThereAGhostAtPixel(GridToPixel(point)) && from != CameFrom.Down) { tempdistance = getDistanceToPointsSpot(new Point(point.X, point.Y - 1), distance, CameFrom.Up); } else tempdistance = Int32.MaxValue; if (tempdistance < lowestdistance) lowestdistance = tempdistance; } return lowestdistance; } }