// Start is called before the first frame update void Start() { yarn = gameObject.GetComponent <Yarn>(); //threw me error at UnityEditor.Graphs.Edge.WakeUp()...therefore instanciating new empty obj mouseBanner = new GameObject(); mouseBanner = GameObject.Find("mouse1"); anim = GetComponent <Animator>(); }
public ActionResult DeleteConfirmed(int id) { Yarn yarn = db.yarns.Find(id); db.yarns.Remove(yarn); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "YarnId,ColorName,BrandName,Skeins,YarnType")] Yarn yarn) { if (ModelState.IsValid) { _dataRepository.updateYarn(yarn); return(RedirectToAction("Index")); } return(View(yarn)); }
public ActionResult Edit([Bind(Include = "YarnId,YarnCount,Remarks")] Yarn yarn) { if (ModelState.IsValid) { db.Entry(yarn).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(yarn)); }
public ActionResult SaveYarnInfo(Yarn objYarn) { var user = (User)Session["CurrentUser"]; objYarn.UserId = user.EMPID; objYarn.TermId = user.TermID; var res = _yarnInfoRepository.SaveYarnInfo(objYarn); return(Json(res, JsonRequestBehavior.AllowGet)); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); Yarn yarn = (Yarn)target; if (GUILayout.Button("Update")) { yarn.UpdateMesh(); } }
public override System.Collections.IEnumerator RunLine(Yarn.Line line) { if (lineHandler != null) lineHandler(line); if (expectedLines.Count > 0) { Assert.AreEqual(expectedLines.Dequeue(), line.text); } yield break; }
public void createYarnFromTextShouldCreateNewYarnObjectFromString() { var expectedYarn = new Yarn(5, YarnType.BFLSock, "Bobby BFL"); String CommaSeparatedString = ",5,BSK,Bobby BFL"; var actualYarn = Yarn.CreateYarnFromText(CommaSeparatedString); Assert.AreEqual(expectedYarn.NumberOfSkeins, actualYarn.NumberOfSkeins); Assert.AreEqual(expectedYarn.YarnType, actualYarn.YarnType); Assert.AreEqual(expectedYarn.YarnTypeDescription, actualYarn.YarnTypeDescription); }
public ActionResult Create([Bind(Include = "YarnId,YarnCount,Remarks")] Yarn yarn) { if (ModelState.IsValid) { db.yarns.Add(yarn); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(yarn)); }
// GET: Yarns/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Yarn yarn = _dataRepository.getYarn(id.Value); if (yarn == null) { return(HttpNotFound()); } return(View(yarn)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Yarn yarn = db.yarns.Find(id); if (yarn == null) { return(HttpNotFound()); } return(View(yarn)); }
public void AddingTwoYarnTogetherShouldSumTheQuantitiesWhenTheyHaveTheSameProperties() { Yarn yarn1 = new Yarn() { NumberOfSkeins = 10, YarnType = YarnType.Classy, YarnTypeDescription = "Classy S.W. Merino Worsted", Color = "A Little Night Music" }; Yarn yarn2 = new Yarn() { NumberOfSkeins = 15, YarnType = YarnType.Classy, YarnTypeDescription = "Classy S.W. Merino Worsted", Color = "A Little Night Music" }; Yarn totalYarn = yarn1 + yarn2; Assert.AreEqual(25, totalYarn.NumberOfSkeins); }
public string SaveYarnInfo(Yarn objYarn) { string rv = ""; try { Insert_Update_SupplierInfo("sp_insert_yarn_info", "saveyarninfo", objYarn); rv = Operation.Success.ToString(); } catch (Exception ex) { rv = ex.Message; } return(rv); }
public void AddingTwoYarnTogetherShouldNotSumTheQuantitiesWhenTheyDoNotHaveTheSameProperties() { var yarn1 = new Yarn() { NumberOfSkeins = 10, YarnType = YarnType.Classy, YarnTypeDescription = "lassy S.W. Merino Worsted", Color = "A Little Night Music" }; var yarn2 = new Yarn() { NumberOfSkeins = 15, YarnType = YarnType.Classy, YarnTypeDescription = "Classy S.W. Merino Worsted", Color = "A Little Night Music" }; Assert.Throws <ArgumentException>(() => { Yarn totalYarn = yarn1 + yarn2; }); }
public override System.Collections.IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { if (optionsHandler != null) optionsHandler(optionsCollection, optionChooser); if (expectedOptions.Count > 0) { var selection = expectedOptions.Dequeue(); var index = optionsCollection.options.IndexOf(selection); Assert.AreNotEqual(index, -1, "Failed to find option \"{0}\"", selection); Assert.Less(index, optionsCollection.options.Count); optionChooser(index); } yield break; }
public Task <Yarn> GetTestYarn() { Yarn testYarn = YarnService.DbSet.FirstOrDefault(yarn => yarn.Code == "Test"); if (testYarn != null) { return(Task.FromResult(testYarn)); } else { testYarn = new Yarn() { Code = "Test", Name = "Test Yarn" }; YarnService.Create(testYarn); return(YarnService.GetAsync(testYarn.Id)); } }
public ActionResult Create([Bind(Include = "YarnId,ColorName,BrandName,Skeins,YarnType")] Yarn yarn, List <int> UserIds) { if (ModelState.IsValid) { yarn.Users = new List <User>(); foreach (var userId in UserIds) { yarn.Users.Add(new User { UserId = userId }); } //broken _dataRepository.addYarn(yarn); return(RedirectToAction("Index")); } return(View(yarn)); }
public bool CreateYarn(YarnCreate model) { var entity = new Yarn() { UserId = _userId, Color = model.Color, Manufacturer = model.Manufacturer, TotalYardage = model.TotalYardage, TotalWeight = model.TotalWeight, Fiber = model.Fiber, WherePurchased = model.WherePurchased, }; using (var ctx = new ApplicationDbContext()) { ctx.Yarns.Add(entity); return(ctx.SaveChanges() == 1); } }
public void CleanAll() { var meshRendererArray = GetComponentsInChildren <MeshRenderer>(true); bounds.size = Vector3.zero; bounds.center = Vector3.zero; foreach (var mr in meshRendererArray) { Destroy(mr.material); } while (transform.childCount != 0) { DestroyImmediate(transform.GetChild(0).gameObject); } if (ClippingPlane.instance) { ClippingPlane.instance.matList.Clear(); } Yarn.CleanMaterials(); Resources.UnloadUnusedAssets(); }
// Show a line of dialogue, gradually public override IEnumerator RunLine(Yarn.Line line) { // Show the text lineText.gameObject.SetActive(true); if (textSpeed > 0.0f) { // Display the line one character at a time var stringBuilder = new StringBuilder(); foreach (char c in line.text) { stringBuilder.Append(c); lineText.text = stringBuilder.ToString(); yield return new WaitForSeconds(textSpeed); } } else { // Display the line immediately if textSpeed == 0 lineText.text = line.text; } // Show the 'press any key' prompt when done, if we have one if (continuePrompt != null) continuePrompt.SetActive(true); // Wait for any user input while (Input.anyKeyDown == false) { yield return null; } // Hide the text and prompt lineText.gameObject.SetActive(false); if (continuePrompt != null) continuePrompt.SetActive(false); }
public void saveYarn() { YarnHandler yarnHandler = new YarnHandler(); Yarn newYarn = new Yarn(); newYarn.Yarn_Name = uiManager.yarnNameField.text; //If we're adding a new yarn if (yarnEditor.getID() == -1) { newYarn = yarnHandler.Post(newYarn); } //If we're adding to an existing yarn group else { newYarn.Yarn_Id = yarnEditor.getID(); } //TODO: Remove this line and add save bellow creating a save state YarnLineHandler yarnLineHandler = new YarnLineHandler(); yarnLineHandler.Post(new YarnLine(yarnEditor.getTo(), yarnEditor.getFrom(), newYarn.Yarn_Id)); this.YarnList.Add(new YarnLine(yarnEditor.getTo(), yarnEditor.getFrom(), newYarn.Yarn_Id)); }
public override System.Collections.IEnumerator RunCommand(Yarn.Command command) { if (commandHandler != null) commandHandler(command); yield break; }
public void RunLine(Yarn.Line lineText) { if (expectedNextLine != null && expectedNextLine != lineText.text) { // TODO: Output diagnostic info here Console.WriteLine(string.Format("Unexpected line.\nExpected: {0}\nReceived: {1}", expectedNextLine, lineText.text)); Environment.Exit (1); } expectedNextLine = null; Console.WriteLine (lineText.text); if (waitForLines == true) { Console.Read(); } }
// Run an internal command. public override IEnumerator RunCommand(Yarn.Command command) { // "Perform" the command Debug.Log ("Command: " + command.text); yield break; }
public void IsMiniSkeinShouldConvertQuantityWhenDescriptionContainsMini() { Yarn yarn = Yarn.CreateYarnFromText("1,VM,Classy 5- 50yd.minis @ $2.90 per skein,Amber Glass"); Assert.AreEqual(5, yarn.NumberOfSkeins); }
private void WeaveWeft(Rect rect) { // // Create each horizontal yarm (weft) GameObject go = null; go = Instantiate(Resources.Load("Yarn"), transform) as GameObject; go.name = "Weft"; Yarn yarn = go.GetComponent <Yarn>(); yarn.attributes = weftYarn; weft = go.GetComponent <Curve>(); weft.speedMultiplier *= gap.x; for (var row = (int)rect.yMin; row < rect.yMax; row++) { bool currentUpDown = false; // For each cross with a vertical yarm (warp) if (row % 2 == 0) { for (int column = (int)rect.xMin; column < rect.xMax; column++) { bool upDown = valueAtPixel(column, row); bool nextUpDown = valueAtPixel(column + 1, row); // If the yarm doesn't change is not neccesary a control point if ((column != rect.xMin) && (column != rect.xMax - 1)) { if ((upDown == currentUpDown) && (upDown == nextUpDown)) { continue; } } float up = -1.0f; if (!upDown) { up = 1.0f; } weft.AddControlPoint( new Vector3( (column - rect.x - (rect.width) * 0.5f) * gap.x, up * gap.y * 0.5f, (row - rect.y - (rect.height) * 0.5f) * gap.z), Quaternion.LookRotation(Vector3.right, Vector3.forward), currentUpDown != upDown); currentUpDown = upDown; } } else { for (int column = (int)rect.xMax; column >= rect.xMin; column--) { bool upDown = valueAtPixel(column, row); bool nextUpDown = valueAtPixel(column - 1, row); // If the yarm doesn't change is not neccesary a control point if ((column != rect.xMin) && (column != rect.xMax - 1)) { if ((upDown == currentUpDown) && (upDown == nextUpDown)) { continue; } } float up = -1.0f; if (!upDown) { up = 1.0f; } weft.AddControlPoint( new Vector3( (column - rect.x - (rect.width) * 0.5f) * gap.x, up * gap.y * 0.5f, (row - rect.y - (rect.height) * 0.5f) * gap.z), Quaternion.LookRotation(Vector3.left, Vector3.back), currentUpDown != upDown); currentUpDown = upDown; } } } yarn.UpdateMesh(); bounds.Encapsulate(yarn.bounds); //Split mesh //go.GetComponentInChildren<SplitMeshRenderer>().Split(); }
public void removeYarn(Yarn id) { _dataContext.Yarn.Remove(id); _dataContext.SaveChanges(); }
public void IsMiniSkeinShouldReturnFalseWhenDescriptionDoesNotContainNumber() { Yarn yarn = new Yarn(5, YarnType.Classy, "Classy S.W. Merino Worsted"); Assert.False(yarn.IsMiniSkein); }
// Run an internal command. public override IEnumerator RunCommand(Yarn.Command command) { // "Perform" the command Debug.Log ("Command: " + command.text); // Example: forward commands that begin with "set-sprite" to a SpriteSwitcher var commandElements = command.text.Split(' '); if (commandElements.Length > 0) { Debug.Log(commandElements[0]); // Syntax for this command = setsprite NAME SPRITENAME // GameObject NAME must have a SpriteSwitcher component // The SpriteSwitcher must have a sprite named SPRITENAME if (commandElements[0] == "FFFFDdo") { var switcher = GameObject.Find(commandElements[1]) .GetComponent<SpriteSwitcher>(); var spriteName = commandElements[2]; switcher.UseSprite(spriteName); } } yield break; }
public Dialogue(Yarn.VariableStorage continuity) { this.continuity = continuity; loader = new Loader (this); library = new Library (); library.ImportLibrary (new StandardLibrary ()); // Register the "visited" function, which returns true if we've visited // a node previously (nodes are marked as visited when we leave them) library.RegisterFunction ("visited", 1, delegate(Yarn.Value[] parameters) { var name = parameters[0].AsString; return visitedNodeNames.Contains(name); }); }
private void WeavePictoricalEspolin(Pictorial pictorial, Transform parent, int index, Rect rect) { YarnPictorial yarnPictorial = pictorial.processedPictorials[index]; yarnPictorial.Prepare(); // // Create each horizontal yarm (pictorical) GameObject go = Instantiate(Resources.Load("Yarn"), parent) as GameObject; yarnPictorial.curve = go.GetComponent <Curve>(); yarnPictorial.curve.speedMultiplier *= gap.x; go.name = "P" + index; Yarn yarn = go.GetComponent <Yarn>(); yarn.attributes = yarnPictorial.yarn; //Just for debug if (yarnPictorial.debugColor != Color.black) { yarn.attributes.color = yarnPictorial.debugColor; } for (int row = (int)rect.yMin; row < rect.yMax; row++) { if (yarnPictorial.firstPoint[row] != -1 && (yarnPictorial.lastPoint[row] - yarnPictorial.firstPoint[row]) > 2) { bool lastUpDown = false; bool healed, healed2; // For each cross with a vertical yarm (warp) if ((row % 2) == 0) { for (var column = yarnPictorial.firstPoint[row]; column <= yarnPictorial.lastPoint[row]; column++) { bool upDown = pictoricalValueAtPixel(yarnPictorial, column, row, out healed); bool nextUpDown = pictoricalValueAtPixel(yarnPictorial, column + 1, row, out healed2); // If the yarm doesn't change is not neccesary a control point if ((column != yarnPictorial.firstPoint[row]) && (column != yarnPictorial.lastPoint[row] - 1) && column < resolution.x - 1) { if ((upDown == lastUpDown) && (upDown == nextUpDown)) // && depth[column,row] == depth[column+1,row]) { continue; } } float up; if (upDown) { up = 2.0f; } else { up = yarnPictorial.CalculateBackDepth(this, index, column, row); } if (healed) { up *= 0.2f; } yarnPictorial.curve.AddControlPoint( new Vector3( (column - rect.x - rect.width * 0.5f) * gap.x, up * gap.y * 0.5f, (row - rect.y - rect.height * 0.5f) * gap.z), Quaternion.LookRotation(Vector3.right, Vector3.forward), lastUpDown != upDown, "Control Point_" + row + "_" + column + " " + healed); lastUpDown = upDown; } } else { for (var column = yarnPictorial.lastPoint[row]; column >= yarnPictorial.firstPoint[row]; column--) { bool upDown = pictoricalValueAtPixel(yarnPictorial, column, row, out healed); bool nextUpDown = pictoricalValueAtPixel(yarnPictorial, column - 1, row, out healed2); // If the yarm doesn't change is not neccesary a control point if ((column != yarnPictorial.firstPoint[row]) && (column != yarnPictorial.lastPoint[row] - 1) && column != resolution.x && column != 0) { if ((upDown == lastUpDown) && (upDown == nextUpDown))// && depth[column,row] == depth[column-1,row]) { continue; } } float up; if (upDown) { up = 2.0f; } else { up = yarnPictorial.CalculateBackDepth(this, index, column, row); } if (healed) { up *= 0.2f; } yarnPictorial.curve.AddControlPoint( new Vector3( (column - rect.x - rect.width * 0.5f) * gap.x, up * gap.y * 0.5f, (row - rect.y - rect.height * 0.5f) * gap.z), Quaternion.LookRotation(Vector3.left, Vector3.back), lastUpDown != upDown, "Control Point_" + row + "_" + column + " " + healed); lastUpDown = upDown; } } } } yarn.UpdateMesh(); bounds.Encapsulate(yarn.bounds); yarnPictorial.ReleaseMem(); //Split mesh //go.GetComponentInChildren<SplitMeshRenderer>().Split(); }
public string SaveYarnInfo(Yarn objYarn) { return(_yarnInfoDataService.SaveYarnInfo(objYarn)); }
//Insert public void Add(Yarn d) { entities.Yarns.AddObject(d); }
// Prints the parse tree for the node void PrintParseTree(Yarn.Parser.ParseNode rootNode) { dialogue.LogDebugMessage("Parse Tree:"); dialogue.LogDebugMessage(rootNode.PrintTree(0)); }
// Set a variable's value public override void SetValue(string variableName, Yarn.Value value) { // Copy this value into our list variables[variableName] = new Yarn.Value(value); }
// Show a list of options, and wait for the player to make a selection. public override IEnumerator RunOptions(Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser) { // Do a little bit of safety checking if (optionsCollection.options.Count > optionButtons.Count) { Debug.LogWarning("There are more options to present than there are" + "buttons to present them in. This will cause problems."); } // Display each option in a button, and make it visible int i = 0; foreach (var optionString in optionsCollection.options) { optionButtons [i].gameObject.SetActive (true); optionButtons [i].GetComponentInChildren<Text> ().text = optionString; i++; } // Record that we're using it SetSelectedOption = optionChooser; // Wait until the chooser has been used and then removed (see SetOption below) do { yield return null; } while (SetSelectedOption != null); // Hide all the buttons foreach (var button in optionButtons) { button.gameObject.SetActive (false); } }
public abstract void Diagnose(Yarn.Program program);
public void addYarn(Yarn yarn) { _dataContext.Yarn.Add(yarn); _dataContext.SaveChanges(); }
// Display a line. public abstract IEnumerator RunLine (Yarn.Line line);
public void updateYarn(Yarn id) { _dataContext.Entry(id).State = EntityState.Modified; _dataContext.SaveChanges(); }
// Display the options, and call the optionChooser when done. public abstract IEnumerator RunOptions (Yarn.Options optionsCollection, Yarn.OptionChooser optionChooser);
public void IsMiniSkeinShouldReturnTrueWhenDescriptionContainsMini() { Yarn yarn = new Yarn(5, YarnType.Classy, "Classy 5- 50yd.minis @ $2.90 per skein"); Assert.True(yarn.IsMiniSkein); }
// Perform some game-specific command. public abstract IEnumerator RunCommand (Yarn.Command command);
public void IsMiniSkeinShouldConvertYarnTypeWhenDescriptionContainsMini() { Yarn yarn = Yarn.CreateYarnFromText("1,VM,Classy 5- 50yd.minis @ $2.90 per skein,Amber Glass"); Assert.AreEqual(YarnType.MiniClassy, yarn.YarnType); }
public ActionResult DeleteConfirmed(int id) { Yarn yarn = _dataRepository.getYarn(id); return(RedirectToAction("Index")); }
public void RunLine(Yarn.Line lineText) { Console.WriteLine (lineText.text); if (waitForLines == true) { Console.Read(); } }
public abstract IEnumerable<Diagnosis> Diagnose(Yarn.Parser.Node node);
// executes a node, and returns either the name of the next node to run // or null (indicating the dialogue is over) internal IEnumerable<Dialogue.RunnerResult> RunNode(Yarn.Parser.Node node) { // Clear the list of options when we start a new node currentOptions = new List<Parser.OptionStatement> (); // Run all of the statements in this node foreach (var command in RunStatements (node.statements)) { yield return command; } // If we have no options, we're all done if (currentOptions.Count == 0) { yield return new Dialogue.NodeCompleteResult (null); yield break; } else { // We have options! // If we have precisely one option and it's got no label, jump to it if (currentOptions.Count == 1 && currentOptions[0].label == null) { yield return new Dialogue.NodeCompleteResult (currentOptions [0].destination); yield break; } // Otherwise, ask which option to pick... var optionStrings = new List<string> (); foreach (var option in currentOptions) { var label = option.label ?? option.destination; optionStrings.Add (label); } Parser.OptionStatement selectedOption = null; yield return new Dialogue.OptionSetResult (optionStrings, delegate(int selectedOptionIndex) { selectedOption = currentOptions[selectedOptionIndex]; }); if (selectedOption == null) { dialogue.LogErrorMessage ("Option chooser was never called!"); yield break; } // And jump to its destination! yield return new Dialogue.NodeCompleteResult(selectedOption.destination); } yield break; }
private void HandleResult(Yarn.Dialogue.RunnerResult result) { Console.WriteLine (result); if (result is Yarn.Dialogue.LineResult) { var text = (result as Yarn.Dialogue.LineResult).line.text; if (nextExpectedLine != null) { Assert.AreEqual (text, nextExpectedLine); } } else if (result is Yarn.Dialogue.OptionSetResult) { var optionCount = (result as Yarn.Dialogue.OptionSetResult).options.options.Count; var resultDelegate = (result as Yarn.Dialogue.OptionSetResult).setSelectedOptionDelegate; if (nextExpectedOptionCount != -1) { Assert.AreEqual (nextExpectedOptionCount, optionCount); } if (nextOptionToSelect != -1) { resultDelegate (nextOptionToSelect); } } else if (result is Yarn.Dialogue.CommandResult) { var commandText = (result as Yarn.Dialogue.CommandResult).command.text; if (nextExpectedCommand != null) { Assert.AreEqual (nextExpectedCommand, commandText); } } Console.WriteLine (result.ToString ()); nextExpectedLine = null; nextExpectedCommand = null; nextExpectedOptionCount = -1; nextOptionToSelect = -1; }