本文整理汇总了C#中AI类的典型用法代码示例。如果您正苦于以下问题:C# AI类的具体用法?C# AI怎么用?C# AI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AI类属于命名空间,在下文中一共展示了AI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActivatePusher
public override void ActivatePusher(AI ai, int turn)
{
if (ActiveTurns[turn])
{
Board.MoveAIOnce(ai, Direction);
}
}
示例2: Initialize
// Use this for initialization
public override void Initialize (AI parent)
{
base.Initialize(parent);
transparent = false;
ActionName = "AIMove";
started = Time.time;
}
示例3: ChangeAI
void ChangeAI()
{
AIState state = lastAI.GetNextState ();
lastAI.Finish ();
if (state == AIState.None)
{
Instantiate(Resources.Load("Prefabs/Interact"));
Destroy(gameObject);
return;
}
AI ai;
switch (state) {
case AIState.Stay:
ai = new AIStay();
break;
case AIState.Run:
ai = new AIRun();
break;
case AIState.Sit:
ai = new AISit();
break;
default:
ai = new AISit();
break;
}
ai.Start(this);
lastAI = ai;
}
示例4: Start
// Use this for initialization
void Start()
{
if(thoughtMan==null) thoughtMan = GameObject.Find("ThoughtManager").GetComponent<ThoughtManager>();
myAI = GetComponent<AI> ();
InitIdeas();
}
示例5: Start
/// <summary>
/// Reset the fade delay and grab the fader
/// </summary>
/// <param name="ai">The AI executing this action</param>
public override void Start(AI ai)
{
base.Start(ai);
fader = ai.Body.GetComponentInChildren<FadeToBlack>();
fadeDelay = 5f;
}
示例6: DoAvoidance
private void DoAvoidance(AI ai, RAINAspect aspect)
{
between = ai.Kinematic.Position - aspect.Position;
avoidVector = Vector3.Cross(Vector3.up, between);
Vector3 avoidPoint;
int direction = Random.Range(0, 100);
avoidVector.Normalize();
if(direction < 50)
avoidVector *= -1;
avoidPoint = GetPositionOnNavMesh(avoidVector, ai);
if(avoidPoint == Vector3.zero)
{
avoidVector *= -1;
avoidPoint = GetPositionOnNavMesh(avoidVector, ai);
}
if(avoidPoint == Vector3.zero)
{
Debug.Log("Avoid not possible!");
// Change destination
ai.WorkingMemory.SetItem("hasArrived", true);
return;
}
ai.Motor.MoveTo(ai.Kinematic.Position + avoidPoint);
Debug.Log (ai.Body.name + " is avoiding " + aspect.Entity.Form.name);
}
示例7: Execute
public override ActionResult Execute(AI ai)
{
//enemyObject = enemy.Evaluate(ai.DeltaTime, ai.WorkingMemory).GetValue<GameObject>();
if( ai.WorkingMemory.GetItem("Wizard").GetValue<RAIN.Entities.Aspects.VisualAspect>() == null )
{
enemyObject = null;
ai.WorkingMemory.SetItem("ShouldAttack", false );
return ActionResult.SUCCESS;
}
else
enemyObject = ai.WorkingMemory.GetItem("Wizard").GetValue<RAIN.Entities.Aspects.VisualAspect>().Entity.Form;
if( enemyObject != null )
{
//if( enemyObject.GetPhotonView().isMine )
{
if ((int)enemyObject.GetPhotonView().owner.customProperties["Health"] <= 0 )
{
ai.WorkingMemory.SetItem("ShouldAttack", false );
}
else
{
ai.WorkingMemory.SetItem("ShouldAttack", true );
}
}
}
return ActionResult.SUCCESS;
}
示例8: Register
public void Register(AI.AI ai)
{
if (!_AIs.ContainsKey(ai.ID))
{
_AIs.Add(ai.ID, ai);
}
}
示例9: DoAvoidance
private void DoAvoidance(AI ai, RAINAspect aspect)
{
between = ai.Kinematic.Position - aspect.Position;
avoidVector = Vector3.Cross(Vector3.up, between);
int direction = Random.Range(0, 100);
avoidVector.Normalize();
if (direction < 50)
avoidVector *= -1;
if (!CheckPositionOnNavMesh(avoidVector, ai))
avoidVector *= -1;
if (!CheckPositionOnNavMesh(avoidVector, ai))
{
//Debug.Log("Avoid not possible!");
return;
}
Vector3 destination = ai.Kinematic.Position + avoidVector;
//ai.Motor.MoveTo(destination);
//ai.Kinematic.Position += avoidVector;
ai.Kinematic.Position = Vector3.Lerp(ai.Kinematic.Position, destination, 0.3f);
ai.Motor.FaceAt(avoidVector);
}
示例10: Execute
public override ActionResult Execute(AI ai)
{
Debug.Log ("execute");
// Dialoguer.
//return ActionResult.SUCCESS;
return ActionResult.FAILURE;
}
示例11: Stop
/// <summary>
/// Release the cover point on Stop
/// </summary>
/// <param name="ai">The AI executing the action</param>
public override void Stop(AI ai)
{
//Vacate will release the cover point
Vacate(ai);
base.Stop(ai);
}
示例12: Execute
/// <summary>
/// Executing this action just checks to make sure we have a valid cover point that we still own.
/// </summary>
/// <param name="ai">The AI executing the action</param>
/// <returns>FAILURE if we don't have a valid cover point. Otherwise this action will continue to
/// return RUNNING. This means you should use it in a Parallel only.</returns>
public override ActionResult Execute(AI ai)
{
if ((_currentCoverPoint == null) || (_currentCoverPoint.Occupant != ai.Body))
return ActionResult.FAILURE;
return ActionResult.RUNNING;
}
示例13: Execute
public override ActionResult Execute(AI ai)
{
Vector3 loc = Vector3.zero;//Default
//Create a navigation graph collection
List<RAINNavigationGraph> found = new List<RAINNavigationGraph>();
//Create a vector location based on our AI current location
//plus random range values for x and z coordinates
do
{
loc = new Vector3(ai.Kinematic.Position.x + Random.Range(-8f, 8f),
ai.Kinematic.Position.y,
ai.Kinematic.Position.z + Random.Range(-8f, 8f));
//We will create navigation points using the above calculated value, the AI current positon and ensure it is within the bounds of our navigation graph
found = NavigationManager.instance.GraphsForPoints(ai.Kinematic.Position, loc, ai.Motor.StepUpHeight, NavigationManager.GraphType.Navmesh, ((BasicNavigator)ai.Navigator).GraphTags);
} while ((Vector3.Distance(ai.Kinematic.Position, loc) < 2f) || (found.Count == 0)); //We want to be sure the location found is far enough away from each one we move to so we don't pick anything to close or the same one
//We will define a runtime variable in the AIRigs Memory element panel. You can select this in your inspector to see the output at runtime.
ai.WorkingMemory.SetItem<Vector3>("varMoveTo", loc);
if(_startTime > 500f)
{
ai.WorkingMemory.SetItem("isSearching", false);
_startTime = 0;
}
return ActionResult.SUCCESS;
}
示例14: Execute
/// <summary>
/// When executing, this action checks to see if the AI "enemy" variable has a value. If so,
/// and if the enemy has an aimpoint aspect, that is used as the aim target. If the aimpoint doesn't
/// exist, then the enemy is used directly. If neither exists, firing still occurs but aiming does not.
/// </summary>
/// <param name="ai">The AI executing the action</param>
/// <returns>FAILURE if the AimAndFireElement is missing, SUCCESS otherwise</returns>
public override ActionResult Execute(AI ai)
{
if (_aimAndFire == null)
return ActionResult.FAILURE;
//Use the AI enemy variable as the aim target
GameObject tAimObject = ai.WorkingMemory.GetItem<GameObject>("enemy");
//If the target exists, set the aim target
if (tAimObject != null)
{
RAINAspect tAimPoint = null;
//Look for an aimpoint aspect and use that if possible
EntityRig tEntity = tAimObject.GetComponentInChildren<EntityRig>();
if (tEntity != null)
tAimPoint = tEntity.Entity.GetAspect("aimpoint");
//Otherwise just use the enemy object plus a default height
if (tAimPoint == null)
_aimAndFire.SetAimTarget(tAimObject.transform.position + new Vector3(0, 1.5f, 0));
else
_aimAndFire.SetAimTarget(tAimPoint.Position);
}
//Fire away
_aimAndFire.FireWeapon();
return ActionResult.SUCCESS;
}
示例15: Execute
public override ActionResult Execute(AI ai)
{
if (_children.Count == 0)
{
return ActionResult.FAILURE;
}
int successes = 0;
for (int i = 0; i < _children.Count; i++)
{
var result = _children[i].Run(ai);
if (result == ActionResult.SUCCESS)
{
_children[i].Reset();
successes++;
}
else if (result == ActionResult.FAILURE)
{
return ActionResult.FAILURE;
}
}
if (ai.Body.transform.position == ai.Motor.MoveTarget.Position && successes == _children.Count)
{
return ActionResult.SUCCESS;
}
return ActionResult.RUNNING;
}