private static PackageManifest createDefaultManifest(string packageDirectory) { var manifest = PackageManifest.DefaultModuleManifest(); manifest.AddAssembly(LinkCommand.GuessAssemblyNameForFolder(packageDirectory, new FileSystem())); manifest.Name = Path.GetFileName(packageDirectory); return(manifest); }
public void ShouldCreateAFolder() { var command = new LinkCommand(); var databaseName = EnhancedRandom.String(10, 20); command.CreateLinkedDatabaseFolder(databaseName); var directory = Directory.GetCurrentDirectory(); var fileName = Path.Combine(directory, $"{databaseName}.json"); var folderName = Path.Combine(directory, databaseName); Directory.Exists(folderName).ShouldBe(true); File.Exists(fileName).ShouldBe(true); }
public static void executeCommand(ICommand command) { if (command.GetType().Equals(typeof(SpeakerCommand))) //speaker { SpeakerCommand speakerCommand = (SpeakerCommand)command; currentSpeaker = speakerCommand.speaker; GameObject speakerBox = GameObject.Find("Speaker"); Text speakerText = speakerBox.GetComponentInChildren <Text>(); Image speakerImage = speakerBox.GetComponentInChildren <Image>(); if (speakerCommand.speaker.Equals("")) { speakerText.color = Color.clear; speakerImage.color = Color.clear; } else { speakerText.color = Color.white; speakerImage.color = new Color(1f, 1f, 1f, 0.4f); speakerText.text = speakerCommand.speaker; } advanceScript(); } else if (command.GetType().Equals(typeof(TextCommand))) //text { TextCommand textCommand = (TextCommand)command; GameObject.Find("Dialogue").GetComponentInChildren <Text>().text = textCommand.text; } else if (command.GetType().Equals(typeof(PortraitCommand))) //portrait { PortraitCommand portraitCommand = (PortraitCommand)command; Image portrait = GameObject.Find(portraitCommand.side == 'L' ? "LeftPortrait" : "RightPortrait").GetComponentInChildren <Image>(); if (portraitCommand.character.Equals("")) { portrait.color = Color.clear; } else { portrait.color = Color.white; portrait.sprite = Resources.Load <Sprite>("Characters\\" + portraitCommand.character + "Girl"); } advanceScript(); } else if (command.GetType().Equals(typeof(BackgroundCommand))) //background { BackgroundCommand backgroundCommand = (BackgroundCommand)command; Image background = GameObject.Find("Background").GetComponentInChildren <Image>(); if (backgroundCommand.name.Equals("")) { background.color = Color.black; } else { background.color = Color.white; background.sprite = Resources.Load <Sprite>("Backgrounds\\" + backgroundCommand.name); } advanceScript(); } else if (command.GetType().Equals(typeof(LinkCommand))) //link { LinkCommand linkCommand = (LinkCommand)command; readScript(linkCommand.fileName); advanceScript(); } else if (command.GetType().Equals(typeof(AddPointsCommand))) //addpoints { AddPointsCommand addPointsCommand = (AddPointsCommand)command; switch (addPointsCommand.character) { case "Java": GameControl.control.JavaLovePoints += addPointsCommand.points; break; case "JSHTML": GameControl.control.JSHTMLLovePoints += addPointsCommand.points; break; case "C++": GameControl.control.CPPLovePoints += addPointsCommand.points; break; case "C#": GameControl.control.CSLovePoints += addPointsCommand.points; break; case "Python": GameControl.control.PYLovePoints += addPointsCommand.points; break; } advanceScript(); } else if (command.GetType().Equals(typeof(PromptCommand))) //prompt { PromptCommand promptCommand = (PromptCommand)command; isPrompting = true; int i = 0; List <GameObject> promptButtons = new List <GameObject>(); foreach (string choice in promptCommand.getChoices()) { GameObject promptButton = Instantiate(Resources.Load <GameObject>("Prefabs\\PromptButton"), new Vector3(0, 0), Quaternion.identity); promptButtons.Add(promptButton); promptButton.transform.SetParent(GameObject.Find("Background").transform); promptButton.transform.position = new Vector3(Screen.width / 2, (Screen.height - 55) - i * 40); promptButton.GetComponentInChildren <Text>().text = choice; promptButton.GetComponentInChildren <Button>().onClick.AddListener(delegate { isPrompting = false; foreach (GameObject button in promptButtons) { Destroy(button); } currentScript.InsertRange(commandIndex, promptCommand.getConsequences(choice)); advanceScript(); }); i++; } } else if (command.GetType().Equals(typeof(DateCheckCommand))) //datecheck { DateCheckCommand dateCheckCommand = (DateCheckCommand)command; switch (dateCheckCommand.character) { case "Java": if (GameControl.control.JavaLovePoints >= 15) { //date start } break; case "JSHTML": if (GameControl.control.JSHTMLLovePoints >= 15) { //date start } break; case "C++": if (GameControl.control.CPPLovePoints >= 15) { //date start } break; case "C#": if (GameControl.control.CSLovePoints >= 15) { //date start } break; case "Python": if (GameControl.control.PYLovePoints >= 15) { //date start } break; } } else if (command.GetType().Equals(typeof(FinalCheckCommand))) //finalcheck { FinalCheckCommand finalCheckCommand = (FinalCheckCommand)command; PromptCommand promptCommand = new PromptCommand(); if (GameControl.control.JavaLovePoints >= 15) { List <ICommand> commandList = new List <ICommand>(); commandList.Add(new LinkCommand("\\Home\\Narrator\\Endings\\Java.txt")); promptCommand.addConsequences("Java", commandList); } if (GameControl.control.JSHTMLLovePoints >= 15) { List <ICommand> commandList = new List <ICommand>(); commandList.Add(new LinkCommand("\\Home\\Narrator\\Endings\\HTML&JS.txt")); promptCommand.addConsequences("HTML & JS", commandList); } if (GameControl.control.CPPLovePoints >= 15) { List <ICommand> commandList = new List <ICommand>(); commandList.Add(new LinkCommand("\\Home\\Narrator\\Endings\\C++.txt")); promptCommand.addConsequences("C++", commandList); } if (GameControl.control.CSLovePoints >= 15) { List <ICommand> commandList = new List <ICommand>(); commandList.Add(new LinkCommand("\\Home\\Narrator\\Endings\\C#.txt")); promptCommand.addConsequences("C#", commandList); } if (GameControl.control.PYLovePoints >= 15) { List <ICommand> commandList = new List <ICommand>(); commandList.Add(new LinkCommand("\\Home\\Narrator\\Endings\\Python.txt")); promptCommand.addConsequences("Python", commandList); } List <ICommand> noneCommandList = new List <ICommand>(); noneCommandList.Add(new LinkCommand("\\Home\\Narrator\\Endings\\None.txt")); promptCommand.addConsequences("None", noneCommandList); currentScript.Insert(commandIndex, promptCommand); advanceScript(); } }
//********************************************************************* // // MobilePortalModuleControl.OnInit Method // // OnInit is called when the control is created and added to the // control tree. OnInit looks for a child control that renders the // summary view of the module, and creates a default one (with a // simple LinkCommand control) if no summary is found. // //********************************************************************* protected override void OnInit(EventArgs e) { base.OnInit(e); // Look for a control that renders the summary. _summaryControl = FindControl("summary"); // There could be no summary control, or the summary control may be // an empty panel. If there's no summary UI, automatically generate one. if (_summaryControl == null || (_summaryControl is Panel && !_summaryControl.HasControls())) { // Create and initialize a new LinkCommand control Command command = new LinkCommand(); command.Text = ModuleTitle; // Set the command name to the details command, so that // event bubbling can recognize it as a command to go to // details view. command.CommandName = ContentsPanel.DetailsCommand; // Add it to the appropriate place. if (_summaryControl != null) { _summaryControl.Controls.Add(command); } else { Controls.Add(command); _summaryControl = command; } } }