public void InsertStaticNumberWalls() { int topRow = FindTopRow(false) + 20; if (lastInsertedStaticNumberWallHeight < topRow) { for (var row = lastInsertedStaticNumberWallHeight; row < topRow; row++) { if (row % staticNumberWallOffset == 0) { var newSeparetor = new GameObject(); newSeparetor.name = "separator_" + row; for (var a = -1; a < width + 20; a++) { var spawnPos = new Vector3((a * spacing) - 10, (row - 1) * spacing, 1); var wallBlock = Instantiate(blockPrefab, spawnPos, Quaternion.identity); wallBlock.transform.localScale = new Vector3(1, 0.1f, 0.1f); wallBlock.transform.SetParent(newSeparetor.transform); wallBlock.GetComponent <Renderer>().material = matWall; wallBlock.GetComponent <BlockScript>().UpdatePosition(spawnPos, 3f); } newSeparetor.transform.SetParent(levelBlocksParent.transform); var number = DigitType.InstantiateNumber(row, new Vector3(-4, row - 0.5f, 0), blockPrefab); number.transform.SetParent(numbersParent.transform); number.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); number.transform.localRotation = Quaternion.Euler(new Vector3(0, -10f, 0)); lastInsertedStaticNumberWallHeight = topRow; } } } }
public static void RadixSortAndBuildBack(Queue <int>[] queues, int[] nums, DigitType enumValue) { if (enumValue == DigitType.NotSupported) { return; } for (int i = 0; i < nums.Length; i++) { int queueIndex = FindQueueIndex(nums[i], enumValue); queues[queueIndex].Enqueue(nums[i]); } int x = 0; for (int i = 0; i < queues.Length; i++) { while (queues[i].Count > 0) { nums[x++] = queues[i].Dequeue(); } } RadixSortAndBuildBack(queues, nums, Next(enumValue)); }
private static void RSort(QueueMy <int>[] queues, int[] items, DigitType digitType) { int num; if (digitType == DigitType.Ones) { for (int i = 0; i < items.Length; i++) { var tempdata = items[i]; num = tempdata % 10; queues[num].EnQueue(tempdata); } } else { for (int i = 0; i < items.Length; i++) { var tempdata = items[i]; num = tempdata / 10; queues[num].EnQueue(tempdata); } } int index = 0; for (int i = 0; i < 10; i++) { while (queues[i].Count > 0) { items[index] = queues[i].DeQueue(); index++; } } }
private static int FindQueueIndex(int value, DigitType enumValue) { int index = 0; int tempValue = 0; switch (enumValue) { case DigitType.One: index = value > 0 ? value % 10 : 0; break; case DigitType.Ten: tempValue = value > 10 ? value % 100 : 0; index = tempValue / 10; break; case DigitType.Hundred: tempValue = value > 100 ? value % 1000 : 0; index = tempValue / 100; break; case DigitType.Thousand: tempValue = value > 1000 ? value % 10000 : 0; index = tempValue / 1000; break; case DigitType.TenThousand: tempValue = value > 10000 ? value % 100000 : 0; index = tempValue / 10000; break; case DigitType.HundredThousand: tempValue = value > 100000 ? value % 1000000 : 0; index = tempValue / 100000; break; case DigitType.Million: tempValue = value > 1000000 ? value % 10000000 : 0; index = tempValue / 1000000; break; case DigitType.TenMillion: tempValue = value > 10000000 ? value % 100000000 : 0; index = tempValue / 10000000; break; case DigitType.Billion: tempValue = value > 100000000 ? value % 1000000000 : 0; index = tempValue / 100000000; break; } return(index); }
public static DigitType Next(DigitType curr) { if (!typeof(DigitType).IsEnum) { throw new ArgumentException(string.Format("Argument {0} is not an Enum", typeof(DigitType).FullName)); } DigitType[] arr = (DigitType[])Enum.GetValues(typeof(DigitType)); int index = Array.IndexOf <DigitType>(arr, curr) + 1; return((arr.Length == index) ? arr[0] : arr[index]); }
public static void RSort(Queue[] que, int[] n, DigitType digit) { int snum; for (int i = 0; i <= n.GetUpperBound(0); i++) { if (digit == DigitType.ones) { snum = n[i] % 10; } else { snum = n[i] / 10; } que[snum].EnQueue(n[i]); } }
static void RSort(Queue[] que, int[] n, DigitType digit) { int snum; for (int x = 0; x <= n.GetUpperBound(0); x++) { if (digit == DigitType.ones) { snum = n[x] % 10; } else { snum = n[x] / 10; } que[snum].Enqueue(n[x]); } }
private static void RSort(Queue[] que, int[] arr, DigitType digit) { int snum; for (int i = 0; i < arr.Length; i++) { if (digit == DigitType.ones) { snum = arr[i] % 10; } else { snum = arr[i] / 10; } que[snum].Enqueue(arr[i]); } }
static void RSort(Queue[] numQueue, int[] nums, DigitType digitType) { int qIndex; for (int i = 0; i <= nums.GetUpperBound(0); i++) { if (digitType == DigitType.ones) { qIndex = nums[i] % 10; } else { qIndex = nums[i] / 10; } numQueue[qIndex].Enqueue(nums[i]); } }
/// <summary> /// Returns a <see cref="System.String" /> that represents this instance with DigitType flags. /// </summary> /// <param name="digitType">DigitType flags</param> /// <param name="truncate">Set true if need trim right digit</param> /// <returns>Returns a <see cref="System.String" /> that represents this instance with DigitType flags.</returns> public string ToString(DigitType digitType, bool truncate = false) { var builder = new StringBuilder(); if ((digitType & DigitType.Major) > 0) { builder.Append(this.Major); } else if (digitType > DigitType.Major || !truncate) { builder.Append(0); } if ((digitType & DigitType.Minor) > 0) { builder.AppendFormat(".{0}", this.Minor); } else if (digitType > DigitType.Minor || !truncate) { builder.Append(".0"); } if ((digitType & DigitType.Patch) > 0) { builder.AppendFormat(".{0}", this.Patch); } else if (digitType > DigitType.Patch || !truncate) { builder.Append(".0"); } if ((digitType & DigitType.Prerelease) > 0) { builder.AppendFormat("-{0}", this.Prerelease); } if ((digitType & DigitType.Build) > 0) { builder.AppendFormat("+{0}", this.Build); } return(builder.ToString()); }
public static void RSort(Queue[] que, int[] n, DigitType digit) { int snum; for (int i = 0; i < n.Length; i++) { //int temp = n.GetUpperBound(0); //Console.WriteLine(temp); if (digit == DigitType.ones) { snum = n[i] % 10; } else { snum = n[i] / 10; } que[snum].Enqueue(n[i]); } }
} //显示数组 /// <summary> /// 基数排序入队( /// <param name="que">To 存放数据的队列,</param> /// <param name="n">From 待排序的数组,</param> /// <param name="digit">位数标志)</param> /// </summary> static void RSort(Queue[] que, int[] n, DigitType digit) { // 基数排序入队 // 用 RSort 子程序来传递队列数组、整数的数组以及一个描述符(位数标志)。此描述符会告诉子程序是对个位上的数字还是 // 对十位上的数字进行排序。如果排序是基于个位上的数字,那么程序计算的数字就是这个整数对 10 进行取模运算 // 后的余数。如果排序是基于十位上的数字,那么程序计算的数字则是对这个整数除以 10(按照整除的方法)所取得 // 的整数商。 int snum; //临时数据区 for (int x = 0; x <= n.GetUpperBound(0); x++) { if (digit == DigitType.ones) { snum = n[x] % 10; } else { snum = n[x] / 10; } que[snum].Enqueue(n[x]); //入队 } }//基数排序入队
public static void _RadixSort(Queue[] q, int[] n, DigitType digit) { Display(n); for (int x = 0; x <= n.GetUpperBound(0); x++) { int snum; if (digit == DigitType.ones) { snum = n[x] % 10; } else { snum = n[x] / 10; } q[snum].Enqueue(n[x]); } Build(q, n); Display(n); }
public Word(string text = "", double num = 0, DigitType digitType = DigitType.Unknown) { this.Text = text; this.Num = num; this.DigitType = digitType; }
// Use this for initialization void Start() { var number = DigitType.InstantiateNumber(1234567890, new Vector3(0, 0, 0), blockPrefab); }
public void UpdateDigits(GameTime gameTime) { TimeSpan span = fGoalDate - DateTime.Now; int days = 0; int hours = 0; int minutes = 0; int seconds = 0; if (span.TotalSeconds > 0) { days = span.Days; hours = span.Hours; minutes = span.Minutes; seconds = span.Seconds; if (days > 999) { days = 999; hours = 99; minutes = 99; seconds = 99; } } DigitType colonType = DigitType.colon1; if ((seconds % 2) == 1) { colonType = DigitType.colon2; } int days1 = days / 100; int days2 = (days / 10) % 10; int days3 = days % 10; int hours1 = hours / 10; int hours2 = hours % 10; int minutes1 = minutes / 10; int minutes2 = minutes % 10; int seconds1 = seconds / 10; int seconds2 = seconds % 10; int index = 0; fCurrentDigits[index++] = (DigitType)days1; fCurrentDigits[index++] = (DigitType)days2; fCurrentDigits[index++] = (DigitType)days3; fCurrentDigits[index++] = colonType; fCurrentDigits[index++] = (DigitType)hours1; fCurrentDigits[index++] = (DigitType)hours2; fCurrentDigits[index++] = colonType; fCurrentDigits[index++] = (DigitType)minutes1; fCurrentDigits[index++] = (DigitType)minutes2; fCurrentDigits[index++] = colonType; fCurrentDigits[index++] = (DigitType)seconds1; fCurrentDigits[index++] = (DigitType)seconds2; //int milliseconds = gameTime.TotalGameTime.Milliseconds; //double f = milliseconds / 1000.0f; int x0 = SIZE * SEGMENTS_X / 2; //int y0 = SIZE * SEGMENTS_X / 2; //if ((seconds1%2)==0) //{ // y0 = Height - SIZE * SEGMENTS_X; //} for (int digitIndex = 0; digitIndex < fCurrentDigits.Length; digitIndex++) { int ox = Width / 2 + (SIZE * SEGMENTS_X) * (digitIndex - 6); int y0 = SIZE * SEGMENTS_X / 2; int ms = gameTime.TotalGameTime.Seconds * 1000 + gameTime.TotalGameTime.Milliseconds + 50 * digitIndex; ms = ms % 60000; if (ms > 30000) { y0 = Height - SIZE * SEGMENTS_X; } DigitType dType = fCurrentDigits[digitIndex]; MyParticles particles = fParticles[digitIndex]; LineConnector connector = GetDigit(dType); if (connector != null) { var points = connector.DistributePoints(particles.Count, 0); for (int i = 0; i < points.Count; i++) { var particle = particles[i]; var point = points[i]; particle.Destination = new Vector2(x0 + ox + point.X, y0 + point.Y); } } } }
private LineConnector GetDigit(DigitType digit) { int ox = -3; int oy = -3; int dx = SIZE; int dy = SIZE; if (fDigits[(int)digit] == null) { LineConnector lc = new LineConnector(); fDigits[(int)digit] = lc; switch (digit) { case DigitType.digit0: lc.Lines.Add(new Line()); lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (1 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (6 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (6 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); break; case DigitType.digit1: lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((2 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((3 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((3 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((2 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((2 + ox) * dx, (0 + oy) * dy)); break; case DigitType.digit2: lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (6 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (6 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); break; case DigitType.digit3: lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (6 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (6 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); break; case DigitType.digit4: lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); break; case DigitType.digit5: lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (6 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (6 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); break; case DigitType.digit6: lc.Lines.Add(new Line()); lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((1 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (3 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (4 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (4 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (6 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (6 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); break; case DigitType.digit7: lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); break; case DigitType.digit8: lc.Lines.Add(new Line()); lc.Lines.Add(new Line()); lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (1 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (3 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (3 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); lc.Lines[2].Points.Add(new Point((1 + ox) * dx, (4 + oy) * dy)); lc.Lines[2].Points.Add(new Point((4 + ox) * dx, (4 + oy) * dy)); lc.Lines[2].Points.Add(new Point((4 + ox) * dx, (6 + oy) * dy)); lc.Lines[2].Points.Add(new Point((1 + ox) * dx, (6 + oy) * dy)); lc.Lines[2].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); break; case DigitType.digit9: lc.Lines.Add(new Line()); lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (0 + oy) * dy)); lc.Lines[0].Points.Add(new Point((5 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (7 + oy) * dy)); lc.Lines[0].Points.Add(new Point((4 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (4 + oy) * dy)); lc.Lines[0].Points.Add(new Point((0 + ox) * dx, (0 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (1 + oy) * dy)); lc.Lines[1].Points.Add(new Point((4 + ox) * dx, (3 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (3 + oy) * dy)); lc.Lines[1].Points.Add(new Point((1 + ox) * dx, (1 + oy) * dy)); break; case DigitType.colon1: lc.Lines.Add(new Line()); lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((2 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((2 + ox) * dx, (3 + oy) * dy)); lc.Lines[1].Points.Add(new Point((2 + ox) * dx, (4 + oy) * dy)); lc.Lines[1].Points.Add(new Point((2 + ox) * dx, (6 + oy) * dy)); break; case DigitType.colon2: lc.Lines.Add(new Line()); lc.Lines.Add(new Line()); lc.Lines[0].Points.Add(new Point((3 + ox) * dx, (1 + oy) * dy)); lc.Lines[0].Points.Add(new Point((3 + ox) * dx, (3 + oy) * dy)); lc.Lines[1].Points.Add(new Point((3 + ox) * dx, (4 + oy) * dy)); lc.Lines[1].Points.Add(new Point((3 + ox) * dx, (6 + oy) * dy)); break; default: fDigits[(int)digit] = null; break; } } return(fDigits[(int)digit]); }
internal void method_1(DigitType A_0) { this.digitType_0 = A_0; }