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