public AudioClip GetAudioClip(CutDirection direction) { int rand = UnityEngine.Random.Range(1, 10); var dir = CutDirectionToSound(direction); return(BeatHitSounds.ToList().First(a => a.name == $"hit{rand}{dir}")); }
public static CutDirection Invert(this CutDirection cutDirection) { switch (cutDirection) { case CutDirection.Up: return(CutDirection.Down); case CutDirection.Down: return(CutDirection.Up); case CutDirection.Left: return(CutDirection.Right); case CutDirection.Right: return(CutDirection.Left); case CutDirection.UpLeft: return(CutDirection.DownRight); case CutDirection.UpRight: return(CutDirection.DownLeft); case CutDirection.DownLeft: return(CutDirection.UpRight); case CutDirection.DownRight: return(CutDirection.UpLeft); case CutDirection.Any: return(CutDirection.Any); default: throw new ArgumentOutOfRangeException(nameof(cutDirection), cutDirection, null); } }
public StringParser CutToLast(string search, CutDirection dir, bool CutSearch, int add) { if (dir == CutDirection.Left) { if (CutSearch) { return(new StringParser(this.html.Substring(this.html.LastIndexOf(search) + search.Length + add))); } else { return(new StringParser(this.html.Substring(this.html.LastIndexOf(search) + add))); } } else { if (CutSearch) { return(new StringParser(this.html.Substring(0, this.html.LastIndexOf(search) - add))); } else { return(new StringParser(this.html.Substring(0, this.html.LastIndexOf(search) + search.Length - add))); } } }
public StringParser CutToFirst(char search, CutDirection dir, bool CutSearch, int add) { if (dir == CutDirection.Left) { if (CutSearch) { return(new StringParser(this.html.Substring(this.html.IndexOf(search) + 1 + add))); } else { return(new StringParser(this.html.Substring(this.html.IndexOf(search) + add))); } } else { int a = this.html.IndexOf("</a>"); if (CutSearch) { return(new StringParser(this.html.Substring(0, this.html.IndexOf(search) - add))); } else { return(new StringParser(this.html.Substring(0, this.html.IndexOf(search) + 1 - add))); } } }
public void Set(double _time, int _lineIndex, int _lineLayer, ItemType _type, CutDirection _cutDirection) { this._time = (float)_time; this._lineIndex = _lineIndex; this._lineLayer = _lineLayer; this._type = (int)_type; this._cutDirection = (int)_cutDirection; var image = gameObject.GetComponent <Image>(); switch (_type) { case ItemType.Bomb: image.sprite = bombImage; image.color = Color.black; break; case ItemType.Red: image.color = Color.red; break; case ItemType.Blue: image.color = Color.blue; break; default: break; } }
public Note( float time, Hand hand, CutDirection cutDirection, HorizontalPosition horizontalPosition, VerticalPosition verticalPosition) { Time = time; Hand = hand; CutDirection = cutDirection; HorizontalPosition = horizontalPosition; VerticalPosition = verticalPosition; }
public static IEnumerable <Note> ReversedDouble( float time, CutDirection cutDirection, HorizontalPosition leftHorizontalPosition, VerticalPosition verticalPosition) { if (leftHorizontalPosition == HorizontalPosition.Left) { throw new ArgumentOutOfRangeException(nameof(leftHorizontalPosition)); } return(new[] { new Note(time, Hand.Left, cutDirection, leftHorizontalPosition, verticalPosition), new Note(time, Hand.Right, cutDirection, leftHorizontalPosition - 1, verticalPosition) }); }
public static IEnumerable <Note> OppositeDownUp( float time, CutDirection leftCutDirection, HorizontalPosition leftHorizontalPosition, VerticalPosition verticalPosition) { if (leftHorizontalPosition == HorizontalPosition.Right) { throw new ArgumentOutOfRangeException(nameof(leftHorizontalPosition)); } return(new [] { new Note(time, Hand.Left, leftCutDirection, leftHorizontalPosition, verticalPosition), new Note(time, Hand.Right, leftCutDirection.Invert(), leftHorizontalPosition + 1, verticalPosition) }); }
public NoteDirection ToDirectionEnum(CutDirection cutDirection) { switch (cutDirection) { case CutDirection.Up: return(NoteDirection.Up); case CutDirection.Down: return(NoteDirection.Down); case CutDirection.Left: return(NoteDirection.Left); case CutDirection.Right: return(NoteDirection.Right); case CutDirection.UpLeft: return(NoteDirection.UpLeft); case CutDirection.UpRight: return(NoteDirection.UpRight); case CutDirection.DownLeft: return(NoteDirection.DownLeft); case CutDirection.DownRight: return(NoteDirection.DownRight); case CutDirection.Any: //can happen if the last note was any and now we determine the next possible ones switch (rand.Next(4)) { case 0: return(NoteDirection.Up); case 1: return(NoteDirection.Right); case 2: return(NoteDirection.Down); case 3: return(NoteDirection.Left); default: throw new ArgumentOutOfRangeException(); } default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Searches for the first occurrence of a substring in this instance and removes everything on the right or left of that search-string. /// </summary> /// <param name="html">The string in which the substring should be located.</param> /// <param name="search">The substring to locate.</param> /// <param name="dir">Determines if the left or right part of the string should be removed.</param> /// <param name="CutSearch">true, if <paramref name="search"/> should be removed from the result; false, otherwise.</param> /// <param name="add">Cuts an additional number of characters from the resulting string. These are removed from the end where text is cut.</param> /// <returns>A copy of <paramref name="html"/> reduced to a substring starting from or ending at the first occurrence of <paramref name="search"/>.</returns> public static string CutToFirst(this string html, string search, CutDirection dir, bool CutSearch, int add) { int index = html.IndexOf(search); if (index == -1) throw new ArgumentOutOfRangeException("The provided string \"search\" could not be located."); if (dir == CutDirection.Left) { index += (CutSearch ? search.Length : 0) + add; return html.Substring(index); } else { index += (CutSearch ? 0 : search.Length) - add; return html.Substring(0, index); } }
public StringParser CutToFirst(string search, CutDirection dir, bool CutSearch, int add) { if (dir == CutDirection.Left) { if (CutSearch) return new StringParser(this.html.Substring(this.html.IndexOf(search) + search.Length + add)); else return new StringParser(this.html.Substring(this.html.IndexOf(search) + add)); } else { if (CutSearch) return new StringParser(this.html.Substring(0, this.html.IndexOf(search) - add)); else return new StringParser(this.html.Substring(0, this.html.IndexOf(search) + search.Length - add)); } }
public StringParser CutToLast(char search, CutDirection dir, bool CutSearch, int add) { if (dir == CutDirection.Left) { if (CutSearch) return new StringParser(this.html.Substring(this.html.LastIndexOf(search) + 1 + add)); else return new StringParser(this.html.Substring(this.html.LastIndexOf(search) + add)); } else { if (CutSearch) return new StringParser(this.html.Substring(0, this.html.LastIndexOf(search) - add)); else return new StringParser(this.html.Substring(0, this.html.LastIndexOf(search) + 1 - add)); } }
/// <summary> /// Searches for the first occurrence of a character in this instance and removes everything on the right or left of that character. /// </summary> /// <param name="html">The string in which the character should be located.</param> /// <param name="search">The character to locate.</param> /// <param name="dir">Determines if the left or right part of the string should be removed.</param> /// <param name="CutSearch">true, if <paramref name="search"/> should be removed from the result; false, otherwise.</param> /// <param name="add">Cuts an additional number of characters from the resulting string. These are removed from the end where text is cut.</param> /// <returns>A copy of <paramref name="html"/> reduced to a substring starting from or ending at the first occurrence of <paramref name="search"/>.</returns> public static string CutToFirst(this string html, char search, CutDirection dir, bool CutSearch, int add) { int index = html.IndexOf(search); if (index == -1) { throw new ArgumentOutOfRangeException("The provided string \"search\" could not be located."); } if (dir == CutDirection.Left) { index += (CutSearch ? 1 : 0) + add; return(html.Substring(index)); } else { index += (CutSearch ? 0 : 1) - add; return(html.Substring(0, index)); } }
private string CutDirectionToSound(CutDirection direction) { var soundPostFix = String.Empty; switch (direction) { case CutDirection.NONDIRECTION: case CutDirection.TOP: case CutDirection.BOTTOM: break; case CutDirection.LEFT: soundPostFix = "left"; break; case CutDirection.RIGHT: soundPostFix = "right"; break; case CutDirection.TOPLEFT: soundPostFix = "left"; break; case CutDirection.TOPRIGHT: soundPostFix = "right"; break; case CutDirection.BOTTOMLEFT: soundPostFix = "left"; break; case CutDirection.BOTTOMRIGHT: soundPostFix = "right"; break; } return(soundPostFix); }
/// <summary> /// Searches for the first occurrence of a character in this instance and removes everything on the right or left of that character. /// </summary> /// <param name="html">The string in which the character should be located.</param> /// <param name="search">The character to locate.</param> /// <param name="dir">Determines if the left or right part of the string should be removed.</param> /// <param name="CutSearch">true, if <paramref name="search"/> should be removed from the result; false, otherwise.</param> /// <returns>A copy of <paramref name="html"/> reduced to a substring starting from or ending at the first occurrence of <paramref name="search"/>.</returns> public static string CutToFirst(this string html, char search, CutDirection dir, bool CutSearch) { return(CutToFirst(html, search, dir, CutSearch, 0)); }
public Note(double time, int line, int layer, NoteType type, CutDirection cutDirection) { _time = time; _lineIndex = line; _lineLayer = layer; _type = (int)type; _cutDirection = (int)cutDirection; }
/// <summary> /// Searches for the first occurrence of a substring in this instance and removes everything on the right or left of that search-string. /// </summary> /// <param name="html">The string in which the substring should be located.</param> /// <param name="search">The substring to locate.</param> /// <param name="dir">Determines if the left or right part of the string should be removed.</param> /// <param name="CutSearch">true, if <paramref name="search"/> should be removed from the result; false, otherwise.</param> /// <returns>A copy of <paramref name="html"/> reduced to a substring starting from or ending at the first occurrence of <paramref name="search"/>.</returns> public static string CutToFirst(this string html, string search, CutDirection dir, bool CutSearch) { return CutToFirst(html, search, dir, CutSearch, 0); }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog theDialog = new OpenFileDialog(); theDialog.Title = "Open Text File"; theDialog.Filter = "Level files|*.json"; theDialog.InitialDirectory = @"C:\"; if (theDialog.ShowDialog() == DialogResult.OK) { try { Stream myStream; if ((myStream = theDialog.OpenFile()) != null) { using (var sr = new StreamReader(myStream)) { // Insert code to read the stream here. var filedata = sr.ReadToEnd(); var data = new JavaScriptSerializer().Deserialize <Level>(filedata); //loop through notes CutDirection lastRed = CutDirection.ANY; CutDirection lastBlue = CutDirection.ANY; Note lastNote = null; double lastRedTime = 0.0; double lastBlueTime = 0.0; double timeDifference = double.Parse(timedifferenceTextBox.Text); int seed = seedTextBox.Text == "" ? 0 : int.Parse(seedTextBox.Text); bool position = randomPositionCheckBox.Checked; Random rand = new Random(seed); foreach (var note in data._notes) { //add random direction if (note._type == NoteColor.BLUE) { if (lastBlue == CutDirection.ANY) { int n = rand.Next(0, 9); lastBlue = (CutDirection)n; note._cutDirection = (CutDirection)n; } else if (lastBlueTime <= note._time - timeDifference) { if (lastNote._time >= note._time - .05) { //we need the same cut direction and we need it to follow the positions //right now make it go left or right int n = rand.Next(0, 2); lastBlue = (CutDirection)n + 2; note._cutDirection = (CutDirection)n + 2; //also make the previous note the same lastNote._cutDirection = (CutDirection)n + 2; } else { int n = rand.Next(0, 9); lastBlue = (CutDirection)n; note._cutDirection = (CutDirection)n; } } else { note._cutDirection = lastBlue; } lastBlueTime = note._time; } else if (note._type == NoteColor.RED) { if (lastRed == CutDirection.ANY) { int n = rand.Next(0, 9); lastRed = (CutDirection)n; note._cutDirection = (CutDirection)n; } else if (lastRedTime <= note._time - timeDifference) { if (lastNote._time >= note._time - .05) { //we need the same cut direction and we need it to follow the positions //right now make it go left or right int n = rand.Next(0, 2); lastRed = (CutDirection)n + 2; note._cutDirection = (CutDirection)n + 2; //also make the previous note the same lastNote._cutDirection = (CutDirection)n + 2; } else { int n = rand.Next(0, 9); lastRed = (CutDirection)n; note._cutDirection = (CutDirection)n; } } else { note._cutDirection = lastRed; } lastRedTime = note._time; } if (lastNote?._time >= note._time - .05) { //change the direction to left or right if (lastNote._type == note._type) { int dir = rand.Next(0, 2); note._cutDirection = (CutDirection)dir + 2; lastNote._cutDirection = note._cutDirection; } else { //change the direction to up or down int dir = rand.Next(0, 2); note._cutDirection = (CutDirection)dir; lastNote._cutDirection = note._cutDirection; } } lastNote = note; } //output the file StreamWriter sw = new StreamWriter(theDialog.FileName + ".new"); string d2 = new JavaScriptSerializer().Serialize(data); sw.Write(d2); sw.Flush(); sw.Close(); } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
public StringParser CutToFirst(string search, CutDirection dir, bool CutSearch) { return(CutToFirst(search, dir, CutSearch, 0)); }
public StringParser CutToFirst(string search, CutDirection dir, bool CutSearch) { return CutToFirst(search, dir, CutSearch, 0); }