當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。