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


C# AIStates类代码示例

本文整理汇总了C#中AIStates的典型用法代码示例。如果您正苦于以下问题:C# AIStates类的具体用法?C# AIStates怎么用?C# AIStates使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AIStates类属于命名空间,在下文中一共展示了AIStates类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnGetHit

 public override AIStates OnGetHit( Mobile by, AIStates AIState, int dmg )
 {
     if ( AIState != AIStates.Attack && AIState != AIStates.Fighting )
     {
         OnBeginFight( by );
         return AIStates.BeingAttacked;
     }
     return AIState;
 }
开发者ID:karliky,项目名称:wowwow,代码行数:9,代码来源:PredatorAI.cs

示例2: TargetCoords

	/// <summary>
	/// TargetCoords is used when a ship has been hit and it will try and destroy
	/// this ship
	/// </summary>
	/// <param name="row">row generated around the hit tile</param>
	/// <param name="column">column generated around the hit tile</param>
	private void TargetCoords(ref int row, ref int column)
	{
		Location l = _Targets.Pop();

		if ((_Targets.Count == 0))
			_CurrentState = AIStates.Searching;
		row = l.Row;
		column = l.Column;
	}
开发者ID:shameera0020,项目名称:BattleShips-2.0,代码行数:15,代码来源:AIMediumPlayer.cs

示例3: ProcessShot

    /// <summary>
    /// ProcessShot will be called uppon when a ship is found.
    /// It will create a stack with targets it will try to hit. These targets
    /// will be around the tile that has been hit.
    /// </summary>
    /// <param name="row">the row it needs to process</param>
    /// <param name="col">the column it needs to process</param>
    /// <param name="result">the result og the last shot (should be hit)</param>
    protected override void ProcessShot(int row, int col, AttackResult result)
    {
        if (result.Value == ResultOfAttack.Hit) {
            _CurrentState = AIStates.Searching;

        } else if (result.Value == ResultOfAttack.ShotAlready) {
            throw new ApplicationException("Error in AI");
        }
    }
开发者ID:Nothing07,项目名称:BattleShips,代码行数:17,代码来源:AIEasyPlayer.cs

示例4: ProcessShot

 /// <summary>
 /// ProcessShot will be called uppon when a ship is found.
 /// It will create a stack with targets it will try to hit. These targets
 /// will be around the tile that has been hit.
 /// </summary>
 /// <param name="row">the row it needs to process</param>
 /// <param name="col">the column it needs to process</param>
 /// <param name="result">the result og the last shot (should be hit)</param>
 protected override void ProcessShot(int row, int col, AttackResult result)
 {
     if (result.Value == ResultOfAttack.Hit) {
         _CurrentState = AIStates.TargetingShip;
         AddTarget(row - 1, col);
         AddTarget(row, col - 1);
         AddTarget(row + 1, col);
         AddTarget(row, col + 1);
     } else if (result.Value == ResultOfAttack.ShotAlready) {
         throw new ApplicationException("Error in AI");
     }
 }
开发者ID:6942555,项目名称:battleship,代码行数:20,代码来源:AIMediumPlayer.cs

示例5: ProcessShot

 /// <summary>
 /// ProcessShot will be called uppon when a ship is found.
 /// It will create a stack with targets it will try to hit. These targets
 /// will be randomly assigned.
 /// </summary>
 /// <param name="row">the row it needs to process</param>
 /// <param name="rowOld">the row it contained before hit</param>
 /// <param name="col">the column it needs to process</param>
 /// <param name="colOld">the column it contained before hit</param>
 /// <param name="result">the result of the last shot (should be hit)</param>
 protected override void ProcessShot(int row, int col, AttackResult result)
 {
     if (result.Value == ResultOfAttack.Hit) {
         _CurrentState = AIStates.Searching;
         int rowOld = row;
         int colOld = col;
         SearchCoords(ref row, ref col);
         AddTarget(row, colOld);
         AddTarget(rowOld, col);
     } else if (result.Value == ResultOfAttack.ShotAlready) {
         throw new ApplicationException("Error in AI");
     }
 }
开发者ID:RemedialTester,项目名称:BattleShips,代码行数:23,代码来源:AIEasyPlayer.cs

示例6: OnGetHit

 public override AIStates OnGetHit( Mobile by, AIStates AIState, int dmg )
 {
     if ( AIState != AIStates.Attack && AIState != AIStates.Fighting )
     {
         OnBeginFight( by );
         if ( by == From )
             From.AttackTarget = From.LastOffender;
         else
             From.AttackTarget = by;
         return AIStates.BeingAttacked;
     }
     return AIState;
 }
开发者ID:karliky,项目名称:wowwow,代码行数:13,代码来源:DefensiveAnimalAI.cs

示例7: UpdateState

 void UpdateState()
 {
     if (health < 1) curstate = AIStates.Dead;
 }
开发者ID:SurvivalOfTheFittest,项目名称:Project-Immortui,代码行数:4,代码来源:AIScript.cs

