public void DrawPresetPath(PathList path, Vector3 startPos) { Transform[] pathPoints = path.GetPoints(); for (int i = 0; i < pathPoints.Length;i++) { Vector3 currentPosition = pathPoints[i].position; SplitPoint split = pathPoints[i].GetComponent<SplitPoint>(); PersonPoint person = pathPoints[i].GetComponent<PersonPoint>(); if (person != null) { person.SetInfo(person.transform.position,(pathPoints[i+1].position-person.transform.position).normalized); SendMessageUpwards("MakePeople",person); } if (split != null) { foreach (PathList newPath in split.newPaths) { DrawPresetPath(newPath,startPos); } } else if (i != pathPoints.Length - 1) { Vector3 nextPosition = pathPoints[i+1].position; float initialDistance = Vector3.Distance(currentPosition, nextPosition); float numTiles = Mathf.Ceil(initialDistance/tileStep); for (int t = 0; t < numTiles; t++) { PathTile newTile = (PathTile)Instantiate(tilePrefab,currentPosition,tilePrefab.transform.rotation); currentPosition = currentPosition + ((nextPosition - currentPosition).normalized * tileStep); newTile.transform.LookAt(currentPosition, Vector3.up); newTile.transform.parent = _newPathGO.transform; } } } }
static string GetNiceText(PathList p) { var maxLength = 64; using (var w = new StringWriter()) { int length = 0; int i = 0; for (; i < p.Count;) { var s = p[i].ToString(); w.Write(s); length += s.Length; ++i; if (length > maxLength || i >= p.Count) { break; } s = ", "; w.Write(s); length += s.Length; } if (i < p.Count) { w.Write(", and {0} more", p.Count - i); } return(w.ToString()); } }
public King(bool isWhite, bool hasTextures = true) : base(isWhite) { if (hasTextures) { Texture = isWhite ? Resources.WhiteKing.ToBitmapSource() : Resources.BlackKing.ToBitmapSource(); } PathList.Add(PathFactory.AddToPath(Movement.Direction.Top).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.TopLeft).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.Left).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.BottomLeft).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.Bottom).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.BottomRight).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.Right).SetIsRecursive(false).Create()); PathList.Add(PathFactory.AddToPath(Movement.Direction.TopRight).SetIsRecursive(false).Create()); }
public void ApplyPathTransformation() { var fileList = new PathList <UoeFileToCompile>(); for (int i = 0; i < 1000; i++) { fileList.Add(new UoeFileToCompile(i.ToString())); } Assert.AreEqual(1000, fileList.Count); Assert.IsTrue(fileList.ToList().Exists(f => f.Path.Equals("0"))); fileList.ApplyPathTransformation(k => { k.Path = $"fu{k.Path}"; return(k); }); Assert.AreEqual(1000, fileList.Count, "wrong count"); Assert.IsTrue(fileList.ToList().Exists(f => f.Path.Equals("fu0")), "can't find fu0"); fileList.ApplyPathTransformation(k => { k.Path = "no"; return(k); }); Assert.AreEqual(1, fileList.Count, "should find only 1 because they all have the same key"); Assert.IsTrue(fileList.ToList().Exists(f => f.Path.Equals("no")), "can't find no"); }
public override object InformationToProperty(IInformation information, Type propertyType) { var value = information as IInformationValue; if (value == null) { throw new OptionReaderException(information.Lines.First().Number, information.Lines.Last().Number, $"'{information.Name}' must be a value type."); } try { var xElements = new List <XElement>(); // The path could contain wildcards, so use a PathList. var pathList = new PathList() { PathStorage = PathStorageMode.Relative }; pathList.Add(value.Value.Trim()); foreach (var path in pathList) { var xElement = new XElement("UserPage"); xElement.Add(new XElement("Path", PathUtils.ChangeExtension(path, ".html"))); xElement.Add(XmlUtils.WrapAndParse("Content", new Markdown().Transform(OtherUtils.ReadAllText(path)))); xElements.Add(xElement); } return(xElements); } catch (Exception e) { throw new OptionReaderException(information.Lines.First().Number, information.Lines.Last().Number, e.Message); } }
public void EditText(PathList pathList) { foreach (var i in pathList) { TextEditor.Open(i); } }
void InitPathData() { paths = new Dictionary <int, LinkedList <MetroEdge> >(); e2p = new Dictionary <MetroEdge, PathList>(); for (int mi = 0; mi < Metrolines.Count; mi++) { int[] Metroline = Metrolines[mi]; paths.Add(mi, new LinkedList <MetroEdge>()); for (int i = 0; i + 1 < Metroline.Length; i++) { MetroEdge me = MetroEdge.CreateFromTwoNodes(Metroline[i], Metroline[i + 1]); if (!e2p.ContainsKey(me)) { PathList pl = new PathList(); pl.edge = me; pl.paths = new HashSet <PathOnEdge>(); e2p.Add(me, pl); } PathOnEdge pathOnEdge = new PathOnEdge(); pathOnEdge.index = mi; pathOnEdge.node = paths[mi].AddLast(me); e2p[me].paths.Add(pathOnEdge); } } }
/// <summary> /// Includes a Javascript file inline. /// </summary> /// /// <param name="helper"> /// The current helper context. /// </param> /// <param name="script"> /// Full pathname of the server file. /// </param> /// <param name="attributes"> /// (optional) the attributes. /// </param> /// <param name="location"> /// (optional) The location of the script. This parameter can be used to move the script into the /// <head> tag of the document. /// </param> /// /// <returns> /// An HtmlString. /// </returns> public static IHtmlString Script <T>(this HtmlHelper <T> helper, string script, object attributes, ScriptLocations location) { string path = PathList.NormalizePath(PathList.NormalizeName(script)); var el = CQ.CreateFragment("<script />"); if (attributes != null) { el.AttrSet(attributes); } if (!el.HasAttr("type")) { el.Attr("type", "text/javascript"); } el.Attr("src", script + (script.EndsWith(".js", StringComparison.CurrentCultureIgnoreCase) ? "" : ".js") ); if (location == ScriptLocations.Head) { el.Attr("data-moveto", "head"); } return(new HtmlString(el.Render())); }
/// <summary> /// recursively build an order on the edge /// </summary> List <int> RestoreResult(MetroEdge edge) { List <int> res = new List <int>(); PathList pl = e2p[edge]; if (pl.subLists == null) { foreach (PathOnEdge path in pl.paths) { res.Add(path.index); } } else { foreach (PathList subList in pl.subLists) { List <int> subResult = RestoreResult(subList.edge); if (!(edge.Source() == subList.edge.Source() || edge.Target() == subList.edge.Target())) { subResult.Reverse(); } res.AddRange(subResult); } } return(res); }
internal void Reset() { GremlinVariable inputVariable = null; if (VariableList.First() is GremlinContextVariable) { inputVariable = VariableList.First(); } PivotVariable = null; Predicates = null; VariableList.Clear(); TableReferences.Clear(); PathList.Clear(); StepList.Clear(); IsPopulateGremlinPath = false; CurrentContextPath = null; ProjectVariablePropertiesList.Clear(); ProjectedProperties.Clear(); //reserve the InputVariable if (inputVariable != null) { VariableList.Add(inputVariable); } }
private PathList CreateSegment(int number, Vector3[] points) { PathList pathList = new PathList("Road " + number, points); if (RoadType == InfrastructureType.Road) { pathList.Width = 10f; pathList.InnerPadding = 1f; pathList.OuterPadding = 1f; pathList.InnerFade = 1f; pathList.OuterFade = 8f; pathList.RandomScale = 0.75f; pathList.MeshOffset = 0f; pathList.TerrainOffset = -0.125f; pathList.Topology = 2048; pathList.Splat = 128; } else { float num = 0.4f; pathList.Width = 4f; pathList.InnerPadding = 1f * num; pathList.OuterPadding = 1f; pathList.InnerFade = 1f; pathList.OuterFade = 8f; pathList.RandomScale = 0.75f; pathList.MeshOffset = 0f; pathList.TerrainOffset = -0.125f; pathList.Topology = 2048; pathList.Splat = 1; } return(pathList); }
public ScriptCollectionTest() { var html = Support.GetFile("CsQuery.Mvc.Tests/Views/Test/Index6.cshtml"); Dom = CQ.Create(html); pathList = new PathList(); pathList.Add("~/scripts"); }
public object Clone() { IChessPiece clonedChessPiece; if (this is Pawn) { clonedChessPiece = new Pawn(IsWhite(), false) { DidMove = DidMove, PathList = PathList.Select(path => path.ClonePath()).ToList(), EatList = EatList }; } else if (this is King) { clonedChessPiece = new King(IsWhite(), false) { DidMove = DidMove, PathList = PathList.Select(path => path.ClonePath()).ToList(), }; } else if (this is Queen) { clonedChessPiece = new Queen(IsWhite(), false) { DidMove = DidMove, PathList = PathList.Select(path => path.ClonePath()).ToList(), }; } else if (this is Rook) { clonedChessPiece = new Rook(IsWhite(), false) { DidMove = DidMove, PathList = PathList.Select(path => path.ClonePath()).ToList(), }; } else if (this is Knight) { clonedChessPiece = new Knight(IsWhite(), false) { DidMove = DidMove, PathList = PathList.Select(path => path.ClonePath()).ToList(), }; } else if (this is Bishop) { clonedChessPiece = new Bishop(IsWhite(), false) { DidMove = DidMove, PathList = PathList.Select(path => path.ClonePath()).ToList(), }; } else { throw new NotImplementedException(); } return(clonedChessPiece); }
/// <summary> /// Parses the content of a RAF from a previously initialized <see cref="BinaryReader"/>. /// </summary> /// <param name="br"><see cref="BinaryReader"/> instance containing data from a RAF.</param> private void Read(BinaryReader br) { uint magic = br.ReadUInt32(); if (magic != Magic) { throw new InvalidMagicNumberException(magic); } this.Version = br.ReadInt32(); this.ManagerIndex = br.ReadInt32(); uint fileListOffset = br.ReadUInt32(); uint pathListOffset = br.ReadUInt32(); // Reading file list br.BaseStream.Seek(fileListOffset, SeekOrigin.Begin); int fileCount = br.ReadInt32(); for (int i = 0; i < fileCount; i++) { this.Files.Add(new RAFFileEntry(this, br)); } // Reading path list br.BaseStream.Seek(pathListOffset, SeekOrigin.Begin); PathList pathList = new PathList(br); foreach (RAFFileEntry fileEntry in this.Files) { fileEntry.Path = pathList.Paths[fileEntry.PathListIndex]; } }
public void WildcardWithExtensionNoMatch() { var pathColl = new PathList(); pathColl.Add("*.noMatch"); Assert.AreEqual(0, pathColl.Count); }
/// <summary> /// Writes the content of the current <see cref="RAF"/> in a previously initialized <see cref="BinaryReader"/>. /// </summary> /// <param name="bw"></param> private void Write(BinaryWriter bw) { // Preparing file entries before writing this.Files.Sort(); for (int i = 0; i < this.Files.Count; i++) { this.Files[i].PathListIndex = i; } bw.Write(Magic); bw.Write(this.Version); bw.Write(this.ManagerIndex); // File list offset bw.Write(20); // Path list offset int pathListOffset = 24 + (this.Files.Count * 16); bw.Write(pathListOffset); bw.Write(this.Files.Count); foreach (RAFFileEntry fileEntry in this.Files) { fileEntry.Write(bw); } PathList pathList = new PathList(this.Files); pathList.Write(bw); }
public void createStringBasedPath(string path) //dodaje sciezke do listy scieżek na podstawie stringa z ciągiem wierzchołków { Path createdPath = null; try { if (!String.IsNullOrEmpty(path)) { int b = 0; string[] nbsVertices = path.Split(' '); createdPath = new Path(Int32.Parse(nbsVertices[0]) + 1, Int32.Parse(nbsVertices[nbsVertices.GetLength(0) - 1]) + 1); PathList.Add(createdPath); for (int a = 0; a < nbsVertices.GetLength(0) - 1; a++) { b = a + 1; PathList[PathList.Count - 1].edgesInPath.Add(getEdge(Int32.Parse(nbsVertices[a]) + 1, Int32.Parse(nbsVertices[b]) + 1, EdgeList)); } } } catch (System.FormatException e) { LogClass.WhiteLog("[RC] Can't find path with this capacity"); PathList.Remove(createdPath); } }
public void WildcardNoDirectory() { var pathColl = new PathList(); pathColl.Add(@"NoDirectory\*.txt"); Assert.AreEqual(4, pathColl.Count); }
protected virtual object commandSaveExecute(object parameter) { if (PathList != null) { //Clear item with empty information for (int i = PathList.Count - 1; i >= 0; i--) { PathItem item = PathList[i]; if (String.IsNullOrWhiteSpace(item.Name) || String.IsNullOrWhiteSpace(item.Path)) { PathList.RemoveAt(i); continue; } item.Path = item.Path.TrimEnd('\\'); } //Order list to save IList <PathItem> orderList = (from p in PathList orderby p.Name select p).ToList <PathItem>(); PathList.Clear(); foreach (var item in orderList) { PathList.Add(item); } //Save XML File if (GlobalHelper.SaveFolderFile(orderList, GlobalHelper.FOLDERS_FILE_PATH)) { MessageBox.Show(Resources.AddFolderPathVM_commandSaveExecute_SuccessMessage, Resources.AddFolderPathVM_commandSaveExecute_SuccessTitle, MessageBoxButton.OK, MessageBoxImage.Information); ListChanged = true; } } return(null); }
public void HandleOpenDialog(object sender, RoutedEventArgs e) { var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog(); dialog.ShowDialog(); if (string.IsNullOrEmpty(dialog.SelectedPath)) { return; } if (PathList.Contains(dialog.SelectedPath)) { var selectedIndex = PathList.IndexOf(dialog.SelectedPath); SelectedIndex = selectedIndex; return; } var newPathList = new List <string>() { dialog.SelectedPath }; var nextPathList = newPathList.Concat(PathList).ToList(); PathList = nextPathList; SelectedIndex = 0; }
public void FileNameWildcard() { var pathColl = new PathList { "*" }; Assert.AreEqual(2, pathColl.Count); }
public void DoubleWildcardNoDirectory() { var pathColl = new PathList { @"NoDirectory\**\*.txt" }; Assert.AreEqual(4, pathColl.Count); }
public void DirectoryWildcardWithExtensionMatch() { var pathColl = new PathList { @"Folder1\*.txt" }; Assert.AreEqual(1, pathColl.Count); }
/* public */ public void Load() { if (File.Exists(FilePath)) { PathList.Clear(); Sys.Load(this, FilePath); } }
protected virtual object commandRemoveExecute(object parameter) { if (PathList != null) { PathList.Remove(SelectedPath); } return(null); }
private void RemoveSelectedPath_btn_Click(object sender, EventArgs e) { var itemToRemove = PathList.SelectedItem; PathList.Items.Remove(itemToRemove); PathList.Refresh(); PathToWatchList.PathToWatches.Remove(PathToWatchList.PathToWatches.FirstOrDefault(x => x.Path == itemToRemove.ToString())); }
public void RemoveWildCardPath() { var pathColl = new PathList { @"Folder1\**\*.txt" }; pathColl.Remove(@"Folder1\**\*.txt"); }
public ScriptCollectionTest() { var html = Support.GetFile("CsQuery.Mvc.Tests/Views/Test/unresolvedscripts.cshtml"); Dom = CQ.Create(html); pathList = new PathList(); pathList.Add("~/scripts"); }
public void JustDoubleWildcard() { var pathColl = new PathList { "**/*.txt" }; Assert.AreEqual(7, pathColl.Count); }
/// <summary> /// 设置历史轨迹执行的值 /// </summary> public void SetHistoryPath(float v) { //foreach (LocationHistoryPath hispath in historyPaths) //{ // hispath.Set(v); //} PathList.SetHistoryPath(v); }
public void FileExistsAtNormalPath() { var pathColl = new PathList { "File1.txt" }; Assert.AreEqual(1, pathColl.Count); Assert.AreEqual(Path.GetFullPath("File1.txt"), pathColl.First()); }
// Use this for initialization void Start() { //at GO press = false; Plist = new PathList(); Plist.initList(); turn = 0; CurrentPos = new Vector3(0,5,0); }
private void RemoveAllPath_btn_Click(object sender, EventArgs e) { for (int i = 0; i <= PathList.Items.Count; i++) { i = 0; PathList.Items.RemoveAt(i); } PathList.Refresh(); }
public void Normalizing() { PathList list = new PathList(); list.Add("libs"); list.Add("/libs2"); list.Add("~/libs3"); CollectionAssert.AreEqual(new string[] { "~/libs/", "~/libs2/", "~/libs3/"}, list.ToList()); }
/// <summary> /// Default constructor; creates this ScriptManager for the specified library path & MapPath /// function. /// </summary> /// /// <param name="libraryPath"> /// The paths in the library search path. /// </param> /// <param name="mapPathFunc"> /// The map path function. /// </param> public ScriptManager(PathList libraryPath, Func<string,string> mapPathFunc) { if (mapPathFunc == null) { throw new ArgumentException("The MapPath function cannot be null."); } if (libraryPath == null) { throw new ArgumentException("The LibraryPath cannot be null."); } Initialize(libraryPath, mapPathFunc); }
public void OptionParsing() { PathList list = new PathList(); list.Add("~/libs"); list.Add("~/libs2"); var coll = new ScriptCollection(list, TestUtil.MapPath); coll.AddPath("~/scripts/test-script-3.js"); Assert.AreEqual(coll.Count, 1); }
public void DrawPath(Vector3 startPos) { if (presetPath == null) { //Draw procedural path. } else { _path = (PathList)Instantiate(presetPath,startPos,Quaternion.identity); _path.transform.parent = this.transform; _newPathGO = new GameObject("NewPath"); _newPathGO.transform.parent = this.transform; DrawPresetPath(_path, startPos); } _newPathGO.transform.Translate(0f,-.75f,0f); }
public void Start() { streams = new ObjectStream<Streams>(template, spawnRate, 16, () => { var path = new PathList(); path.Add(new LinearPath {origin = this.gameObject, target = target}); path.Add(new FadeOutPath {offset = 0.5f}); return new SpawnData<Streams> { stream = Streams.STREAM_0, manager = AnimationManager.Default, path = path, origin = new NTransform(target), curve = new Linear(lifeTime) }; }); }
public void GetName() { PathList list = new PathList(); list.Add("libs"); list.Add("/libs2"); list.Add("~/libs3"); Assert.AreEqual("test.js", list.GetName("test")); Assert.AreEqual("test.js", list.GetName("test.js")); Assert.AreEqual("test.js", list.GetName("~/test.js")); Assert.AreEqual("test.js", list.GetName("~/libs/test.js")); Assert.AreEqual("test.js", list.GetName("/libs/test.js")); Assert.AreEqual("test.js", list.GetName("~/libs3/test.js")); Assert.AreEqual("something/test.js", list.GetName("something/test.js")); Assert.AreEqual("something/test.js", list.GetName("~/libs2/something/test")); }
public void Start() { streams = new ObjectStream<Streams>(template, spawnRate, 16, () => { var path = new PathList(); path.Add(new ArcFixedPath {Origin = this.gameObject, Target = target, Speed = speed, Height = 2f, Up = new Vector3(0f, 1f, 0f)}); path.Add(new FadeOutDistance {offset = fadeOutAt, target = target}); path.Add(new FadeInDistance {distance = fadeInOver}); return new SpawnData<Streams> { stream = Streams.STREAM_2, manager = AnimationManager.Default, path = path, origin = new NTransform(gameObject), curve = new Linear(lifeTime) }; }); }
public void OptionParsing() { PathList list = new PathList(); list.Add("~/scripts/libs"); list.Add("~/scripts/libs2"); var coll = new ScriptCollection(new ScriptEnvironment { RelativePathRoot= "/", LibraryPath= list, MapPath = TestUtil.MapPath }); coll.AddPath("~/scripts/test-script-3.js"); Assert.AreEqual(coll.Count, 1); }
// Use this for initialization void Start() { takeAttack = false; DuelMode = false; winwidth = Screen.width; winheight = Screen.height; Debug.Log(winwidth+" "+winheight); // initialise 4player game Vector3 st = new Vector3(0,5,0); long amount = 250000; startTime =0; deltaTime = 0.5f; pause = false; rollyes = false; totalPlayers = 4; turn = 0; for(int i=0;i<64;i++) InfoBox[i]=-1; float x=-0.08f,y=-0.095f,wx=0.23f,wy=0.2f; Rect A = new Rect(x*winwidth,y*winheight,wx*winwidth,wy*winheight); wx = 0.05f; wy=0.1f; y = -0.077f; Rect B1 = new Rect(x*winwidth,y*winheight,wx*winwidth,wy*winheight); float bX = -0.09f; float bY = -0.1f; float bH = 0.04f; float bW = 0.02f; Rect B2 = new Rect(bX*winwidth,bY*winheight,bW*winwidth,bH*winheight); for(int i=0;i<totalPlayers;i++) { Players[i] = new GamePlayers(); Players[i].init(i, amount, st, 0, 0, 0, 0, 5,true); PlayerTextures[i].pixelInset = A; PlayerTextures[i].transform.Find("logo").guiTexture.pixelInset = B1; PlayerTextures[i].transform.Find("cuff1").guiTexture.pixelInset = B2; PlayerTextures[i].transform.Find("cuff2").guiTexture.pixelInset = B2; PlayerTextures[i].transform.Find("cuff3").guiTexture.pixelInset = B2; } wx = 0.05f; wy = 0.05f; Rect D1 = new Rect(x*winwidth,y*winheight,wx*winwidth,wy*winwidth); Dice1.pixelInset = D1; y=0.0001f; Rect D2 = new Rect(x*winwidth,y*winheight,wx*winwidth,wy*winwidth); Dice2.pixelInset = D2; Vector3 startpos = new Vector3(0,7.5f,0); GobPlayer = new GameObject[4]; // GobPlayer = Resources.LoadAll("Player") as GameObject[]; float tosub=-1; for(int i=0;i<totalPlayers;i++) { GameObject instanceg = new GameObject(); startpos.x = tosub + i; instanceg = Instantiate(PlayerFab,startpos,transform.rotation) as GameObject; GobPlayer[i] = instanceg; for(int j=0;j<4;j++) GobPlayer[i].transform.Find("Pcam"+j).camera.enabled = false; gameObject.transform.Find("Camera"+i).camera.enabled = false; /// gameObject.transform.Find("Camera"+i).camera.transform.Find("AmbientLight").light.enabled = false; } gameObject.transform.Find("Camera0").camera.enabled = true; // gameObject.transform.Find("Camera0").camera.transform.Find("AmbientLight").light.enabled= true; Plist = new PathList(); Plist.initList(); GameObject instance = new GameObject(); instance = Instantiate(Dicefab,instance.transform.position,instance.transform.rotation) as GameObject; instance.name="Dicer1"; GameObject instance2 = new GameObject(); instance2 = Instantiate(Dice2fab,instance2.transform.position,transform.rotation) as GameObject; instance2.name="Dicer2"; V1Dice = instance.GetComponent<DiceValue>(); V2Dice = instance2.GetComponent<DiceValue>(); Dice1 = Instantiate(Dice1) as GUITexture; Dice2 = Instantiate (Dice2) as GUITexture; initDepartments(); // Debug.Log("gameinited"); }
void HandleDragDataGet(object sender, DragDataGetArgs args) { Logger.Debug ("ImagesFileView.HandleDragDataGet. Sender {0}, args {1}", sender, args.Info); string file; TreeIter iter; TreePath[] items = SelectedItems; PathList list = new PathList (); for (int i = 0; i < items.Length; i++) { store.GetIter (out iter, items [i]); file = (string) store.GetValue (iter, 0); Logger.Debug ("ImagesFileView.HandleDragDataGet. Dropped {0}", file); list.Add (file); } switch (args.Info) { case 2: { Byte [] data = Encoding.UTF8.GetBytes (list.ToString ()); Atom [] targets = args.Context.Targets; args.SelectionData.Set (targets[0], 2, data); Logger.Debug ("ImagesFileView.HandleDragDataGet. Data.Length {0}", data.Length); return; } default: Logger.Debug ("ImagesFileView.HandleDragDataGet. Drop cancelled"); break; } args.RetVal = true; }
void InitPathData() { paths = new Dictionary<int, LinkedList<MetroEdge>>(); e2p = new Dictionary<MetroEdge, PathList>(); for (int mi = 0; mi < Metrolines.Count; mi++) { int[] Metroline = Metrolines[mi]; paths.Add(mi, new LinkedList<MetroEdge>()); for (int i = 0; i + 1 < Metroline.Length; i++) { MetroEdge me = MetroEdge.CreateFromTwoNodes(Metroline[i], Metroline[i + 1]); if (!e2p.ContainsKey(me)) { PathList pl = new PathList(); pl.edge = me; pl.paths = new HashSet<PathOnEdge>(); e2p.Add(me, pl); } PathOnEdge pathOnEdge = new PathOnEdge(); pathOnEdge.index = mi; pathOnEdge.node = paths[mi].AddLast(me); e2p[me].paths.Add(pathOnEdge); } } }
/// <summary> /// Linear sorting of paths passing through vertex v /// </summary> Dictionary<MetroEdge, List<PathList>> RadixSort(int v) { //build a map [old_edge => list_of_paths_on_it]; the relative order of paths is important Dictionary<MetroEdge, List<PathOnEdge>> r = new Dictionary<MetroEdge, List<PathOnEdge>>(); //first index in circular order Dictionary<MetroEdge, int> firstIndex = new Dictionary<MetroEdge, int>(); foreach (MetroEdge oldEdge in orderedAdjacent[v]) { PathList pathList = e2p[oldEdge]; foreach (PathOnEdge path in pathList.paths) { MetroEdge ej = FindNextEdgeOnPath(v, path); CollectionUtilities.AddToMap(r, ej, path); } firstIndex.Add(oldEdge, (r.ContainsKey(oldEdge) ? r[oldEdge].Count : 0)); } //oldEdge => SortedPathLists Dictionary<MetroEdge, List<PathList>> res = new Dictionary<MetroEdge, List<PathList>>(); //build the desired order for each edge foreach (MetroEdge oldEdge in orderedAdjacent[v]) { //r[oldEdge] is the right order! (up to the circleness) List<PathOnEdge> paths = r[oldEdge]; Debug.Assert(paths.Count > 0); List<PathList> subLists = new List<PathList>(); HashSet<PathOnEdge> curPathSet = new HashSet<PathOnEdge>(); for (int j = 0; j < paths.Count; j++) { int i = (j + firstIndex[oldEdge]) % paths.Count; MetroEdge nowEdge = paths[i].node.Value; MetroEdge nextEdge = paths[(i + 1) % paths.Count].node.Value; curPathSet.Add(paths[i]); if (j == paths.Count - 1 || nowEdge != nextEdge) { //process MetroEdge newEdge = MetroEdge.CreateFromTwoEdges(v, oldEdge, nowEdge); PathList pl = new PathList(); pl.edge = newEdge; pl.paths = curPathSet; subLists.Add(pl); //clear curPathSet = new HashSet<PathOnEdge>(); } } if (oldEdge.Source() == v) subLists.Reverse(); res.Add(oldEdge, subLists); } return res; }
private void PrepareTargetList(PathList path) { _splitPoint = null; foreach (Transform target in path.pathPoints) { _listOfTargets.Add(target); SplitPoint split = target.GetComponent<SplitPoint>(); if (split != null) { _splitPoint = split; //TODO this only accounts for two path choices. Vector3 midPosition = Vector3.zero; for (int i = 0; i < _splitPoint.newPaths.Length;i++) { midPosition += _splitPoint.newPaths[i].pathPoints[2].position; } CreateChoiceItem(); midPosition /= _splitPoint.newPaths.Length; _arrow = (Arrow)Instantiate(arrowPrefab,midPosition,Quaternion.identity); _arrow.transform.parent = _splitPoint.transform; _choiceIsReady = true; Transform nextPath = GetNextPathChoice(); _arrow.SetTarget(nextPath); SetLabelsActive(nextPath); scoreManager.AddRound(); } } }
public PathList[] GetPath(PathfinderNode[] StartNodes, PathfinderNode FinishNode, int Accuracy, int MinClearance) { int num; int num4; int num9; int num13 = StartNodes.GetUpperBound(0) + 1; PathList[] listArray2 = new PathList[(this.NodeLayerCount - 1) + 1]; PathfinderNode[,] nodeArray3 = new PathfinderNode[(this.NodeLayerCount - 1) + 1, (num13 - 1) + 1]; PathfinderNode[] nodeArray2 = new PathfinderNode[(this.NodeLayerCount - 1) + 1]; PathfinderNode[] nodeArray = new PathfinderNode[0x18]; int[] numArray2 = new int[0x18]; bool[] flagArray = new bool[(num13 - 1) + 1]; Path[] pathArray = new Path[0x18]; float[] numArray = new float[0x18]; bool[] flagArray2 = this.NetworkLargeArrays.Nodes_Booleans; float[] numArray3 = this.NetworkLargeArrays.Nodes_ValuesA; PathfinderNode[] nodeArray4 = this.NetworkLargeArrays.Nodes_Nodes; Path path = this.NetworkLargeArrays.Nodes_Path; int index = StartNodes[0].Layer.Network_LayerNum; nodeArray2[index] = FinishNode; int num2 = index; while (true) { if (nodeArray2[num2].ParentNode == null) { num9 = num2; break; } nodeArray2[num2 + 1] = nodeArray2[num2].ParentNode; num2++; } int num14 = num13 - 1; for (num = 0; num <= num14; num++) { nodeArray3[index, num] = StartNodes[num]; num2 = index; while (true) { if (nodeArray3[num2, num].ParentNode == null) { if (nodeArray3[num2, num] == nodeArray2[num2]) { flagArray[num] = true; num4++; } break; } nodeArray3[num2 + 1, num] = nodeArray3[num2, num].ParentNode; num2++; } } if (num4 != 0) { int num11 = num9; listArray2[num11].Paths = new Path[] { new Path() }; listArray2[num11].PathCount = 1; listArray2[num11].Paths[0].Nodes = new PathfinderNode[] { nodeArray2[num11] }; listArray2[num11].Paths[0].NodeCount = 1; do { int num3; int num5; int num6; int num7; bool flag; int num12; bool flag3; PathfinderNode node; PathfinderNode otherNode; int num10 = num11; num11--; if (num11 < index) { return listArray2; } if (flag3) { if (Accuracy < 0) { Debugger.Break(); } int num15 = listArray2[num10].PathCount - 1; for (num12 = 0; num12 <= num15; num12++) { numArray2[num12] = Math.Min(Accuracy, listArray2[num10].Paths[num12].NodeCount - 1); } nodeArray[0] = listArray2[num10].Paths[0].Nodes[numArray2[0]]; num6 = 1; flag = true; } else { if (Accuracy >= 0) { int num16 = listArray2[num10].PathCount - 1; for (num12 = 0; num12 <= num16; num12++) { if (listArray2[num10].Paths[num12].NodeCount > Accuracy) { flag3 = true; break; } } } nodeArray[0] = nodeArray2[num11]; if (num11 == index) { num6 = 1; } else { int num17 = nodeArray[0].ConnectionCount - 1; num = 0; while (num <= num17) { nodeArray[1 + num] = nodeArray[0].Connections[num].GetOtherNode(nodeArray[0]); num++; } num6 = 1 + nodeArray[0].ConnectionCount; } int num18 = listArray2[num10].PathCount - 1; for (num12 = 0; num12 <= num18; num12++) { numArray2[num12] = listArray2[num10].Paths[num12].NodeCount - 1; } flag = false; } int num19 = listArray2[num10].PathCount - 1; for (num12 = 0; num12 <= num19; num12++) { int num20 = numArray2[num12]; num = 0; while (num <= num20) { node = listArray2[num10].Paths[num12].Nodes[num]; int num21 = node.ConnectionCount - 1; num5 = 0; while (num5 <= num21) { otherNode = node.Connections[num5].GetOtherNode(node); int num22 = otherNode.ConnectionCount - 1; num7 = 0; while (num7 <= num22) { num3 = otherNode.Connections[num7].GetOtherNode(otherNode).Layer_NodeNum; flagArray2[num3] = false; num7++; } num5++; } num++; } } int num23 = listArray2[num10].PathCount - 1; num12 = 0; while (num12 <= num23) { int num24 = numArray2[num12]; num = 0; while (num <= num24) { node = listArray2[num10].Paths[num12].Nodes[num]; num3 = node.Layer_NodeNum; flagArray2[num3] = true; int num25 = node.NodeCount - 1; num7 = 0; while (num7 <= num25) { num3 = node.Nodes[num7].Layer_NodeNum; numArray3[num3] = float.MaxValue; num7++; } int num26 = node.ConnectionCount - 1; for (num5 = 0; num5 <= num26; num5++) { otherNode = node.Connections[num5].GetOtherNode(node); num3 = otherNode.Layer_NodeNum; flagArray2[num3] = true; int num27 = otherNode.NodeCount - 1; for (num7 = 0; num7 <= num27; num7++) { num3 = otherNode.Nodes[num7].Layer_NodeNum; numArray3[num3] = float.MaxValue; } } num++; } num12++; } sFloodRouteArgs args = new sFloodRouteArgs { CurrentPath = path, FinishNodes = nodeArray, FinishNodeCount = num6, FinishIsParent = flag, Visit = flagArray2, NodeValues = numArray3, SourceNodes = nodeArray4, MinClearance = MinClearance }; int num28 = num6 - 1; for (num = 0; num <= num28; num++) { pathArray[num] = null; numArray[num] = float.MaxValue; } int num29 = num13 - 1; for (num = 0; num <= num29; num++) { if (flagArray[num]) { path.NodeCount = 1; path.Nodes[0] = nodeArray3[num11, num]; path.Value = 0f; args.BestPaths = new Path[(num6 - 1) + 1]; this.FloodRoute(ref args); int num30 = num6 - 1; num12 = 0; while (num12 <= num30) { if ((args.BestPaths[num12] != null) && (args.BestPaths[num12].Value < numArray[num12])) { numArray[num12] = args.BestPaths[num12].Value; pathArray[num12] = args.BestPaths[num12]; } num12++; } } } listArray2[num11].Paths = new Path[(num6 - 1) + 1]; listArray2[num11].PathCount = 0; int num31 = num6 - 1; for (num12 = 0; num12 <= num31; num12++) { if (pathArray[num12] != null) { listArray2[num11].Paths[listArray2[num11].PathCount] = pathArray[num12]; PathList[] listArray3 = listArray2; int num32 = num11; listArray3[num32].PathCount++; } } listArray2[num11].Paths = (Path[]) Utils.CopyArray((Array) listArray2[num11].Paths, new Path[(listArray2[num11].PathCount - 1) + 1]); } while (listArray2[num11].PathCount != 0); } return null; }
private void Initialize(PathList libraryPath, Func<string, string> mapPathFunc, Func<string, string> resolveUrlFunc) { MapPath = mapPathFunc ?? HttpContext.Current.Server.MapPath; ResolveUrl = resolveUrlFunc ?? DefaultResolveUrlFunc; LibraryPath = libraryPath ?? new PathList(); }
private void Initialize(PathList libraryPath, Func<string, string> mapPathFunc, Func<string, string> resolveUrlFunc) { ScriptEnvironment = new ScriptEnvironment { MapPath = mapPathFunc, LibraryPath = libraryPath, ResolveUrl = resolveUrlFunc }; }
private void Initialize(PathList libraryPath, Func<string, string> mapPathFunc) { MapPath = mapPathFunc ?? HttpContext.Current.Server.MapPath; LibraryPath = libraryPath ?? new PathList(); }
/// <summary> /// Default constructor. /// </summary> public CsQueryViewEngine() { LibraryPath = new PathList(); LibraryPath.Add("~/scripts/lib"); }
public PathList[] GetPath(PathfinderNode[] StartNodes, PathfinderNode FinishNode, int Accuracy, int MinClearance) { int StartNodeCount = StartNodes.GetUpperBound(0) + 1; PathList[] Paths = new PathList[NodeLayerCount]; PathfinderNode[,] LayerStartNodes = new PathfinderNode[NodeLayerCount, StartNodeCount]; PathfinderNode[] LayerFinishNodes = new PathfinderNode[NodeLayerCount]; int LayerNum = 0; PathfinderNode[] Destinations = new PathfinderNode[24]; int DestinationCount = 0; bool FinishIsParent = default(bool); bool IsInaccurate; int[] CalcNodeCount = new int[24]; sFloodRouteArgs FloodRouteArgs = new sFloodRouteArgs(); int FinalLayer = 0; bool[] StartCanReach = new bool[StartNodeCount]; PathfinderNode tmpNodeA = default(PathfinderNode); PathfinderNode tmpNodeB = default(PathfinderNode); int CanReachCount = 0; int FirstLayer = 0; Path[] BestPaths = new Path[24]; float[] BestValues = new float[24]; int PathNum = 0; bool StopMultiPathing = default(bool); bool[] Visit = NetworkLargeArrays.Nodes_Booleans; float[] NodeValues = NetworkLargeArrays.Nodes_ValuesA; PathfinderNode[] Nodes_Nodes = NetworkLargeArrays.Nodes_Nodes; Path StartPath = NetworkLargeArrays.Nodes_Path; int A = 0; int B = 0; int C = 0; int D = 0; int E = 0; FinalLayer = StartNodes[0].Layer.Network_LayerNum; LayerFinishNodes[FinalLayer] = FinishNode; B = FinalLayer; do { if ( LayerFinishNodes[B].ParentNode == null ) { FirstLayer = B; break; } LayerFinishNodes[B + 1] = LayerFinishNodes[B].ParentNode; B++; } while ( true ); for ( A = 0; A <= StartNodeCount - 1; A++ ) { LayerStartNodes[FinalLayer, A] = StartNodes[A]; B = FinalLayer; do { if ( LayerStartNodes[B, A].ParentNode == null ) { if ( LayerStartNodes[B, A] == LayerFinishNodes[B] ) { StartCanReach[A] = true; CanReachCount++; } break; } LayerStartNodes[B + 1, A] = LayerStartNodes[B, A].ParentNode; B++; } while ( true ); } if ( CanReachCount == 0 ) { return null; } LayerNum = FirstLayer; Paths[LayerNum].Paths = new Path[0]; Paths[LayerNum].Paths[0] = new Path(); Paths[LayerNum].PathCount = 1; Paths[LayerNum].Paths[0].Nodes = new PathfinderNode[1]; Paths[LayerNum].Paths[0].Nodes[0] = LayerFinishNodes[LayerNum]; Paths[LayerNum].Paths[0].NodeCount = 1; int LastLayer = 0; do { LastLayer = LayerNum; LayerNum--; if ( LayerNum < FinalLayer ) { break; } else if ( StopMultiPathing ) { if ( Accuracy < 0 ) { Debugger.Break(); } for ( PathNum = 0; PathNum <= Paths[LastLayer].PathCount - 1; PathNum++ ) { CalcNodeCount[PathNum] = Math.Min(Accuracy, Convert.ToInt32(Paths[LastLayer].Paths[PathNum].NodeCount - 1)); } Destinations[0] = Paths[LastLayer].Paths[0].Nodes[CalcNodeCount[0]]; DestinationCount = 1; FinishIsParent = true; IsInaccurate = true; } else { if ( Accuracy >= 0 ) { for ( PathNum = 0; PathNum <= Paths[LastLayer].PathCount - 1; PathNum++ ) { if ( Paths[LastLayer].Paths[PathNum].NodeCount > Accuracy ) { StopMultiPathing = true; break; } } } Destinations[0] = LayerFinishNodes[LayerNum]; if ( LayerNum == FinalLayer ) { DestinationCount = 1; } else { for ( A = 0; A <= Destinations[0].ConnectionCount - 1; A++ ) { Destinations[1 + A] = Destinations[0].Connections[A].GetOtherNode(Destinations[0]); } DestinationCount = 1 + Destinations[0].ConnectionCount; } for ( PathNum = 0; PathNum <= Paths[LastLayer].PathCount - 1; PathNum++ ) { CalcNodeCount[PathNum] = Paths[LastLayer].Paths[PathNum].NodeCount - 1; } FinishIsParent = false; } for ( PathNum = 0; PathNum <= Paths[LastLayer].PathCount - 1; PathNum++ ) { for ( A = 0; A <= CalcNodeCount[PathNum]; A++ ) { tmpNodeA = Paths[LastLayer].Paths[PathNum].Nodes[A]; for ( D = 0; D <= tmpNodeA.ConnectionCount - 1; D++ ) { tmpNodeB = tmpNodeA.Connections[D].GetOtherNode(tmpNodeA); for ( E = 0; E <= tmpNodeB.ConnectionCount - 1; E++ ) { C = tmpNodeB.Connections[E].GetOtherNode(tmpNodeB).Layer_NodeNum; Visit[C] = false; } } } } for ( PathNum = 0; PathNum <= Paths[LastLayer].PathCount - 1; PathNum++ ) { for ( A = 0; A <= CalcNodeCount[PathNum]; A++ ) { tmpNodeA = Paths[LastLayer].Paths[PathNum].Nodes[A]; C = tmpNodeA.Layer_NodeNum; Visit[C] = true; for ( E = 0; E <= tmpNodeA.NodeCount - 1; E++ ) { C = tmpNodeA.Nodes[E].Layer_NodeNum; NodeValues[C] = float.MaxValue; } for ( D = 0; D <= tmpNodeA.ConnectionCount - 1; D++ ) { tmpNodeB = tmpNodeA.Connections[D].GetOtherNode(tmpNodeA); C = tmpNodeB.Layer_NodeNum; Visit[C] = true; for ( E = 0; E <= tmpNodeB.NodeCount - 1; E++ ) { C = tmpNodeB.Nodes[E].Layer_NodeNum; NodeValues[C] = float.MaxValue; } } } } FloodRouteArgs = new sFloodRouteArgs(); FloodRouteArgs.CurrentPath = StartPath; FloodRouteArgs.FinishNodes = Destinations; FloodRouteArgs.FinishNodeCount = DestinationCount; FloodRouteArgs.FinishIsParent = FinishIsParent; FloodRouteArgs.Visit = Visit; FloodRouteArgs.NodeValues = NodeValues; FloodRouteArgs.SourceNodes = Nodes_Nodes; FloodRouteArgs.MinClearance = MinClearance; for ( A = 0; A <= DestinationCount - 1; A++ ) { BestPaths[A] = null; BestValues[A] = float.MaxValue; } for ( A = 0; A <= StartNodeCount - 1; A++ ) { if ( StartCanReach[A] ) { StartPath.NodeCount = 1; StartPath.Nodes[0] = LayerStartNodes[LayerNum, A]; StartPath.Value = 0.0F; FloodRouteArgs.BestPaths = new Path[DestinationCount]; FloodRoute(FloodRouteArgs); for ( PathNum = 0; PathNum <= DestinationCount - 1; PathNum++ ) { if ( FloodRouteArgs.BestPaths[PathNum] != null ) { if ( FloodRouteArgs.BestPaths[PathNum].Value < BestValues[PathNum] ) { BestValues[PathNum] = FloodRouteArgs.BestPaths[PathNum].Value; BestPaths[PathNum] = FloodRouteArgs.BestPaths[PathNum]; } } } } } Paths[LayerNum].Paths = new Path[DestinationCount]; Paths[LayerNum].PathCount = 0; for ( PathNum = 0; PathNum <= DestinationCount - 1; PathNum++ ) { if ( BestPaths[PathNum] != null ) { Paths[LayerNum].Paths[Paths[LayerNum].PathCount] = BestPaths[PathNum]; Paths[LayerNum].PathCount++; } } Array.Resize(ref Paths[LayerNum].Paths, Paths[LayerNum].PathCount); if ( Paths[LayerNum].PathCount == 0 ) { return null; } } while ( true ); return Paths; }