当前位置: 首页>>代码示例>>C#>>正文


C# Path.GetType方法代码示例

本文整理汇总了C#中Path.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Path.GetType方法的具体用法?C# Path.GetType怎么用?C# Path.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


在下文中一共展示了Path.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SavePath

 public static void SavePath(Path path)
 {
     XmlSerializer x = new XmlSerializer(path.GetType());
     StreamWriter file = new StreamWriter(@"../../path.xml");
     x.Serialize(file, path);
     file.Close();
 }
开发者ID:damy90,项目名称:Telerik-all,代码行数:7,代码来源:PathStorage.cs

示例2: ReadPath

    public static Path ReadPath()
    {
        var path = new Path();

        XmlSerializer x = new XmlSerializer(path.GetType());
        StreamReader file = new StreamReader(@"../../path.xml");
        path = (Path)x.Deserialize(file);
        file.Close();

        return path;
    }
开发者ID:damy90,项目名称:Telerik-all,代码行数:11,代码来源:PathStorage.cs

示例3: StartPath

	/** Call this function to start calculating a path.
	 * \param p			The path to start calculating
	 * \param callback	The function to call when the path has been calculated
	 * \param graphMask	Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask. \astarproParam
	 * 
	 * \a callback will be called when the path has completed.
	 * \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed) */
	public Path StartPath (Path p, OnPathDelegate callback = null, int graphMask = -1) {
		p.enabledTags = traversableTags.tagsChange;
		p.tagPenalties = tagPenalties;
		
#if !AstarFree && FALSE
		//In case a multi target path has been specified, call special logic
		if (p.GetType () == typeof (MultiTargetPath)) {
			return StartMultiTargetPath (p as MultiTargetPath,callback);
		}
#endif
		//Cancel a previously requested path is it has not been processed yet and also make sure that it has not been recycled and used somewhere else
		if (path != null && path.GetState() <= PathState.Processing && lastPathID == path.pathID) {
			path.Error();
			path.LogError ("Canceled path because a new one was requested.\n"+
				"This happens when a new path is requested from the seeker when one was already being calculated.\n" +
				"For example if a unit got a new order, you might request a new path directly instead of waiting for the now" +
				" invalid path to be calculated. Which is probably what you want.\n" +
				"If you are getting this a lot, you might want to consider how you are scheduling path requests.");
			//No callback should be sent for the canceled path
		}
		
		path = p;
		path.callback += onPathDelegate;
		path.nnConstraint.graphMask = graphMask;
		
		tmpPathCallback = callback;
		
		//Set the Get Nearest Node hints if they have not already been set
		/*if (path.startHint == null)
			path.startHint = startHint;
			
		if (path.endHint == null) 
			path.endHint = endHint;
		*/
		
		//Save the path id so we can make sure that if we cancel a path (see above) it should not have been recycled yet.
		lastPathID = path.pathID;
		
		//Delay the path call by one frame if it was sent the same frame as the previous call
		/*if (lastPathCall == Time.frameCount) {
			StartCoroutine (DelayPathStart (path));
			return path;
		}*/
		
		//lastPathCall = Time.frameCount;
		
		//Pre process the path
		RunModifiers (ModifierPass.PreProcess, path);
		
		//Send the request to the pathfinder
		AstarPath.StartPath (path);
		
		return path;
	}
开发者ID:Gapti,项目名称:ClashOfClanRIP,代码行数:61,代码来源:Seeker.cs