示例8: Update

        public override void Update(GameTime gameTime)
        {
            Player player = GetNeareastPlayer();

            switch (AIState)
            {
                case AIStates.DODGE:

                    break;
                case AIStates.ATTACK:

                    break;
                case AIStates.ROAM:
                    if (!(Vector2.Distance(DestinationPos, Position) < 5))
                    {
                        var dir = DestinationPos - Position;
                        dir.Normalize();
                        Position += dir * 5f;
                    }
                    else
                    {
                        destPos = new Vector2(rand.Next(width / 2 + 5, Game1.GAME_WIDTH - width / 2),
                            rand.Next(height / 2 + 5, Game1.GAME_HEIGHT - height / 2));
                    }
                    break;
                default:
                    AIState = AIStates.DODGE;
                    break;
            }

            foreach (Player p in GameplayState.Players)
            {
                // Why would I check if my bullets hit me? Well... there's probably many
                //     resons but for now, keep it my way.
                if (p == this) continue;

                // Laser guns are an exception to bullet checks... instead, they're just a
                // giant rectangle.  The laser isn't removed if it's hitting me
                if (p.equippedWeapon.GetType() == typeof(LaserGun))
                {
                    var weapon = (LaserGun)p.equippedWeapon;
                    if (weapon.Laser.Bounds.Intersects(Bounds) && weapon.Laser.IsActive)
                        Damage(p.equippedWeapon.Damage);
                }
                else
                {
                    // Here's the bullet foreach loop, it just uses a fancy lambda expression
                    p.equippedWeapon.Bullets.ForEach((b) =>
                    {
                        // If there's no forcefield then KILL ME
                        if (!forceField)
                        {
                            if (b.Bounds.Intersects(Bounds))
                            {
                                Damage(p.equippedWeapon.Damage);
                                b.DestroyMe = true;
                            }
                        }
                        // If there is a force field then don't kill me
                        else
                        {
                            if (b.Bounds.Intersects(ForceFieldBounds))
                            {
                                b.DestroyMe = true;
                            }
                        }
                    });
                }
            }

            equippedWeapon.Update(gameTime);
        }
开发者ID:abenavente406,项目名称:Helicopter-Hysteria,代码行数:72,代码来源:ComputerPlayer.cs

示例9: Awake

    /** Initializes reference variables.
     * If you override this function you should in most cases call base.Awake () at the start of it.
      * */
    protected virtual void Awake()
    {
        seeker = GetComponent<Seeker>();

        AnimControl = GetComponent<AIStates>();

        //This is a simple optimization, cache the transform component lookup
        tr = transform;

        //Make sure we receive callbacks when paths complete
        seeker.pathCallback += OnPathComplete;

        //Cache some other components (not all are necessarily there)
        controller = GetComponent<CharacterController>();
        navController = GetComponent<NavmeshController>();
        rigid = rigidbody;
    }
开发者ID:jienoel,项目名称:MissTaraGame,代码行数:20,代码来源:AIPathCustom.cs

示例10: Start

    // Use this for initialization
    void Start()
    {
        textPanel.SetActive(false);
        updateLocation();
        if(board == null) {
            board = GameObject.Find("Board");
        }
        if(goalPoint == null) {
            // Debug.Log("goal being set");

            chooseNewGoal();
            //  Debug.Log(string.Format("the goalpoint name is {0}", goalPoint));
            findPath();
            state = AIStates.IDLE;
            // state = (AIStates)Random.Range(0, 3);
        }
        Player.turn += StateMachine;

        // this flags all the squares as hot
        foreach(GameObject square in persueRoom) {
            square.GetComponent<ClickObject>().personalSquare();
        }
    }
开发者ID:JBillingsley,项目名称:SpyParty,代码行数:24,代码来源:NPC.cs

