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


C# AI类代码示例

本文整理汇总了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);
     }
 }
开发者ID:mvdlaar,项目名称:AIRally,代码行数:7,代码来源:Pusher.cs

示例2: Initialize

	// Use this for initialization
	public override void Initialize (AI parent)
	{
		base.Initialize(parent);
		transparent = false;
		ActionName = "AIMove";
		started = Time.time;
	}
开发者ID:Blurift,项目名称:Instincts,代码行数:8,代码来源:AIMove.cs

示例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;
    }
开发者ID:nanalucky,项目名称:Pet,代码行数:31,代码来源:EnterInteract.cs

示例4: Start

    // Use this for initialization
    void Start()
    {
        if(thoughtMan==null) thoughtMan = GameObject.Find("ThoughtManager").GetComponent<ThoughtManager>();
        myAI = GetComponent<AI> ();

        InitIdeas();
    }
开发者ID:Kritz7,项目名称:Voices,代码行数:8,代码来源:Thoughts.cs

示例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;
    }
开发者ID:Eynaliyev,项目名称:KNOCKOUT,代码行数:11,代码来源:FadeAndRestart.cs

示例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);
    }
开发者ID:Nolnocn,项目名称:Siege,代码行数:35,代码来源:AvoidOthers.cs

示例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;
    }
开发者ID:jonmann20,项目名称:WizardSurvival,代码行数:29,代码来源:AICheckPlayerHealth.cs

示例8: Register

 public void Register(AI.AI ai)
 {
     if (!_AIs.ContainsKey(ai.ID))
     {
         _AIs.Add(ai.ID, ai);
     }
 }
开发者ID:quziqin,项目名称:NervDog2DGameEngine,代码行数:7,代码来源:AIManager.cs

示例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);
    }
开发者ID:MarcusAromatorio,项目名称:AIGroupProject,代码行数:27,代码来源:AvoidCollision.cs

示例10: Execute

 public override ActionResult Execute(AI ai)
 {
     Debug.Log ("execute");
     //	Dialoguer.
     //return ActionResult.SUCCESS;
     return ActionResult.FAILURE;
 }
开发者ID:robertnorenberg,项目名称:Hackaton,代码行数:7,代码来源:StartDialog.cs

示例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);
    }
开发者ID:Eynaliyev,项目名称:KNOCKOUT,代码行数:11,代码来源:FindCoverPoint.cs

示例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;
    }
开发者ID:Eynaliyev,项目名称:KNOCKOUT,代码行数:13,代码来源:FindCoverPoint.cs

示例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;
    }
开发者ID:ludo6577,项目名称:Unity,代码行数:30,代码来源:WayPathLocation.cs

示例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;
    }
开发者ID:Eynaliyev,项目名称:KNOCKOUT,代码行数:37,代码来源:FireWeapon.cs

示例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;
    }
开发者ID:envy3d,项目名称:GGJ2016,代码行数:29,代码来源:ContinueToTarget.cs


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