示例4: StartPath

    /** Call this function to start calculating a path.
     * \param p			The path to start calculating
     * \param callback	The function to call when the path has been calculated
     * \param graphMask	Mask used to specify which graphs should be searched for close nodes. See Pathfinding.NNConstraint.graphMask. \astarproParam
     *
     * \a callback will be called when the path has completed.
     * \a Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed) */
    public Path StartPath(Path p, OnPathDelegate callback = null, int graphMask = -1)
    {
        p.enabledTags = traversableTags.tagsChange;
        p.tagPenalties = tagPenalties;

        //In case a multi target path has been specified, call special logic
        if (p.GetType () == typeof (MultiTargetPath)) {
            return StartMultiTargetPath (p as MultiTargetPath,callback);
        }
        //Cancel a previously requested path is it has not been processed yet and also make sure that it has not been recycled and used somewhere else
        if (path != null && path.GetState() <= PathState.Processing && lastPathID == path.pathID) {
            path.LogError ("Canceled path because a new one was requested\nGameObject: "+gameObject.name);
            //No callback should be sent for the canceled path
        }

        path = p;
        path.callback += onPathDelegate;
        path.nnConstraint.graphMask = graphMask;

        tmpPathCallback = callback;

        //Set the Get Nearest Node hints if they have not already been set
        /*if (path.startHint == null)
            path.startHint = startHint;

        if (path.endHint == null)
            path.endHint = endHint;
        */

        //Save the path id so we can make sure that if we cancel a path (see above) it should not have been recycled yet.
        lastPathID = path.pathID;

        //Delay the path call by one frame if it was sent the same frame as the previous call
        /*if (lastPathCall == Time.frameCount) {
            StartCoroutine (DelayPathStart (path));
            return path;
        }*/

        //lastPathCall = Time.frameCount;

        //Pre process the path
        RunModifiers (ModifierPass.PreProcess, path);

        //Send the request to the pathfinder
        AstarPath.StartPath (path);

        return path;
    }
开发者ID:klobodnf,项目名称:st1,代码行数:55,代码来源:Seeker.cs

示例5: onCompleteFunction

    public void onCompleteFunction(Path p)
    {
        //Debug.Log ("We have done the path... " + p.error + " " + p.errorLog);

        //check if it is jumping

        if (p.GetType() == typeof(MultiTargetPath))
        {
            MultiTargetPath mp = p as MultiTargetPath;
            if (!mp.error)
            {
                //Debug.Log("mp.foundEnd:" + mp.foundEnd);
                //Debug.Log("mp.errorLog:" + mp.errorLog);
                //Debug.Log("mp.endPoint:" + mp.endPoint);
                //Debug.Log("mp.endHint:" + mp.endHint);
                //string multipathPointString = "";
                networkView.RPC("ResetDrawMultiPath", RPCMode.All);
                for (int j = 0; j < mp.vectorPaths.Length; j++)
                {
                    if (mp.vectorPaths[j] == null)
                        continue;

                    //for (int i = 1; i < mp.vectorPath.Length; i++)
                    //{
                    //    Vector3 pre = mp.vectorPath[i - 1];
                    //    Vector3 cur = mp.vectorPath[i];
                    //    if (Mathf.Abs(pre.y - cur.y) > 1 || Mathf.Abs(pre.x - cur.x) > 1 || Mathf.Abs(pre.z - cur.z) > 1)
                    //    {
                    //        //Debug.Log("break because unwalkable");
                    //        server.multiPathPoint.RemoveAt(server.multiPathPoint.Count - 1);
                    //        return;
                    //    }
                    //}

                    string pathPointString = "";
                    List<Vector3> vpath = mp.vectorPaths[j];
                    for (int i = 0; i < vpath.Count; i++)
                    {
                        if (pathPointString == "")
                            pathPointString += vpath[i].x + "," + vpath[i].y + "," + vpath[i].z;
                        else
                            pathPointString += ";" + vpath[i].x + "," + vpath[i].y + "," + vpath[i].z;
                    }
                    if (pathPointString != "")
                    {
                        if (j == 0)
                            networkView.RPC("AddDrawMultiPath", RPCMode.All, pathPointString);
                        else
                            networkView.RPC("AddDrawMultiPath", RPCMode.All, "|" + pathPointString);
                    }
                }
                networkView.RPC("DrawMultiPath", RPCMode.All);
            }
            else
            {
                Debug.Log("Delete Node");
                server.multiPathPoint.RemoveAt(server.multiPathPoint.Count - 1);
            }
        }
        else
        {
            if (!p.error)
            {
                path = p;
                //for (int i = 1; i < path.vectorPath.Length; i++)
                //{
                //    Vector3 pre = path.vectorPath[i - 1];
                //    Vector3 cur = path.vectorPath[i];
                //    if (Mathf.Abs(pre.y - cur.y) > 1 || Mathf.Abs(pre.x - cur.x) > 1 || Mathf.Abs(pre.z - cur.z) > 1)
                //    {
                //        path = null;
                //        networkView.RPC("DrawPath", RPCMode.All, "");
                //        return;
                //    }
                //}

                string pathPointString = "";
                for (int i = 0; i < path.vectorPath.Count; i++)
                {
                    if (pathPointString == "")
                        pathPointString += path.vectorPath[i].x + "," + path.vectorPath[i].y + "," + path.vectorPath[i].z;
                    else
                        pathPointString += ";" + path.vectorPath[i].x + "," + path.vectorPath[i].y + "," + path.vectorPath[i].z;
                }
                networkView.RPC("DrawPath", RPCMode.All, pathPointString);
            }
            else
            {
                //path finding is failed. Removing the last ending point
                //this will prevent continuously showing error message
                server.endPathLocation = Vector3.zero;
            }
        }
    }