示例11: AttemptAttack

	// Here we check to see if we can attack and what distance away we are.
	// If we are holding a throwable, the distance will be increased so that
	// we can throw it at a further range.
	void AttemptAttack(float distFromTarget)
	{
		if(targetCharStatus == null || (detectionRadius.inCloseRangeChar.Count == 0
		   && anim.GetInteger("HoldStage") != 1)) // HoldStage 1 means we are holding a throwable.
			return;
		float minDistUsing = minAttackDist;
		float maxDistUsing = maxAttackDist;
		bool holdingThrowable = false;
		if(anim.GetInteger("HoldStage") == 1)
		{
			maxDistUsing = maxAttackDist + 3;
			holdingThrowable = true;
		}

		// This part determines if we are in range to attack.
		if(distFromTarget > minDistUsing && distFromTarget < maxDistUsing)
		{
			// Face our target when within range and in idle. Otherwise just get the angle from us
			// facing our target currently.
			float angle = FaceCharacterTarget();
			// If facing our target by a good amount and making sure
			// they are vulnerable and are not guarding. If they are, they will
			// have a small chance of attacking.
			if(targetCharStatus.Vulnerable) // Make sure they are Vulnerable.
			{
				if(angle < 55
				   && (!targetCharStatus.BaseStateInfo.IsTag("Guard")
				   || (targetCharStatus.BaseStateInfo.IsTag("Guard") && Random.value > 0.95f)))
				{
					if(Random.Range(0, 100) < attackRatio)
					{
						if(!holdingThrowable)
						{
							// Attempt a grab. Grabs are done by moving slightly.
							if(canUseGrabs && _charItem.ItemHolding == null && anim.GetFloat("Move") > 0.2f && Random.value > 0.7f)
								_charAttacking.AttackSetup(3, 0); // Attempt grab.
							else
							{
								int attackUsed = 1;
								if(anim.GetFloat("Move") > 0.94f)
									attackUsed = 2; // If moving too fast, go for the slide attack.
								float vDir = 0;
								// If we are next to an itemStorer, we will use our
								// low attack and kick it.
								if(detectionRadius.NextToItemStorer && detectionRadius.inCloseRangeChar.Count == 0)
									vDir = -1;
								_charAttacking.AttackSetup(attackUsed, vDir);
							}
						}
						// If we are holding a throwable, then throw it!
						else _charItem.Throw();
					}
				}
			}
			else // They aren't vulnerable so a random chance to retreat below.
				// if they aren't simply dodging.
			{
				if(!targetCharStatus.BaseStateInfo.IsTag("Dodging"))
					if(Random.Range(0f, 20f) > 19f)
						aiState = AIStates.Retreat;
			}
		}
	}
开发者ID:MMEstrada,项目名称:GoGoGrandmas,代码行数:66,代码来源:CharacterAI.cs

示例12: Stabalize

 void Stabalize()
 {
     if (_currentAIState == AIStates.PARALYZED)
     {
         if (Time.time > stablizeTime + stablizeCooldown)
         {
             stablizeTime = Time.time;
             rb.velocity = Vector3.zero;
             rb.angularVelocity = Vector3.zero;
             _currentAIState = AIStates.DECIDING;
         }
     }
     else if (_currentPlayingState == PlayingState.STUNNED)
     {
         if (Time.time > playStablizeTime + playStablizeCooldown)
         {
             playStablizeTime = Time.time;
             rb.velocity = Vector3.zero;
             rb.angularVelocity = Vector3.zero;
             _currentPlayingState = PlayingState.SETTING_UP;
         }
     }
 }
开发者ID:xenonsin,项目名称:HackThePlanet2015,代码行数:23,代码来源:Pet.cs

示例13: ProcessHit

        /// <summary>
        /// ProcessHit gets the last hit location coordinates and will ask AddTarget to
        /// create targets around that location by calling the method four times each time with
        /// a new location around the last hit location.
        /// It will then set the state of the AI and if it's not Searching or targetingShip then
        /// start ReOrderTargets.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        private void ProcessHit(int row, int col)
        {
            _LastHit.Add(_CurrentTarget);

            //Uses _CurrentTarget as the source
            AddTarget(row - 1, col);
            AddTarget(row, col - 1);
            AddTarget(row + 1, col);
            AddTarget(row, col + 1);

            if (_CurrentState == AIStates.Searching)
            {
                _CurrentState = AIStates.TargetingShip;
            }
            else
            {
                //either targetting or hitting... both are the same here
                _CurrentState = AIStates.HittingShip;

                ReOrderTargets();
            }
        }
开发者ID:Ajtn,项目名称:Battleships-again,代码行数:31,代码来源:AIHardPlayer.cs

示例14: CheckParalyze

        void CheckParalyze()
        {
            if (rb.velocity != Vector3.zero && rb.angularVelocity != Vector3.zero)
            {
                if (_currentAIState == AIStates.PLAYING)
                    _currentPlayingState = PlayingState.STUNNED;
                else
                    _currentAIState = AIStates.PARALYZED;

            }

            //_currentAIState = AIStates.IDLING;
        }
开发者ID:xenonsin,项目名称:HackThePlanet2015,代码行数:13,代码来源:Pet.cs

示例15: Idle

        //Pet bobs around a point.
        void Idle()
        {
            switch (_currentIdleState)
            {
                case IdleState.NONE:
                    break;
                case IdleState.RECORDING_POSITON:
                    lastLocation = transform.position;
                    _currentIdleState = IdleState.DOIN_MY_THANG;
                    break;
                case IdleState.DOIN_MY_THANG:
                    transform.position = new Vector3(transform.position.x,lastLocation.y + ((float)Math.Sin(Time.time) / floatingStrength),transform.position.z);
                    idleTimeLeft -= Time.deltaTime;
                    if (idleTimeLeft < 0f)
                        _currentAIState = AIStates.DECIDING;

                    break;
            }
            //Currently Only Moves Up and Down.
        }
开发者ID:xenonsin,项目名称:HackThePlanet2015,代码行数:21,代码来源:Pet.cs


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