public bool ResumeMovement() { if (curCondition == WaitingForTheContinuation) { curCondition = Movement; return(true); } return(false); }
public ConditionsPartEntry(Model model) { this.model = model; conditions tmpconditions = new conditions(); conditions.Deserialize(model.conditionsPart.XML, out tmpconditions); conditions = tmpconditions; }
public bool CancelMovement() { if (curCondition == Movement || curCondition == WaitingForTheContinuation) { ClearResorces(); curCondition = WaitingForRequest; return(true); } return(false); }
public bool InterruptMovement() { if (curCondition == Movement) { curCondition = WaitingForTheContinuation; return(true); } else { return(false); } }
//User defined calls (learn more about all of them in “Additional options” of “User’s guide.pdf” document) //>>>> public void ClearResorces() { if (way != null) { way.Clear(); } if (LengthOfTheChords != null) { LengthOfTheChords.Clear(); } totalLength = 0; CurrOffset = 0; prePointI = 0; curCondition = WaitingForRequest; }
public bool MoveTo(Vector3 target) { if (curCondition == WaitingForRequest) { ClearResorces(); spaceGraph.SetGoal(target); spaceGraph.SetStart(transform.position); finalPoint = target; curCondition = WaitingForAWay; AStarCoroutine = spaceGraph.GetWay(ProcessWay); if (automaticSearchStop) { StartCoroutine(KillSearch(stopTimer)); } return(true); } else { return(false); } }
public bool CancelWaySearch() { if (curCondition == WaitingForAWay) { if (AStarCoroutine != null) { StopCoroutine(AStarCoroutine); gameObject.SendMessage("WaySearchingIsCanceled"); } else { Debug.Log("Coroutine is not found"); } curCondition = WaitingForRequest; return(true); } else { return(false); } }
//<<<< //Here all required trajectory transformations occur //before the game object starts the movement toward the target void ProcessWay(List <Vector3> InputWay) { //Add precise start and end coordinates to the found trajectory InputWay[InputWay.Count - 1] = finalPoint; InputWay.Insert(0, transform.position); //call optimization functions and smooth trajectory way = PathOptimization(InputWay); way = PathSmoothing(InputWay); //Record lengths of all chords of the trajectory in the list LengthOfTheChords = new List <float>(way.Count - 1); for (int i = 1; i <= way.Count - 1; i++) { LengthOfTheChords.Add(Vector3.Magnitude(way[i - 1] - way[i])); totalLength += LengthOfTheChords[i - 1]; } //Trajectory drawing trace_way(way); //Assigning the method to the delegate curCondition = Movement; }
public void changeCondition(String condition) { switch (condition) { case "PLAYER_NEAR": currentConditions = conditions.PLAYER_NEAR; break; case "TIRED": currentConditions = conditions.TIRED; break; case "PLAYER_FAR": currentConditions = conditions.PLAYER_FAR; break; case "RESTED": currentConditions = conditions.RESTED; break; } }
public ConditionViewModel(conditions condition) { this.Id = condition.Id; this.Name = condition.name; }
/// <summary> /// Create OpenDoPE parts, including optionally, question part. /// </summary> public void process() { Microsoft.Office.Interop.Word.Document document = null; try { document = Globals.ThisAddIn.Application.ActiveDocument; } catch (Exception ex) { Mbox.ShowSimpleMsgBoxError("No document is open/active. Create or open a docx first."); return; } Model model = Model.ModelFactory(document); // Button shouldn't be available if this exists, // but .. if (model.conditionsPart == null) { conditions conditions = new conditions(); string conditionsXml = conditions.Serialize(); model.conditionsPart = addCustomXmlPart(document, conditionsXml); } if (model.componentsPart == null) { components components = new components(); string componentsXml = components.Serialize(); model.componentsPart = addCustomXmlPart(document, componentsXml); } // Add XPath xpaths xpaths = new xpaths(); // Button shouldn't be available if this exists, // but .. if (model.xpathsPart != null) { xpaths.Deserialize(model.xpathsPart.XML, out xpaths); } int idInt = 1; foreach (Word.ContentControl cc in Globals.ThisAddIn.Application.ActiveDocument.ContentControls) { if (cc.XMLMapping.IsMapped) { log.Debug("Adding xpath for " + cc.ID); // then we need to add an XPath string xmXpath = cc.XMLMapping.XPath; xpathsXpath item = new xpathsXpath(); // I make no effort here to check whether the xpath // already exists, since the part shouldn't already exist! item.id = "x" + idInt; xpathsXpathDataBinding db = new xpathsXpathDataBinding(); db.xpath = xmXpath; db.storeItemID = cc.XMLMapping.CustomXMLPart.Id; if (!string.IsNullOrWhiteSpace(cc.XMLMapping.PrefixMappings)) { db.prefixMappings = cc.XMLMapping.PrefixMappings; } item.dataBinding = db; xpaths.xpath.Add(item); // Write tag TagData td = new TagData(cc.Tag); td.set("od:xpath", item.id); cc.Tag = td.asQueryString(); log.Debug(".. added for " + cc.ID); idInt++; } } string xpathsXml = xpaths.Serialize(); if (model.xpathsPart == null) { model.xpathsPart = addCustomXmlPart(document, xpathsXml); } else { CustomXmlUtilities.replaceXmlDoc(model.xpathsPart, xpathsXml); } Microsoft.Office.Tools.Word.Document extendedDocument = Globals.ThisAddIn.Application.ActiveDocument.GetVstoObject(Globals.Factory); //Microsoft.Office.Tools.CustomTaskPane ctp // = Globals.ThisAddIn.createCTP(document, cxp, xpathsPart, conditionsPart, questionsPart, componentsPart); //extendedDocument.Tag = ctp; //// Want a 2 way association //WedTaskPane wedTaskPane = (WedTaskPane)ctp.Control; //wedTaskPane.associatedDocument = document; //extendedDocument.Shutdown += new EventHandler( // Globals.ThisAddIn.extendedDocument_Shutdown); //taskPane.setupCcEvents(document); log.Debug("Done. Task pane now also open."); }
//Procedure of game object’s moving along the path void Move() { Vector3 prePosition = Vector3.zero; if (prePointI == way.Count - 1) { gameObject.SendMessage("PursuitIsFinished"); curCondition = WaitingForRequest; return; } if (speed >= totalLength) { curCondition = WaitingForRequest; prePosition = transform.position; transform.position = way[way.Count - 1]; gameObject.SendMessage("PursuitIsFinished"); if (moveVectorOrientation) { FollowTheDirection(prePosition); } return; } if (Mathf.Abs(totalLength - CurrOffset) <= speed) { prePosition = transform.position; transform.position = way[way.Count - 1]; prePointI++; CurrOffset += totalLength - CurrOffset; curCondition = WaitingForRequest; gameObject.SendMessage("PursuitIsFinished"); if (moveVectorOrientation) { FollowTheDirection(prePosition); } return; } if (Vector3.Distance(transform.position, way[prePointI + 1]) > speed) { prePosition = transform.position; transform.position += speed * (way[prePointI + 1] - transform.position).normalized; CurrOffset += speed; if (moveVectorOrientation) { FollowTheDirection(prePosition); } return; } if (Vector3.Distance(transform.position, way[prePointI + 1]) == speed) { prePosition = transform.position; transform.position = way[prePointI + 1]; CurrOffset += speed; prePointI++; if (moveVectorOrientation) { FollowTheDirection(prePosition); } return; } if (Vector3.Distance(transform.position, way[prePointI + 1]) < speed) { float offset = 0; Vector3 cur_pos = transform.position; while ((speed - offset) > Vector3.Distance(way[prePointI + 1], cur_pos)) { offset += Vector3.Distance(way[prePointI + 1], cur_pos); prePointI++; cur_pos = way[prePointI]; if (prePointI + 1 == way.Count) { prePosition = transform.position; transform.position = cur_pos; if (moveVectorOrientation) { FollowTheDirection(prePosition); } return; } } cur_pos += (speed - offset) * (way[prePointI + 1] - way[prePointI]).normalized; prePosition = transform.position; transform.position = cur_pos; CurrOffset += speed; if (moveVectorOrientation) { FollowTheDirection(prePosition); } return; } }