コード例 #1
0
        public override void Update(GameTime gt)
        {
            if (currentBehaviour == null)
            {
                if (Vector2.Distance(Position, currentTarget.Position) < closeEnough)
                {
                    currentBehaviour = new Evade(this, currentTarget);
                }
                else
                {
                    currentBehaviour = new Pursue(this, currentTarget);
                }
            }

            if (Vector2.Distance(Position, currentTarget.Position) < closeEnough)
            {
                currentBehaviour = null;
            }

            if (m_Velocity.Length() > 0)
            {
                m_Velocity.Normalize();
            }

            if (currentBehaviour != null)
            {
                m_Velocity += currentBehaviour.GetForce();
            }

            base.Update(gt);
        }
コード例 #2
0
 public ChaseHideEnemy(Texture2D a_Texture, Vector2 a_Position, MovableEntity a_Target)
     : base(a_Texture, a_Position)
 {
     m_Colour         = Color.Azure;
     currentBehaviour = null;
     currentTarget    = a_Target;
 }
コード例 #3
0
        public override void Update(GameTime gt)
        {
            if (currentTarget != null)
            {
                currentBehaviour = new Evade(this, currentTarget);
            }

            //Target is far away enough, so sit still
            if (Vector2.Distance(m_Position, currentTarget.Position) > m_FarAwayEnough)
            {
                m_Velocity = Vector2.Zero;
            }
            //otherwise move away
            else
            {
                m_Velocity += currentBehaviour.GetForce();
            }

            if (m_Velocity.Length() > 0)
            {
                m_Velocity.Normalize();
            }

            base.Update(gt);
        }
コード例 #4
0
ファイル: Chaser.cs プロジェクト: algaesia/SteeringEntities
        public override void Update(GameTime gt)
        {
            Vector2 mousePos = Vector2.Zero;

            mousePos.X = Mouse.GetState().X;
            mousePos.Y = Mouse.GetState().Y;

            currentBehaviour = new Seek(this, mousePos);

            m_Velocity += currentBehaviour.GetForce();

            base.Update(gt);
        }
コード例 #5
0
ファイル: Explorer.cs プロジェクト: algaesia/SteeringEntities
 public Explorer(Texture2D a_Texture, Vector2 a_Position)
     : base(a_Texture, a_Position)
 {
     m_Colour         = Color.Yellow;
     currentBehaviour = new Wander(this);
 }