本文整理匯總了C#中AI.getClosestWP方法的典型用法代碼示例。如果您正苦於以下問題:C# AI.getClosestWP方法的具體用法?C# AI.getClosestWP怎麽用?C# AI.getClosestWP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AI
的用法示例。
在下文中一共展示了AI.getClosestWP方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Update
// Update is called once per frame
void Update()
{
switch(currentState)
{
case(STATE.CREATE_AI):
if(objaRooms.Count!=0)
{
enemyAI = new AI(objaRooms);
enemyAI.speed = _speed;
_enemyLoc = enemyAI.getClosestWP(this.gameObject);
_playerLoc = enemyAI.getClosestWP(_player);
enemyAI.graph.AStar(_enemyLoc,_playerLoc);
currentState = STATE.FALLING;
timeSpawned = Time.timeSinceLevelLoad;
}
break;
case(STATE.FALLING):
if(Time.timeSinceLevelLoad>(timeSpawned+timeFallingDelay))
{
currentState = STATE.PURSUING;
audio.Play();
}
break;
case(STATE.PURSUING):
direction = _player.transform.position - this.transform.position;
if (Physics.Raycast(this.transform.position, direction,out hit))
{
if (hit.transform == _player.transform)
{
this.rigidbody.AddForce(direction.x*_speed,0,direction.z*_speed);
if (this.rigidbody.velocity.magnitude > _speed)
this.rigidbody.velocity = this.rigidbody.velocity.normalized * _speed;
}
else
enemyAI.moveAI(this.gameObject);
}
break;
case(STATE.PAUSED):
break;
}
}