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


C# Person.GetComponent方法代码示例

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


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

示例1: findShortestPath

	public void findShortestPath (Person person, Grid endGrid){
		Grid startGrid = person.currentPosition;
		
		Queue fakeQueue = new Queue();
		fakeQueue.Enqueue (startGrid);
		
		for(int x = 0; x < mapWidth; ++x){
			for(int y = 0; y < mapHeight; ++y){
				Grid g = grids[x*mapHeight+y];
				g.gridState = Grid.GridState.NotProcessed;
				g.fromGrid = null;
			}
		}
		
		int totalQueueObjectNum = 0;
		startGrid.gridState = Grid.GridState.InCloseList;
		Grid queueObject = startGrid;
		totalQueueObjectNum++;
		ArrayList storeArray = new ArrayList ();
		while (queueObject != endGrid && fakeQueue.Count > 0) {
			
			queueObject = (Grid)fakeQueue.Dequeue();
			ArrayList adjacentGrids = getFourAdjacentGrid(queueObject);
			foreach (Grid adjacentPoint in adjacentGrids){
				if(!adjacentPoint) continue;
				if (adjacentPoint.gridState != Grid.GridState.InCloseList) {
					storeArray.Add( adjacentPoint);
					totalQueueObjectNum++;
					adjacentPoint.fromGrid = queueObject;
					adjacentPoint.gridState = Grid.GridState.InCloseList;
					//adjacentPoint.movementCost = queueObject.movementCost + 1;
				}
			}
			 	if (fakeQueue.Count == 0) {
					foreach(Grid g in storeArray)
						fakeQueue.Enqueue(g);
					storeArray.Clear();
			}
		}
		
		Grid fromNode = endGrid;
		Person p = person.GetComponent<Person> ();
		p.path.Clear();
		while (fromNode.fromGrid && fromNode.fromGrid != startGrid) {
			p.path.Push(fromNode);
			fromNode = fromNode.fromGrid;
		}
		p.path.Push(fromNode);

	}
开发者ID:charmjunewonder,项目名称:BVW-Round-2,代码行数:50,代码来源:MapRepresentation.cs

示例2: MoveMainCameraToView

    private IEnumerator MoveMainCameraToView(Person person)
    {
        Camera.main.transform.parent = person.head.transform;

        while (Camera.main.transform.position != person.head.transform.position)
        {
            Camera.main.transform.position = Vector3.MoveTowards(Camera.main.transform.position, person.head.transform.position, 5f * Time.deltaTime);

            Vector3 relativePos = person.head.transform.position - Camera.main.transform.position;
            Quaternion rotation = Quaternion.LookRotation(relativePos);
            Camera.main.transform.rotation = Quaternion.Lerp(Camera.main.transform.rotation, rotation, Time.deltaTime);

            yield return null;
        }

        while (Camera.main.transform.rotation != person.transform.rotation)
        {
            Camera.main.transform.rotation = Quaternion.RotateTowards(Camera.main.transform.rotation, person.transform.rotation, 50f * Time.deltaTime);

            yield return null;
        }

        person.controller.enabled = true;
        person.StopAllCoroutines();
        person.GetComponent<Rigidbody>().useGravity = true;

        StartCoroutine(RemoveUnseenPeople(person));
    }
开发者ID:JordanBird,项目名称:DD,代码行数:28,代码来源:PeopleManager.cs


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