开发者ID:sonygod,项目名称:ESPUnity,代码行数:94,代码来源:CustomSeeker.cs

示例6: OnPathComplete

 public void OnPathComplete(Path p)
 {
     if (this.lastRender == null)
     {
         return;
     }
     if (p.error)
     {
         this.ClearPrevious();
         return;
     }
     if (p.GetType() == typeof(MultiTargetPath))
     {
         List<GameObject> list = new List<GameObject>(this.lastRender);
         this.lastRender.Clear();
         MultiTargetPath multiTargetPath = p as MultiTargetPath;
         for (int i = 0; i < multiTargetPath.vectorPaths.Length; i++)
         {
             if (multiTargetPath.vectorPaths[i] != null)
             {
                 List<Vector3> list2 = multiTargetPath.vectorPaths[i];
                 GameObject gameObject;
                 if (list.Count > i && list[i].GetComponent<LineRenderer>() != null)
                 {
                     gameObject = list[i];
                     list.RemoveAt(i);
                 }
                 else
                 {
                     gameObject = new GameObject("LineRenderer_" + i, new Type[]
                     {
                         typeof(LineRenderer)
                     });
                 }
                 LineRenderer component = gameObject.GetComponent<LineRenderer>();
                 component.sharedMaterial = this.lineMat;
                 component.SetWidth(this.lineWidth, this.lineWidth);
                 component.SetVertexCount(list2.Count);
                 for (int j = 0; j < list2.Count; j++)
                 {
                     component.SetPosition(j, list2[j] + this.pathOffset);
                 }
                 this.lastRender.Add(gameObject);
             }
         }
         for (int k = 0; k < list.Count; k++)
         {
             UnityEngine.Object.Destroy(list[k]);
         }
     }
     else if (p.GetType() == typeof(ConstantPath))
     {
         this.ClearPrevious();
         ConstantPath constantPath = p as ConstantPath;
         List<GraphNode> allNodes = constantPath.allNodes;
         Mesh mesh = new Mesh();
         List<Vector3> list3 = new List<Vector3>();
         bool flag = false;
         for (int l = allNodes.Count - 1; l >= 0; l--)
         {
             Vector3 a = (Vector3)allNodes[l].position + this.pathOffset;
             if (list3.Count == 65000 && !flag)
             {
                 UnityEngine.Debug.LogError("Too many nodes, rendering a mesh would throw 65K vertex error. Using Debug.DrawRay instead for the rest of the nodes");
                 flag = true;
             }
             if (flag)
             {
                 UnityEngine.Debug.DrawRay(a, Vector3.up, Color.blue);
             }
             else
             {
                 GridGraph gridGraph = AstarData.GetGraph(allNodes[l]) as GridGraph;
                 float d = 1f;
                 if (gridGraph != null)
                 {
                     d = gridGraph.nodeSize;
                 }
                 list3.Add(a + new Vector3(-0.5f, 0f, -0.5f) * d);
                 list3.Add(a + new Vector3(0.5f, 0f, -0.5f) * d);
                 list3.Add(a + new Vector3(-0.5f, 0f, 0.5f) * d);
                 list3.Add(a + new Vector3(0.5f, 0f, 0.5f) * d);
             }
         }
         Vector3[] array = list3.ToArray();
         int[] array2 = new int[3 * array.Length / 2];
         int m = 0;
         int num = 0;
         while (m < array.Length)
         {
             array2[num] = m;
             array2[num + 1] = m + 1;
             array2[num + 2] = m + 2;
             array2[num + 3] = m + 1;
             array2[num + 4] = m + 3;
             array2[num + 5] = m + 2;
             num += 6;
             m += 4;
         }
         Vector2[] array3 = new Vector2[array.Length];
//.........这里部分代码省略.........
开发者ID:GameDiffs,项目名称:TheForest,代码行数:101,代码来源:PathTypesDemo.cs

示例7: OnPathComplete

	/** Get the path back */
	public void OnPathComplete (Path p) {
		//System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch ();
		//watch.Start ();
		
		//To prevent it from creating new GameObjects when the application is quitting when using multithreading.
		if(lastRender == null) return;
		
		if (p.error) {
			ClearPrevious ();
			return;
		}
		
		
		if (p.GetType () == typeof (MultiTargetPath)) {
			
			List<GameObject> unused = new List<GameObject> (lastRender);
			lastRender.Clear ();
			
			MultiTargetPath mp = p as MultiTargetPath;
			
			for (int i=0;i<mp.vectorPaths.Length;i++) {
				if (mp.vectorPaths[i] == null) continue;
				
				List<Vector3> vpath = mp.vectorPaths[i];
				
				GameObject ob = null;
				if (unused.Count > i && unused[i].GetComponent<LineRenderer>() != null) {
					ob = unused[i];
					unused.RemoveAt (i);
				} else {
					ob = new GameObject ("LineRenderer_"+i,typeof(LineRenderer));
				}
				
				LineRenderer lr = ob.GetComponent<LineRenderer>();
				lr.sharedMaterial = lineMat;
				lr.SetWidth (lineWidth,lineWidth);
				
				lr.SetVertexCount (vpath.Count);
				for (int j=0;j<vpath.Count;j++) {
					lr.SetPosition (j,vpath[j] + pathOffset);
				}
				
				lastRender.Add (ob);
			}
			
			for (int i=0;i<unused.Count;i++) {
				Destroy (unused[i]);
			}
			
		} else if (p.GetType () == typeof (ConstantPath)) {
			
			ClearPrevious ();
			//The following code will build a mesh with a square for each node visited
			
			ConstantPath constPath = p as ConstantPath;
			List<GraphNode> nodes = constPath.allNodes;
			
			Mesh mesh = new Mesh ();
			
			List<Vector3> verts = new List<Vector3>();
			
			bool drawRaysInstead = false;
			
			List<Vector3> pts = Pathfinding.PathUtilities.GetPointsOnNodes (nodes, 20, 0);
			Vector3 avg = Vector3.zero;
			for (int i=0;i<pts.Count;i++) {
				Debug.DrawRay (pts[i], Vector3.up*5, Color.red, 3);
				avg += pts[i];
			}
			
			if (pts.Count > 0) avg /= pts.Count;
			
			for (int i=0;i<pts.Count;i++) {
				pts[i] -= avg;
			}
			
			Pathfinding.PathUtilities.GetPointsAroundPoint (start.position, AstarPath.active.astarData.graphs[0] as IRaycastableGraph, pts, 0, 1);
			
			for (int i=0;i<pts.Count;i++) {
				Debug.DrawRay (pts[i], Vector3.up*5, Color.blue, 3);
			}
			
			//This will loop through the nodes from furthest away to nearest, not really necessary... but why not :D
			//Note that the reverse does not, as common sense would suggest, loop through from the closest to the furthest away
			//since is might contain duplicates and only the node duplicate placed at the highest index is guarenteed to be ordered correctly.
			for (int i=nodes.Count-1;i>=0;i--) {
				
				Vector3 pos = (Vector3)nodes[i].position+pathOffset;
				if (verts.Count	== 65000 && !drawRaysInstead) {
					Debug.LogError ("Too many nodes, rendering a mesh would throw 65K vertex error. Using Debug.DrawRay instead for the rest of the nodes");
					drawRaysInstead = true;
				}
				
				if (drawRaysInstead) {
					Debug.DrawRay (pos,Vector3.up,Color.blue);
					continue;
				}
				
				//Add vertices in a square
//.........这里部分代码省略.........
开发者ID:Gapti,项目名称:ClashOfClanRIP,代码行数:101,代码来源:PathTypesDemo.cs


注:本文中的Path.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。