/// ------------------------------------------------------------------------------------ public SearchEngine(SearchQuery query) { CurrentSearchQuery = query; _errors.Clear(); try { var parser = new PatternParser(App.Project); SrchItemPatternGroup = parser.Parse(query.SearchItem, EnvironmentType.Item); EnvBeforePatternGroup = parser.Parse(query.PrecedingEnvironment, EnvironmentType.Before); EnvAfterPatternGroup = parser.Parse(query.FollowingEnvironment, EnvironmentType.After); } catch { var error = new SearchQueryValidationError( string.Format(GetPatternSyntaxErrorMsg(), App.kEmptyDiamondPattern)); _errors.Add(error); } m_srchItemStr = query.SearchItem; m_envBeforeStr = query.PrecedingEnvironment; m_envAfterStr = query.FollowingEnvironment; if (_errors != null && _errors.Count > 0) { query.Errors.AddRange(_errors); } }
public string ToJSON() { StringBuilder json = new StringBuilder("{"); json.Append("\"name\":\"" + name + "\","); json.Append("\"background\":" + BackgroundColor.ToJSON() + ","); json.Append("\"groups\":["); for (int i = 0; i < 4; i++) { PatternGroup group = i < Patterns.Count ? Patterns[i] : null; if (group == null) { json.Append("{},"); } else { json.Append("{"); json.Append("\"enabled\":" + (group.Enabled ? 1 : 0) + ","); json.Append("\"pattern\":"); json.Append(group.Pattern.ToJSON() + ","); json.Append("\"particle\":"); json.Append(group.Particle.ToJSON() + ","); json.Append("\"color\":" + group.Color.ToJSON()); json.Append("},"); } } json.Remove(json.Length - 1, 1); json.Append("]}"); return(json.ToString()); }
public void SameParameter() { var pattern = new PatternGroup(new Pattern <IEnumerable <GAny> >(), new Pattern <GAny>()); Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(int))); Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(bool))); Assert.IsFalse(pattern.Matches(typeof(int), typeof(IEnumerable <int>))); }
public void DifferentParameters() { var pattern = new PatternGroup(new Pattern <IEnumerable <GFrom> >(), new Pattern <GTo>()); Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(int))); Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(bool))); Assert.IsFalse(pattern.Matches(typeof(int), typeof(IEnumerable <int>))); }
public GroupMatching(PatternGroup group, Document document, IStemmer stemmer) { Group = group; Document = document; Stemmer = stemmer; Labels = new ConcurrentDictionary <string, bool>(); Captures = new ConcurrentDictionary <string, bool>(); }
internal GitIgnore(PatternGroup root, string workingDirectory, bool ignoreCase) { Debug.Assert(PathUtils.IsAbsolute(workingDirectory)); IgnoreCase = ignoreCase; WorkingDirectory = PathUtils.ToPosixDirectoryPath(workingDirectory); _workingDirectoryNoSlash = PathUtils.TrimTrailingSlash(WorkingDirectory); Root = root; }
public void ConstructWithOneParameter() { var group = new PatternGroup(new string[] { "a" }); Assert.Equal(new string[] { "a" }, group.IncludePatterns); Assert.Equal(0, group.ExcludePatterns.Count()); Assert.Equal(0, group.IncludeLiterals.Count()); Assert.Equal(0, group.ExcludePatternsGroup.Count()); }
public void ConstructWithThreeParameters() { var group = new PatternGroup(new string[] { "a", "b" }, new string[] { "C" }, new string[] { "d" }); Assert.Equal(new string[] { "a", "b" }, group.IncludePatterns); Assert.Equal(new string[] { "C" }, group.ExcludePatterns); Assert.Equal(new string[] { "d" }, group.IncludeLiterals); Assert.Equal(0, group.ExcludePatternsGroup.Count()); }
public PatternGroup(PatternGroup parent, string containingDirectory, ImmutableArray <Pattern> patterns) { Debug.Assert(PathUtils.IsPosixPath(containingDirectory)); Debug.Assert(PathUtils.HasTrailingSlash(containingDirectory)); Parent = parent; ContainingDirectory = containingDirectory; Patterns = patterns; }
public PatternGroup(PatternGroup p1, PatternGroup p2){ patterns = new List<Pattern> (); int i; for (i = 0; i<p1.patterns.Count; i++) { patterns.Add (p1.patterns[i]); } for (i = 0; i<p2.patterns.Count; i++) { patterns.Add (p2.patterns[i]); } }
public void WhereConditionIsPrimitive() { var pattern = new PatternGroup(new Pattern <IEnumerable <GFrom> >(), new Pattern <GTo>()); pattern.AddWhereCondition(x => x.IsPrimitive <GFrom>() && x.IsPrimitive <GTo>()); Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(bool))); Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(object))); Assert.IsFalse(pattern.Matches(typeof(IEnumerable <object>), typeof(int))); }
public void HasPatternsExaminesOptionalPatternGroup() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); group1.OptionalGroup.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new Variable("var"), new UriRef("http://example.com/object"))); Assert.AreEqual(true, group1.HasPatterns, "Group should have patterns"); Assert.AreEqual(false, group2.HasPatterns, "Group should not have patterns"); }
public void WhereConditionIsCastable() { var pattern = new PatternGroup(new Pattern <IEnumerable <GFrom> >(), new Pattern <GTo>()); pattern.AddWhereCondition(x => x.IsImplicitlyCastable <GFrom, GTo>()); Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(bool))); Assert.IsFalse(pattern.Matches(typeof(IEnumerable <int>), typeof(object))); Assert.IsTrue(pattern.Matches(typeof(IEnumerable <int>), typeof(double))); }
void Update() { if (webCamTexture.didUpdateThisFrame) { Color[] color = webCamTexture.GetPixels(); if (first == 0) { w = webCamTexture.width; h = webCamTexture.height; GameObject.Find("ResultLabel").GetComponent <Text> ().text = w + " x " + h; texture = new Texture2D(w, h); videoImage.texture = texture; videoImage.material.mainTexture = texture; } ImageProcessor processor = new ImageProcessor(w, h, webCamTexture, texture); Manager manager = GameObject.Find("Manager").GetComponent <Manager> (); int captSize = (int)(90 * (1 - manager.captureMax)) + 10; if (is_recording) { processor.ProcessImage(captSize, manager.minThr, manager.maxThr, manager.filterSize); is_recording = new TimeSpan(DateTime.Now.Ticks - startTime.Ticks).TotalSeconds <= 5; lastPattern = processor.FindLowLevelPattern(captSize, (int)(90 * manager.captureMin) + 10, GameObject.Find("Pattern Name").GetComponent <InputField> ().text); // manager.Types[GameObject.Find ("Type").GetComponent<Dropdown> ().value] if (lastPattern != null) { texturePat = new Texture2D(lastPattern.W, lastPattern.H); patternImage.texture = texturePat; patternImage.material.mainTexture = texturePat; } if (false) //lastPattern is PatternGroup) { { PatternGroup group = (PatternGroup)lastPattern; string s = "Groups: " + group.Count + "; "; for (int i = 0; i < group.Count; i++) { BoundingBox box = group.GetBox(i); s += box.MinX + ", " + box.MinY + ", " + box.MaxX + ", " + box.MaxY + "; "; } Debug.Log(s); } } else { texture.SetPixels(webCamTexture.GetPixels()); processor.DrawCaptureBox(captSize); } texture.Apply(); if (lastPattern != null) { ImageProcessor.DrawPattern(lastPattern, texturePat); texturePat.Apply(); } first++; } }
public void GetMentionedVariablesExaminesOptionalPatternGroup() { PatternGroup group1 = new PatternGroup(); group1.OptionalGroup.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new Variable("var"), new UriRef("http://example.com/object"))); IList variables = group1.GetMentionedVariables(); Assert.AreEqual(1, variables.Count, "Should be one variable"); Assert.AreEqual(((Variable)variables[0]).Name, "var", "Variable is called var"); }
/// ------------------------------------------------------------------------------------ private PatternGroup CreateOuterMostPatternGroup(string pattern) { //foreach (var grp in _tokenGroups.Values.OfType<PatternGroup>().Where(g => g.Members.Count == 1)) // grp.GroupType = GroupType.Sequential; var group = new PatternGroup(_currEnvType) { GroupType = GroupType.Sequential }; PatternGroupMember member = null; foreach (char chr in pattern) { if (chr == '+') { if (member != null) { group.AddRangeOfMembers(member.CloseMember() ?? new[] { member }); member = null; } group.AddMember(new PatternGroupMember("+")); } else if (chr < kMinToken) { (member ?? (member = new PatternGroupMember())).AddToMember(chr); } else { if (member != null) { group.AddRangeOfMembers(member.CloseMember() ?? new[] { member }); member = null; } group.AddMember(_tokenGroups[chr]); } } if (member != null) { group.AddRangeOfMembers(member.CloseMember() ?? new[] { member }); } if (group.Members.Count == 1 && group.Members[0] is PatternGroup) { group = (PatternGroup)group.Members[0]; } //if (group.Members.Count == 1 && group.Members[0] is PatternGroupMember) // group.GroupType = GroupType.Sequential; return(group); }
public void AddExcludePatternGroup() { var group1 = new PatternGroup(new string[] { "z" }); var group2 = new PatternGroup(new string[] { "a", "b" }, new string[] { "C" }, new string[] { "d" }); group1.ExcludeGroup(group2); Assert.Equal(new string[] { "z" }, group1.IncludePatterns); Assert.Equal(0, group1.ExcludePatterns.Count()); Assert.Equal(1, group1.ExcludePatternsGroup.Count()); Assert.True(PatternsGroupTestHelper.Equals(group2, group1.ExcludePatternsGroup.First())); }
public void GetHashCodeUsesPatterns() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); group1.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group2.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group3.AddPattern(new Pattern(new UriRef("http://example.com/other"), new UriRef("http://example.com/predicate"), new Variable("var"))); Assert.IsTrue(group1.GetHashCode() == group2.GetHashCode(), "PatternGroup1 should have same hash code as group2"); Assert.IsTrue(group1.GetHashCode() != group3.GetHashCode(), "PatternGroup1 should not have same hash code as group2"); }
public void GetHashCodeUsesConstraints() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); group1.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group2.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group3.AddConstraint(new Constraint(new VariableExpression(new Variable("other")))); Assert.IsTrue(group1.GetHashCode() == group2.GetHashCode(), "PatternGroup1 should have same hash code as group2"); Assert.IsTrue(group1.GetHashCode() != group3.GetHashCode(), "PatternGroup1 should not have same hash code as group3"); }
public void EqualsComparesConstraints() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); group1.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group2.AddConstraint(new Constraint(new VariableExpression(new Variable("var")))); group3.AddConstraint(new Constraint(new VariableExpression(new Variable("other")))); Assert.IsTrue(group1.Equals(group2), "PatternGroup1 should equal group2"); Assert.IsTrue(!group1.Equals(group3), "PatternGroup1 should not equal group3"); }
public void EqualsComparesPatterns() { PatternGroup group1 = new PatternGroup(); PatternGroup group2 = new PatternGroup(); PatternGroup group3 = new PatternGroup(); group1.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group2.AddPattern(new Pattern(new UriRef("http://example.com/subject"), new UriRef("http://example.com/predicate"), new Variable("var"))); group3.AddPattern(new Pattern(new UriRef("http://example.com/other"), new UriRef("http://example.com/predicate"), new Variable("var"))); Assert.IsTrue(group1.Equals(group2), "PatternGroup1 should equal group2"); Assert.IsTrue(!group1.Equals(group3), "PatternGroup1 should not equal group3"); }
public void MiscParseFailureTest() { var rootGroup = new PatternGroup(EnvironmentType.After); var group = new PatternGroup(EnvironmentType.Item); Assert.IsFalse(group.Parse(string.Empty)); Assert.IsFalse(group.Parse(null)); SetProperty(group, "RootGroup", rootGroup); Assert.IsFalse(GetBoolResult(group, "PreParseProcessing", "{[ab}]")); Assert.IsFalse(GetBoolResult(group, "PreParseProcessing", "a[bc]")); Assert.IsFalse(GetBoolResult(group, "PreParseProcessing", "{ab}c")); }
public void FromJSON(Dictionary <string, object> jsonData) { name = (string)jsonData["name"]; BackgroundColor = SerializableManager.FromJSON(jsonData["background"]); foreach (PatternGroup g in Patterns) { if (g != null) { if (g.Pattern != null) { Destroy(g.Pattern.gameObject); } if (g.Particle != null) { Destroy(g.Particle.gameObject); } } } Patterns.Clear(); List <object> groups = (List <object>)jsonData["groups"]; for (int i = 0; i < 4; i++) { PatternGroup p = null; if (i < groups.Count) { Dictionary <string, object> group = (Dictionary <string, object>)groups[i]; if (group.Count > 0) { p = new PatternGroup(); Dictionary <string, object> pattern = (Dictionary <string, object>)group["pattern"]; Dictionary <string, object> particle = (Dictionary <string, object>)group["particle"]; p.Enabled = SerializableManager.GetInt(group["enabled"]) > 0; p.Pattern = DataManager.Instance.CreatePattern(); SerializableManager.Deserialize <SpiralPattern>(p.Pattern, pattern); p.Particle = DataManager.Instance.CreateParticle(); SerializableManager.Deserialize <SpiralParticle>(p.Particle, particle); p.Color = SerializableManager.FromJSON(group["color"]); } } Patterns.Add(p); } }
/// ------------------------------------------------------------------------------------ private string ParseTextInBrackets(string pattern, Match match) { var group = new PatternGroup(_currEnvType) { GroupType = GroupType.And }; var symbolsInBracketedText = string.Empty; var bracketedText = ParseTextBetweenOpenAndCloseSymbols(match.Result("${bracketedText}"), FindInnerMostBracesPair, ParseTextInBraces); foreach (var chr in bracketedText) { if (chr <= kMinToken) { symbolsInBracketedText += chr; } else if (_tokenGroups[chr] is string) { // The only time a token group is a string is when it contains a diacritic pattern cluster. if (((string)_tokenGroups[chr]).Contains(App.DottedCircle)) { group.SetDiacriticPattern((string)_tokenGroups[chr]); } _tokenGroups.Remove(chr); } else { group.AddMember(_tokenGroups[chr]); _tokenGroups.Remove(chr); } } if (symbolsInBracketedText != string.Empty) { // If plain text (i.e. not features or classes) is found between the square brackets, // then if it represents a single phone, that's fine. Otherwise, it's an error. // This deals with patterns like "[b[0*]]" (where 0 is the diacritic placeholder). // By the time we get here, it's assumed the SearchQueryValidator has caught errors. var phonesInBrackets = _project.PhoneticParser.Parse(symbolsInBracketedText, true, false); group.AddMember(new PatternGroupMember(phonesInBrackets[0])); } if (group.Members.Count == 1 && group.Members[0] is PatternGroup) { group = (PatternGroup)group.Members[0]; } _tokenGroups[++_token] = group; return(ReplaceMatchedTextWithToken(pattern, match, _token)); }
public void DelimitMembersTest() { var group = new PatternGroup(EnvironmentType.After); string pattern = "[[+high][+vcd][V]]"; string result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("[%+high$%+vcd$%V$]", result); pattern = "{[[+high][+cons]][[+vcd][+cons]]}"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("{[%+high$%+cons$][%+vcd$%+cons$]}", result); pattern = "[{[+high][+vcd]}[+cons]]"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("[{%+high$%+vcd$}%+cons$]", result); pattern = "{{a,e}[[+front][+round]]}"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("{{a,e}[%+front$%+round$]}", result); // Test a pattern from which some brackets don't need removing. pattern = "[+front]{[+round][+vcd]}"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("%+front${%+round$%+vcd$}", result); pattern = "[[{a,e}{[+high][DENTAL]}][-dOrSaL]]"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("[[{a,e}{%+high$%DENTAL$}]%-dOrSaL$]", result); pattern = "[+high]abc[+con]"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("%+high$abc%+con$", result); pattern = "[+high]abc{[+con],[dental]}"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("%+high$abc{%+con$%dental$}", result); pattern = "[+high]abc[[+con],[dental]]"; result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual("%+high$abc[%+con$%dental$]", result); pattern = string.Format("[+con][[C][{0}~+]]", App.DottedCircle); result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual(string.Format("%+con$[%C$[{0}~+]]", App.DottedCircle), result); pattern = string.Format("[+con][[C][{0}~*]]", App.DottedCircle); result = GetStrResult(group, "DelimitMembers", pattern); Assert.AreEqual(string.Format("%+con$[%C$[{0}~*]]", App.DottedCircle), result); }
/// <exception cref="IOException"/> /// <exception cref="ArgumentException"><paramref name="path"/> is invalid</exception> internal static PatternGroup LoadFromFile(string path, PatternGroup parent) { // See https://git-scm.com/docs/gitignore#_pattern_format if (!File.Exists(path)) { return(null); } StreamReader reader; try { reader = File.OpenText(path); } catch (Exception e) when(e is FileNotFoundException || e is DirectoryNotFoundException) { return(null); } var reusableBuffer = new StringBuilder(); var directory = PathUtils.ToPosixDirectoryPath(Path.GetFullPath(Path.GetDirectoryName(path))); var patterns = ImmutableArray.CreateBuilder <Pattern>(); using (reader) { while (true) { string line = reader.ReadLine(); if (line == null) { break; } if (TryParsePattern(line, reusableBuffer, out var glob, out var flags)) { patterns.Add(new Pattern(glob, flags)); } } } if (patterns.Count == 0) { return(null); } return(new PatternGroup(parent, directory, patterns.ToImmutable())); }
private void StartPatternGroup() { if (Explain) { Console.WriteLine("Starting a new pattern group"); } PatternGroup group = new PatternGroup(); itsPatternCollector = new PatternCollector(group); itsPatternCollector.Explain = Explain; itsPatternCollectorStack.Add(itsPatternCollector); itsPatternCollector.StartTermGroup(); }
protected override void Awake() { base.Awake(); hyperParameterSet[(int)HyperParameterOfSpell.Spell01] = new SpellHyperParameter { CoolDown = 3, Damage = 1, Range = 2.0f, ColliderHalfExtends = Vector3.one * 0.2f, Motion = (int)SpellMotionName.Normal01 }; Pattern pattern1 = new Pattern(1); pattern1.actionQueue.AddLast(ChillingSlash()); pattern1.actionQueue.AddLast(ChillingSlash()); pattern1.frequency = 20; pattern1.patternCooldown = 2; PatternGroup.Add(pattern1); }
private void ParseFilter(QueryTokenizer tokenizer, PatternGroup group) { while (tokenizer.MoveNext()) { switch (tokenizer.Type) { case QueryTokenizer.TokenType.BeginGroup: break; case QueryTokenizer.TokenType.EndGroup: return; case QueryTokenizer.TokenType.Variable: Constraint constraint = new Constraint(new VariableExpression(new Variable(tokenizer.TokenText))); group.AddConstraint(constraint); break; } } }
private void StartAlternatePatternGroup() { if (Explain) { Console.WriteLine("Starting a new alternate pattern group"); } PatternGroup newGroup = new PatternGroup(); itsPatternCollector.PatternGroup.AddAlternateGroup(newGroup); PatternCollector collector = new PatternCollector(newGroup); collector.Explain = Explain; itsPatternCollectorStack.Add(collector); itsPatternCollector = collector; itsPatternCollector.StartTermGroup(); }
private void StartOptionalPatternGroup() { if (Explain) { Console.WriteLine("Starting a new optional pattern group"); } PatternGroup newGroup = new PatternGroup(); itsPatternCollector.PatternGroup.OptionalGroup = newGroup; PatternCollector collector = new PatternCollector(newGroup); collector.Explain = Explain; itsPatternCollectorStack.Add(collector); itsPatternCollector = collector; itsPatternCollector.StartTermGroup(); }
public static bool Equals(PatternGroup x, PatternGroup y) { if (!Enumerable.SequenceEqual(x.IncludePatterns.OrderBy(elem => elem), y.IncludePatterns.OrderBy(elem => elem))) { return false; } if (!Enumerable.SequenceEqual(x.ExcludePatterns.OrderBy(elem => elem), y.ExcludePatterns.OrderBy(elem => elem))) { return false; } if (!Enumerable.SequenceEqual(x.IncludeLiterals.OrderBy(elem => elem), y.IncludeLiterals.OrderBy(elem => elem))) { return false; } if (x.ExcludePatternsGroup.Count() != y.ExcludePatternsGroup.Count()) { return false; } var xExcludeGroups = x.ExcludePatternsGroup.ToArray(); var yExcludeGroups = x.ExcludePatternsGroup.ToArray(); for (int idx = 0; idx < xExcludeGroups.Count(); ++idx) { if (!Equals(xExcludeGroups[idx], yExcludeGroups[idx])) { return false; } } return true; }
private static void BuildPatternGroups(string Source, int SourceLength, ref int SourceIndex, LigatureInfo[] SourceLigatureInfo, string Pattern, int PatternLength, ref int PatternIndex, LigatureInfo[] PatternLigatureInfo, ref bool PatternError, ref int PGIndexForLastAsterisk, CompareInfo Comparer, CompareOptions Options, ref PatternGroup[] PatternGroups) { PatternError = false; PGIndexForLastAsterisk = 0; PatternGroups = new PatternGroup[0x10]; int num3 = 15; PatternType nONE = PatternType.NONE; int index = 0; do { PatternGroup[] groupArray2; int num6; if (index >= num3) { PatternGroup[] array = new PatternGroup[(num3 + 0x10) + 1]; PatternGroups.CopyTo(array, 0); PatternGroups = array; num3 += 0x10; } switch (Pattern[PatternIndex]) { case '*': case 0xff0a: if (nONE != PatternType.STAR) { nONE = PatternType.STAR; PatternGroups[index].PatType = PatternType.STAR; PGIndexForLastAsterisk = index; index++; } break; case '[': case 0xff3b: { bool seenNot = false; List<Range> rangeList = new List<Range>(); if (!ValidateRangePattern(Pattern, PatternLength, ref PatternIndex, PatternLigatureInfo, Comparer, Options, ref seenNot, ref rangeList)) { PatternError = true; return; } if (rangeList.Count != 0) { if (seenNot) { nONE = PatternType.EXCLIST; } else { nONE = PatternType.INCLIST; } PatternGroups[index].PatType = nONE; PatternGroups[index].CharCount = 1; PatternGroups[index].RangeList = rangeList; index++; } break; } case '#': case 0xff03: if (nONE == PatternType.DIGIT) { groupArray2 = PatternGroups; num6 = index - 1; groupArray2[num6].CharCount++; } else { PatternGroups[index].PatType = PatternType.DIGIT; PatternGroups[index].CharCount = 1; index++; nONE = PatternType.DIGIT; } break; case '?': case 0xff1f: if (nONE == PatternType.ANYCHAR) { groupArray2 = PatternGroups; num6 = index - 1; groupArray2[num6].CharCount++; } else { PatternGroups[index].PatType = PatternType.ANYCHAR; PatternGroups[index].CharCount = 1; index++; nONE = PatternType.ANYCHAR; } break; default: { int num5 = PatternIndex; int num4 = PatternIndex; if (num4 >= PatternLength) { num4 = PatternLength - 1; } if (nONE == PatternType.STRING) { groupArray2 = PatternGroups; num6 = index - 1; groupArray2[num6].CharCount++; PatternGroups[index - 1].StringPatternEnd = num4; } else { PatternGroups[index].PatType = PatternType.STRING; PatternGroups[index].CharCount = 1; PatternGroups[index].StringPatternStart = num5; PatternGroups[index].StringPatternEnd = num4; index++; nONE = PatternType.STRING; } break; } } PatternIndex++; } while (PatternIndex < PatternLength); PatternGroups[index].PatType = PatternType.NONE; PatternGroups[index].MinSourceIndex = SourceLength; int num = SourceLength; while (index > 0) { switch (PatternGroups[index].PatType) { case PatternType.STRING: num -= PatternGroups[index].CharCount; break; case PatternType.EXCLIST: case PatternType.INCLIST: num--; break; case PatternType.DIGIT: case PatternType.ANYCHAR: num -= PatternGroups[index].CharCount; break; } PatternGroups[index].MaxSourceIndex = num; index--; } }
public void createObstacles(){ //addPatternToObstacles (basicPatterns.getAPattern ()); int i = 0; PatternGroup pats = basicPatterns; while(i<musicParts.Count){ //print (i + " " + musicParts.Count); if(musicParts[i].doesHaveMesure(mesure)){ if(musicParts[i].additional){ pats = new PatternGroup(pats, musicParts[i].patterns); }else{ pats = musicParts[i].patterns; break; } } i++; } addPatternToObstacles(pats.getAPattern()); /*int rand = Random.Range (0, 6); if (rand < 1) { obstacleInfos.Add(new ObstacleInfo("Ball", counter/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+1)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Ball", (counter+2)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+3)/music.tempo*60, 16)); counter +=4; didRotation = false; }else if (rand == 1) { if(!didRotation){ float angle = 0; int random = Random.Range(0,4); switch(random){ case 0: angle = 0; break; case 1: angle = 180; break; case 2: angle = 90; break; case 3: angle = 270; break; default:angle = 0; break; } events.Add(new Event("RotationWarning", (counter-1)/music.tempo*60, -angle)); events.Add(new Event("CameraRotation", (counter+2)/music.tempo*60, 10, angle)); counter+=4; didRotation = true; } }else if (rand == 2) { Color col; int random = Random.Range(0,12); if(random<3) col = Color.red; else if(random<6) col = new Color(1,1,0,1); else if(random<9) col = Color.green; else col = new Color(1,0,1,1); events.Add (new Event("BackgroundColor", (counter)/music.tempo*60, 10, col)); //didRotation = false; }else if (rand == 3) { obstacleInfos.Add(new ObstacleInfo("Ball", counter/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+1)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+2)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+3)/music.tempo*60, 16)); counter +=4; didRotation = false; }else if(rand == 4){ obstacleInfos.Add(new ObstacleInfo("Bar", counter/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+1)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+2)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+3)/music.tempo*60, 16)); counter +=4; didRotation = false; }else if (rand == 5) { obstacleInfos.Add(new ObstacleInfo("Bar", counter/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Bar", (counter+1)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Ball", (counter+2)/music.tempo*60, 16)); obstacleInfos.Add(new ObstacleInfo("Ball", (counter+3)/music.tempo*60, 16)); counter +=4; didRotation = false; }*/ }
public MusicPart(){ this.mesures = new List<Periode>(); this.patterns = new PatternGroup(); }
private static void MatchAsterisk(string Source, int SourceLength, int SourceIndex, LigatureInfo[] SourceLigatureInfo, string Pattern, LigatureInfo[] PatternLigatureInfo, PatternGroup[] PatternGroups, int PGIndex, ref bool Mismatch, ref bool PatternError, CompareInfo Comparer, CompareOptions Options) { PatternGroup group; int index = PGIndex; int maxSourceIndex = SourceIndex; int num3 = -1; int num2 = -1; PatternGroups[PGIndex].MinSourceIndex = SourceIndex; PatternGroups[PGIndex].StartIndexOfPossibleMatch = SourceIndex; PGIndex++; Label_002D: group = PatternGroups[PGIndex]; switch (group.PatType) { case PatternType.STRING: { Label_006A: if (SourceIndex > group.MaxSourceIndex) { Mismatch = true; return; } PatternGroups[PGIndex].StartIndexOfPossibleMatch = SourceIndex; int stringPatternStart = group.StringPatternStart; int num6 = 0; int leftStart = SourceIndex; bool flag = true; do { int num8 = CompareChars(Source, SourceLength, leftStart, ref leftStart, SourceLigatureInfo, Pattern, group.StringPatternEnd + 1, stringPatternStart, ref stringPatternStart, PatternLigatureInfo, Comparer, Options, false, false); if (flag) { flag = false; num6 = leftStart + 1; } if (num8 != 0) { SourceIndex = num6; index = PGIndex - 1; maxSourceIndex = SourceIndex; goto Label_006A; } stringPatternStart++; leftStart++; if (stringPatternStart > group.StringPatternEnd) { SourceIndex = leftStart; goto Label_02F4; } } while (leftStart < SourceLength); Mismatch = true; return; } case PatternType.EXCLIST: case PatternType.INCLIST: { while (true) { if (SourceIndex > group.MaxSourceIndex) { Mismatch = true; return; } PatternGroups[PGIndex].StartIndexOfPossibleMatch = SourceIndex; if (MatchRangeAfterAsterisk(Source, SourceLength, ref SourceIndex, SourceLigatureInfo, Pattern, PatternLigatureInfo, group, Comparer, Options)) { goto Label_02F4; } index = PGIndex - 1; maxSourceIndex = SourceIndex; } } case PatternType.DIGIT: { Label_010A: if (SourceIndex > group.MaxSourceIndex) { Mismatch = true; return; } PatternGroups[PGIndex].StartIndexOfPossibleMatch = SourceIndex; int num11 = group.CharCount; for (int j = 1; j <= num11; j++) { char c = Source[SourceIndex]; SourceIndex++; if (!char.IsDigit(c)) { index = PGIndex - 1; maxSourceIndex = SourceIndex; goto Label_010A; } } goto Label_02F4; } case PatternType.ANYCHAR: if (SourceIndex <= group.MaxSourceIndex) { break; } Mismatch = true; return; case PatternType.STAR: PatternGroups[PGIndex].StartIndexOfPossibleMatch = SourceIndex; group.MinSourceIndex = SourceIndex; if (PatternGroups[index].PatType == PatternType.STAR) { goto Label_02E9; } if (SourceIndex <= group.MaxSourceIndex) { goto Label_0285; } Mismatch = true; return; case PatternType.NONE: PatternGroups[PGIndex].StartIndexOfPossibleMatch = group.MaxSourceIndex; if (SourceIndex < group.MaxSourceIndex) { index = PGIndex - 1; maxSourceIndex = group.MaxSourceIndex; } if ((PatternGroups[index].PatType == PatternType.STAR) || (PatternGroups[index].PatType == PatternType.NONE)) { return; } goto Label_0285; default: goto Label_02F4; } PatternGroups[PGIndex].StartIndexOfPossibleMatch = SourceIndex; int charCount = group.CharCount; for (int i = 1; i <= charCount; i++) { if (SourceIndex >= SourceLength) { Mismatch = true; return; } SkipToEndOfExpandedChar(SourceLigatureInfo, SourceLength, ref SourceIndex); SourceIndex++; } goto Label_02F4; Label_0285: num3 = PGIndex; SourceIndex = maxSourceIndex; PGIndex = index; do { SubtractChars(Source, SourceLength, ref SourceIndex, PatternGroups[PGIndex].CharCount, SourceLigatureInfo, Options); PGIndex--; } while (PatternGroups[PGIndex].PatType != PatternType.STAR); SourceIndex = Math.Max(SourceIndex, PatternGroups[PGIndex].MinSourceIndex + 1); PatternGroups[PGIndex].MinSourceIndex = SourceIndex; num2 = PGIndex; Label_02E9: PGIndex++; goto Label_002D; Label_02F4: if (PGIndex == index) { if (SourceIndex == maxSourceIndex) { SourceIndex = PatternGroups[num3].MinSourceIndex; PGIndex = num3; index = num3; } else if (SourceIndex < maxSourceIndex) { PatternGroup[] groupArray = PatternGroups; int num13 = num2; groupArray[num13].MinSourceIndex++; SourceIndex = PatternGroups[num2].MinSourceIndex; PGIndex = num2 + 1; } else { PGIndex++; index = num2; } } else { PGIndex++; } goto Label_002D; }
private static bool MatchRangeAfterAsterisk(string Source, int SourceLength, ref int SourceIndex, LigatureInfo[] SourceLigatureInfo, string Pattern, LigatureInfo[] PatternLigatureInfo, PatternGroup PG, CompareInfo Comparer, CompareOptions Options) { List<Range> rangeList = PG.RangeList; int leftEnd = SourceIndex; bool flag = false; foreach (Range range in rangeList) { int num4; int num2 = 1; if ((PatternLigatureInfo != null) && (PatternLigatureInfo[range.Start].Kind == CharKind.ExpandedChar1)) { num4 = 0; if (CompareChars(Source, SourceLength, SourceIndex, ref leftEnd, SourceLigatureInfo, Pattern, range.Start + range.StartLength, range.Start, ref num4, PatternLigatureInfo, Comparer, Options, true, false) == 0) { flag = true; break; } } num4 = 0; int num3 = CompareChars(Source, SourceLength, SourceIndex, ref leftEnd, SourceLigatureInfo, Pattern, range.Start + range.StartLength, range.Start, ref num4, PatternLigatureInfo, Comparer, Options, false, true); if ((num3 > 0) && (range.End >= 0)) { num4 = 0; num2 = CompareChars(Source, SourceLength, SourceIndex, ref leftEnd, SourceLigatureInfo, Pattern, range.End + range.EndLength, range.End, ref num4, PatternLigatureInfo, Comparer, Options, false, true); } if ((num3 == 0) || ((num3 > 0) && (num2 <= 0))) { flag = true; break; } } if (PG.PatType == PatternType.EXCLIST) { flag = !flag; } SourceIndex = leftEnd + 1; return flag; }