• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AIStates类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: StateMachine

    // States: Wander, Persue, Idle
    void StateMachine()
    {
        // Debug.Log("statemachine being called at time " + Time.time);
        //Debug.Log(string.Format("at time {0} the state is {1}", Time.time, state));
        checkRoomInvasion();
        switch(state) {
            case AIStates.WANDER:
                if(goalPoint == null) {
                    selectRandomState();
                    chooseNewGoal();
                    return;
                }
                if(currentSquare.Equals(goalPoint)) {
                    // you done!
                    // choose a new state and return
                    //     Debug.Log("we have moved into the goal square so we are calculating a new square to wander to");
                    selectRandomState();
                    chooseNewGoal();
                    cleanPathNodes();
                    findPath();
                    //      Debug.Log(goalPoint);
                    return;
                }
                // sets the current square to not holding this character anymore in anticipation for the move
                // then choose a square that advances the ai towards the target square

                currentSquare = findNextMove();
                updateLocation();
                break;
            case AIStates.PERSUE:
             //   Debug.Log("You GETTIN CHASED");
                foreach(GameObject square in persueRoom) {
                    if(squareContainsPlayer(square)) {
                        // we do a persuit
                        goalPoint = square;
                        cleanPathNodes();
                        findPath();
                        currentSquare = findNextMove();
                        updateLocation();
                        return;
                    }
                }
                selectRandomState();
                // this is not in use for now
                // selectRandomState();
                break;
            case AIStates.IDLE:
                state = AIStates.WANDER;
                goalPoint = null;
                break;
            default:
                break;
        }
    }
开发者ID:JBillingsley,项目名称:SpyParty,代码行数:55,代码来源:NPC.cs


示例17: Start

 // Use this for initialization
 void Start()
 {
     myState = AIStates.Roaming;
 }
开发者ID:shong8485,项目名称:IndieTeam2015-HeroProjectU,代码行数:5,代码来源:HeroAI.cs


示例18: OnGetHit

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


示例19: Update

    // Update is called once per frame
    void Update()
    {
        switch(currentState) {

        case AIStates.MOVING_RIGHT:
            transform.Translate(new Vector3(moveSpeed * Time.deltaTime, 0, 0), Space.World);

            if(transform.position.x - player.position.x > 5)
                currentState = AIStates.MOVING_LEFT;

            break;

        case AIStates.MOVING_LEFT:
            transform.Translate(new Vector3(-moveSpeed * Time.deltaTime, 0, 0), Space.World);

            if(transform.position.x - player.position.x < -5) {
                // Set up the swoop info
                startPosition = transform.position;
                endPosition = player.transform.position;
                swoopCenter = player.transform.position;
                swoopCenter.y = transform.position.y; // above the player at the bee's level

                startSwoop = startPosition - swoopCenter;
                endSwoop = endPosition - swoopCenter;

                currentState = AIStates.SWOOPING_DOWN;
            }

            break;

        case AIStates.SWOOPING_DOWN:
            swoopTime += Time.deltaTime;
            transform.position = Vector3.Slerp(startSwoop, endSwoop, swoopTime * 2);
            transform.position += swoopCenter;
            if(swoopTime > 0.5f) {
                swoopTime = 0.0f;

                // Calculate second half of swoop
                Vector3 temp = startPosition;
                startPosition = endPosition;
                endPosition = temp + new Vector3(10, 0, 0);

                startSwoop = startPosition - swoopCenter;
                endSwoop = endPosition - swoopCenter;

                currentState = AIStates.SWOOPING_UP;
            }

            break;

        case AIStates.SWOOPING_UP:
            swoopTime += Time.deltaTime;
            transform.position = Vector3.Slerp(startSwoop, endSwoop, swoopTime * 2);
            transform.position += swoopCenter;
            if(swoopTime > 0.5f) {
                swoopTime = 0.0f;

                currentState = AIStates.MOVING_LEFT;
            }

            break;
        default:
            break;

        }

        switch(currentHealth) {
        case 3:
            transform.Find("MeanBee").renderer.material.mainTexture = beeTextures[0];
            break;
        case 2:
            transform.Find("MeanBee").renderer.material.mainTexture = beeTextures[1];
            break;
        case 1:
            transform.Find("MeanBee").renderer.material.mainTexture = beeTextures[2];
            break;
        default:
            // Empty the bar, then destroy the Bee object
            Destroy(beeHealthBarFill);
            Destroy(gameObject);
            break;

        }
    }
开发者ID:ilcartographer,项目名称:Swarmed,代码行数:85,代码来源:BossEnemy.cs


示例20: Start

 // Use this for initialization
 void Start()
 {
     currentHealth = MAX_HEALTH;
     _pixelInset = beeHealthBarFill.pixelInset;
     currentState = AIStates.MOVING_RIGHT;
 }
开发者ID:ilcartographer,项目名称:Swarmed,代码行数:7,代码来源:BossEnemy.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AIType类代码示例发布时间:2022-05-24
下一篇:
C# AIState类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap