/// <summary> /// Load all the scripts from dlls in the Scripts folder. /// <remarks>Boo scripts should previously have been compiled into /// a dll (boo script cache.dll)</remarks> /// </summary> private void LoadScripts() { mScripts = new List <IScript>(); foreach (string scriptsPath in ScriptsPaths) { foreach (string dllFile in Directory.GetFiles(scriptsPath, "*.dll")) { try { Assembly assembly = Assembly.LoadFile(dllFile); foreach (Type type in assembly.GetTypes()) { try { IScript script = null; //Check for types implementing IScript if (typeof(IScript).IsAssignableFrom(type)) { if (!type.IsAbstract) { script = (IScript)Activator.CreateInstance(type); } } //Check for static scripts (for backwards compatibility) else if (type.Namespace == "CoverSources") { script = new StaticScript(type); } if (script != null) { mScripts.Add(script); } } catch (Exception e) { //Skip the type. Does this need to display a user error message? System.Diagnostics.Debug.Fail(String.Format("Could not load script: {0}\n\n{1}", type.Name, e.Message)); } } } catch (Exception e) { //Skip the assembly System.Diagnostics.Debug.Fail(String.Format("Could not load assembly: {0}\n\n{1}", dllFile, e.Message)); } } } }
public void Setting( Marker marker , Vector3 MarkerBullet , bool Miss , bool isCanCounterEmit , StaticScript staticScript ) { //ワールド座標の代入 _WorldPos = MarkerBullet; _MarkerWorldPos = marker.transform.position; //スクリーン座標の代入 _ScreenPos = marker .PosOnScreen; JudgeBar UseBar; int UseIndex; if(staticScript .rhythmManager.IsSlow) { UseBar = staticScript .bulletResultManager .SlowJudgeBar; UseIndex = marker .SlowJudgeIndex; } else { UseBar = staticScript .bulletResultManager .NormalJudgeBar; UseIndex = marker.JudgeIndex; } //ResultRankの代入 _ResultRank = Mathf .Abs( UseIndex - UseBar .BestJudgeIndex ) + staticScript .bulletResultManager .MaxRank - UseBar .MaxResultRank; IsSlowly = ( _ResultRank ) < 0; IsEarly = ( _ResultRank ) > 0; //スコアの代入 _Score = (int)( UseBar .GetScoreMultiple( UseIndex ) * 100 ); _Miss = Miss; IsCanCounterEmit = isCanCounterEmit; IsCounterEmited = false; }
public BaseTemplate AddStaticBodyScripts(ScriptBundleData bundleData) { StaticScript.SetData(bundleData); return(this); }
public void Setting(Marker marker, Vector3 MarkerBullet, bool Miss, bool isCanCounterEmit, StaticScript staticScript) { //ワールド座標の代入 _WorldPos = MarkerBullet; _MarkerWorldPos = marker.transform.position; //スクリーン座標の代入 _ScreenPos = marker.PosOnScreen; JudgeBar UseBar; int UseIndex; if (staticScript.rhythmManager.IsSlow) { UseBar = staticScript.bulletResultManager.SlowJudgeBar; UseIndex = marker.SlowJudgeIndex; } else { UseBar = staticScript.bulletResultManager.NormalJudgeBar; UseIndex = marker.JudgeIndex; } //ResultRankの代入 _ResultRank = Mathf.Abs(UseIndex - UseBar.BestJudgeIndex) + staticScript.bulletResultManager.MaxRank - UseBar.MaxResultRank; IsSlowly = (_ResultRank) < 0; IsEarly = (_ResultRank) > 0; //スコアの代入 _Score = (int)(UseBar.GetScoreMultiple(UseIndex) * 100); _Miss = Miss; IsCanCounterEmit = isCanCounterEmit; IsCounterEmited = false; }
private static void ProcessScripts(XElement updates) { try { Console.WriteLine("Searching for scripts..."); Dictionary <string, string> scripts = new Dictionary <string, string>(); foreach (string scriptsPath in ScriptsPaths) { foreach (string scriptFile in Directory.GetFiles(scriptsPath, "*.boo")) { //Later files override earlier ones of the same name scripts[Path.GetFileName(scriptFile).ToLowerInvariant()] = scriptFile; } } //HACK: Remove known common files scripts.Remove("util.boo"); scripts.Remove("amazon-common.boo"); //HACK: Remove specific files that shouldn't be included scripts.Remove("coverlandia.boo"); foreach (string scriptFile in scripts.Values) { try { Console.Write(String.Format("Processing {0}... ", Path.GetFileName(scriptFile))); using (StreamReader reader = File.OpenText(scriptFile)) { List <string> references = new List <string>(); string firstLine = reader.ReadLine(); if (firstLine.StartsWith("# refs: ") && firstLine.Length > 8) { string refsText = firstLine.Substring(8); references.AddRange(refsText.Split(' ')); } BooCompiler compiler = new BooCompiler(); compiler.Parameters.Ducky = true; //Required to allow late-binding to "coverart" parameter compiler.Parameters.OutputType = CompilerOutputType.Library; compiler.Parameters.Debug = false; compiler.Parameters.Pipeline = new CompileToMemory(); //HACK: Add known common files and references (as each script is being compiled individually compiler.Parameters.Input.Add(new FileInput(Path.Combine(Path.GetDirectoryName(scriptFile), "util.boo"))); compiler.Parameters.Input.Add(new FileInput(Path.Combine(Path.GetDirectoryName(scriptFile), "amazon-common.boo"))); references.Add("System.Web"); references.Add("System.Core"); //Console.WriteLine(String.Format("Loading references: [{0}]...", string.Join(", ", references.ToArray()))); foreach (string reference in references) { compiler.Parameters.References.Add(compiler.Parameters.LoadAssembly(reference, true)); } compiler.Parameters.Input.Add(new FileInput(scriptFile)); CompilerContext compilerContext = compiler.Run(); bool result; if (compilerContext.Errors.Count > 0) { Console.WriteLine("failed."); result = false; //faliure } else if (compilerContext.Warnings.Count > 0) { Console.WriteLine("done, but with warnings."); result = true; //Allow to continue } else { Console.WriteLine("done."); result = true; //Success } //Report warnings and errors foreach (CompilerWarning warning in compilerContext.Warnings) { ReportCompilerIssue("warning", warning.LexicalInfo, warning.Code, warning.Message); } foreach (CompilerError error in compilerContext.Errors) { ReportCompilerIssue("error", error.LexicalInfo, error.Code, error.Message); } if (result) { //Find the script type foreach (Type type in compilerContext.GeneratedAssembly.GetTypes()) { try { IScript script = null; //Check for types implementing IScript if (typeof(IScript).IsAssignableFrom(type)) { if (!type.IsAbstract) { script = (IScript)Activator.CreateInstance(type); } } //Check for static scripts (for backwards compatibility) else if (type.Namespace == "CoverSources") { script = new StaticScript(type); } if (script != null) { //Obtain name and version number var scriptXml = new XElement("Script", new XAttribute("Name", script.Name), new XAttribute("URI", Path.GetFileName(scriptFile)), new XAttribute("Version", script.Version)); //Hack: Add dependency to known dependent files if (script.Name.StartsWith("Amazon ")) { scriptXml.Add(new XElement("Dependency", "amazon-common.boo")); } updates.Add(scriptXml); } } catch (Exception e) { //Skip the type. Does this need to display a user error message? Console.WriteLine(String.Format("Could not load script: {0}\n\n{1}", type.Name, e.Message)); } } } } } catch (Exception fileReadingException) { Console.WriteLine(String.Format("Skipping unreadable file: \"{0}\"\n {1}", scriptFile, fileReadingException.Message)); } } } catch (Exception exception) { Console.WriteLine(String.Format("\nError: {0}\n", exception.Message)); } }