public virtual void SetCharacter(ICharacter character, IFlowchart flowchart = null) { if (character == null) { if (characterImage != null) { characterImage.gameObject.SetActive(false); } if (nameText != null) { nameText.text = ""; } speakingCharacter = null; } else { ICharacter prevSpeakingCharacter = speakingCharacter; speakingCharacter = character; // Dim portraits of non-speaking characters foreach (Stage stage in Stage.activeStages) { if (stage.DimPortraits) { foreach (var c in stage.CharactersOnStage) { if (prevSpeakingCharacter != speakingCharacter) { if (c != null && !c.Equals(speakingCharacter)) { stage.SetDimmed(c, true); } else { stage.SetDimmed(c, false); } } } } } string characterName = character.NameText; if (characterName == "") { // Use game object name as default characterName = character.GetObjectName(); } if (flowchart != null) { characterName = flowchart.SubstituteVariables(characterName); } SetCharacterName(characterName, character.NameColor); } }
public MasterPresenter(DataManagement data, FlowchartView view, string name) { this.data = data; this.view = view; flowchart = data.LoadFlowchart(name); selectedBlock = -1; selectedEdge = new int[2]; selectedEdge[0] = -1; selectedEdge[1] = -1; }
/// <summary> /// Returns the Flowchart that this command belongs to. /// </summary> public virtual IFlowchart GetFlowchart() { IFlowchart flowchart = GetComponent <IFlowchart>(); if (flowchart == null && transform.parent != null) { flowchart = transform.parent.GetComponent <IFlowchart>(); } return(flowchart); }
/// <summary> /// Returns the localization id for the Flowchart that contains this command. /// </summary> public virtual string GetFlowchartLocalizationId() { // If no localization id has been set then use the Flowchart name IFlowchart flowchart = GetFlowchart(); if (flowchart == null) { return(""); } string localizationId = GetFlowchart().LocalizationId; if (localizationId.Length == 0) { localizationId = flowchart.GetName(); } return(localizationId); }
public override void OnEnter() { IFlowchart flowchart = GetFlowchart(); if (stopParentFlowchart) { flowchart.StopAllBlocks(); } foreach (IFlowchart f in targetFlowcharts) { if (f == flowchart) { // Flowchart has already been stopped continue; } f.StopAllBlocks(); } }
internal void MasterAddToDB(IFlowchart flowchart, string comment) { string dt = DateTime.Now.ToString("u"); string querySelect = @"SELECT flowchart_name FROM data WHERE flowchart_name = '" + flowchart.GetName() + "' AND owner = '" + this.login + "'"; MySqlConnection connection = initializeDatabaseConnection("localhost", "flowchart", "root", ""); MySqlCommand com = new MySqlCommand(querySelect, connection); try { connection.Open(); MySqlDataReader dr = com.ExecuteReader(); string query = ""; if (dr.HasRows) { query = @"UPDATE data SET owner = '" + this.login + "', flowchart_name = '" + flowchart.GetName() + "', flowchart_data = '" + flowchart.GetCodeLikeStringList() + "', date = '" + dt + "', comment = '" + comment + "' WHERE owner = '" + this.login + "' AND flowchart_name = '" + flowchart.GetName() + "'"; connection.Close(); } else { query = @"INSERT INTO data (owner, flowchart_name, flowchart_data, date, comment) VALUES ('" + this.login + "', '" + flowchart.GetName() + "', '" + flowchart.GetCodeLikeStringList() + "','" + dt + "', '" + comment + "')"; connection.Close(); } com = new MySqlCommand(query, connection); connection.Open(); dr = com.ExecuteReader(); connection.Close(); } catch (Exception e) { connection.Close(); } }
internal void MasterApply(string name, string owner, IFlowchart flowchart) { string dt = DateTime.Now.ToString("u"); string query = @"UPDATE data SET flowchart_data = '" + flowchart.GetCodeLikeStringList() + "', date = '" + dt + "', comment = '' WHERE owner = '" + owner + "' AND flowchart_name = '" + name + "'"; MySqlConnection connection = initializeDatabaseConnection("localhost", "flowchart", "root", ""); MySqlCommand com = new MySqlCommand(query, connection); try { connection.Open(); MySqlDataReader dr = com.ExecuteReader(); connection.Close(); } catch (Exception e) { connection.Close(); } }
internal void Delete(IFlowchart flowchart) { string dt = DateTime.Now.ToString("u"); string query = @"DELETE FROM data WHERE owner = '" + login + "' AND reviewer = '" + reviewer + "' AND flowchart_name = '" + flowchart.GetName() + "'"; MySqlConnection connection = initializeDatabaseConnection("localhost", "flowchart", "root", ""); MySqlCommand com = new MySqlCommand(query, connection); try { connection.Open(); MySqlDataReader dr = com.ExecuteReader(); connection.Close(); } catch (Exception e) { connection.Close(); } }
public MasterPresenter(DataManagement data, string path, FlowchartView view, string name, string type_code) { switch (type_code) { case "C++": { flowchart = new FlowchartCppFactory().CreateFlowchart(path, name); break; } default: { flowchart = new Flowchart(name); break; } } this.data = data; this.view = view; selectedBlock = -1; selectedEdge = new int[2]; selectedEdge[0] = -1; selectedEdge[1] = -1; }
public CppCode(IFlowchart flowchart) { int currentNumOfTabbs = 0; Stack <int> stack = new Stack <int>(flowchart.GetListOfBlocks().Count);//1 - start, 2 - if, 3 - for, 4 - square code = new List <string>(1); foreach (var block in flowchart.GetListOfBlocks()) { foreach (var str in block.GetListOfStrings()) { currentNumOfTabbs = 0; if (code.Count() != 0) { foreach (var c in code[code.Count() - 1].ToCharArray()) { if (c != 9) { break; } currentNumOfTabbs++; } string tabbs = ""; if (str[currentNumOfTabbs] == 9) { for (int i = 0; i < currentNumOfTabbs; i++) { tabbs += '\t'; } if (flowchart.GetListOfBlocks()[flowchart.GetListOfBlocks().IndexOf(block) - 1] is StartBlock) { stack.Push(1); } if (code.Last().Contains("if (")) { stack.Push(2); } if (code.Last().Contains("for (")) { stack.Push(3); } code.Add(tabbs + '{'); } } if (currentNumOfTabbs != 0 && str[currentNumOfTabbs - 1] != 9) { string tabbs = ""; for (int i = 0; i < currentNumOfTabbs - 1; ++i) { tabbs += '\t'; } int endOfBlock = stack.Pop(); string endingSomething; switch (endOfBlock) { case 1: { endingSomething = "//endoffunc"; break; } case 2: { endingSomething = "//endofif"; break; } case 3: { endingSomething = "//endoffor"; break; } default: { endingSomething = ""; break; } } code.Add(tabbs + '}' + endingSomething); } code.Add(str); } } currentNumOfTabbs = 0; foreach (var c in code[code.Count() - 1].ToCharArray()) { if (c != 9) { break; } currentNumOfTabbs++; } string scobes = ""; for (int j = 0; j < currentNumOfTabbs; ++j) { int endOfBlock = stack.Pop(); string endingSomething; switch (endOfBlock) { case 1: { endingSomething = "//endoffunc"; break; } case 2: { endingSomething = "//endofif"; break; } case 3: { endingSomething = "//endoffor"; break; } default: { endingSomething = ""; break; } } scobes += '}' + endingSomething; } code.Add(scobes); }
public ICode CreateCode(IFlowchart flowchart) { return(new CppCode(flowchart)); }