本文整理汇总了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);
}
示例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));
}