コード例 #1
0
        public SteeringBehaviors(MovingEntity entity, MovingEntity enemy)
        {
            _entity = entity;
            rand = new Random();
            _mDWanderRadius = 2.5f;
            m_dWanderDistance = 3f;
            m_vSteeringForce = new Vector2D();
            m_dWanderJitter = 40f;

            m_dViewDistance = 40;
            m_dWeightSeparation = 5000;

            MinDetectionBoxLength = 20;
            m_dWeightObstacleAvoidance = 9000000;

            double rotation = VectorHelper.RandFloat() * (Math.PI * 2);
            m_vWanderTarget = new Vector2D(_mDWanderRadius * Math.Cos(rotation), _mDWanderRadius * Math.Sin(rotation));
            m_pTargetAgent1 = enemy;

            AStarTargets = new List<Node>();
            ExploreTargets = new Queue<Vector2D>();

            ExploreTargets.Enqueue(new Vector2D(100,100)); //Left-Top
            ExploreTargets.Enqueue(new Vector2D(100, 500)); //Left-Bottom
            ExploreTargets.Enqueue(new Vector2D(800, 500)); //Mid-Bottom
            ExploreTargets.Enqueue(new Vector2D(800, 100)); //Mid-Top
            ExploreTargets.Enqueue(new Vector2D(1500, 100)); //Right-Top
            ExploreTargets.Enqueue(new Vector2D(1500, 500)); //Right-Bottom
            ExploreTargets.Enqueue(new Vector2D(800, 450)); //Mid-Mid
            ExploreTargets.Enqueue(new Vector2D(100, 450)); // Mid-Left
            ExploreTargets.Enqueue(new Vector2D(1500, 450)); // Mid-Right
        }
コード例 #2
0
ファイル: GoToSafeHouse.cs プロジェクト: Jowindebondt/AI_GTA
        public GoToSafeHouse(MovingEntity owner)
        {
            Owner = owner;
            SubGoals = new Stack<Goal>();
            pathFinding = new PathFinding(Owner);
            flee = new Flee(Owner);

            AddSubgoal(pathFinding);
        }
コード例 #3
0
ファイル: Explore.cs プロジェクト: Jowindebondt/AI_GTA
 public Explore(MovingEntity owner)
 {
     Owner = owner;
 }
コード例 #4
0
ファイル: PathFinding.cs プロジェクト: Jowindebondt/AI_GTA
 public PathFinding(MovingEntity owner)
 {
     Owner = owner;
 }
コード例 #5
0
ファイル: AvoidEnemy.cs プロジェクト: Jowindebondt/AI_GTA
 public AvoidEnemy(MovingEntity owner)
 {
     Owner = owner;
     SubGoals = new Stack<Goal>();
 }
コード例 #6
0
ファイル: Flee.cs プロジェクト: Jowindebondt/AI_GTA
 public Flee(MovingEntity owner)
 {
     Owner = owner;
 }
コード例 #7
0
ファイル: Wander.cs プロジェクト: Jowindebondt/AI_GTA
 public Wander(MovingEntity owner)
 {
     Owner = owner;
 }
コード例 #8
0
ファイル: World.cs プロジェクト: Jowindebondt/AI_GTA
        private World()
        {
            MovingEntities = new List<MovingEntity>();
            ObstacleEntities = new List<ObstacleEntity>();
            var rand = new Random();
            _graph = new Graph();
            _drawGraph = false;

            thug = new Thug() { Pos = new Vector2D(800, 450), _sourceY = 0, Strength = 50};
            safeHouse = new Point(982, 243);

            MovingEntities.Add(thug);

            for (int i = 0; i < 1; i++)
            {
                int next = rand.Next(0, 4);

                var seek = false;
                var explore = false;
                var wander = false;
                var flee = false;
                var astar = false;

                if (next == 1)
                    seek = true;
                else if (next == 2)
                    explore = true;
                else if (next == 3)
                    astar = true;
                else
                {
                    wander = true;
                    flee = true;
                }

                int citizenNr = rand.Next(1, 7);

                //---Random---//
                //var citizen = new Citizen { Pos = new Vector2D(rand.Next(100, 1500), rand.Next(100, 700)), _sourceY = citizenNr * 16, enemy = thug, Flee = flee, Wander = wander, Seek = seek, Explore = explore, AStar = astar, SafeHouse  = safeHouse, Strength = rand.Next(0,300) };

                //---Seek---//
                //var citizen = new Citizen { Pos = new Vector2D(rand.Next(100, 1500), rand.Next(100, 700)), _sourceY = citizenNr * 16, enemy = thug, Flee = false, Wander = false, Seek = true, Explore = false, AStar = false, SafeHouse  = safeHouse, Strength = rand.Next(0,300) };

                //---Flee & Wander---//
                //var citizen = new Citizen { Pos = new Vector2D(rand.Next(100, 1500), rand.Next(100, 700)), _sourceY = citizenNr * 16, enemy = thug, Flee = true, Wander = true, Seek = false, Explore = false, AStar = false, SafeHouse  = safeHouse, Strength = rand.Next(0,300) };

                //---Explore---//
                //var citizen = new Citizen { Pos = new Vector2D(rand.Next(100, 1500), rand.Next(100, 700)), _sourceY = citizenNr * 16, enemy = thug, Flee = false, Wander = false, Seek = false, Explore = true, AStar = false, SafeHouse  = safeHouse, Strength = rand.Next(0,300) };

                //---A*---//
                //var citizen = new Citizen { Pos = new Vector2D(rand.Next(100, 1500), rand.Next(100, 700)), _sourceY = citizenNr * 16, enemy = thug, Flee = false, Wander = false, Seek = false, Explore = false, AStar = true, SafeHouse  = safeHouse, Strength = rand.Next(0,300) };

                //---GDB---//
                var citizen = new Citizen { Pos = new Vector2D(rand.Next(100, 1500), rand.Next(100, 700)), _sourceY = citizenNr * 16, enemy = thug, Flee = false, Wander = false, Seek = false, Explore = false, AStar = false, SafeHouse  = safeHouse, Strength = rand.Next(0,300)};
                MovingEntities.Add(citizen);
            }

            for (int x = 0; x < 25; x++)
            {
                for (int y = 0; y < 14; y++)
                {
                    if (y == 0 || y == 13)
                    {
                        ObstacleEntities.Add(new Building { Pos = new Vector2D(x * 64, y * 64) });
                    }
                    else if(x == 0 || x == 24)
                    {
                        ObstacleEntities.Add(new Building { Pos = new Vector2D(x * 64, y * 64) });
                    }
                    else if ((y == 2 || y == 5 || y == 8 || y == 11) && (x == 2 || x == 6 || x == 10 || x == 14 ||x == 18 || x == 22))
                    {
                        ObstacleEntities.Add(new Building { Pos = new Vector2D(x * 64, y * 64) });
                    }
                    else
                    {
                        ObstacleEntities.Add(new Pavement { Pos = new Vector2D(x * 64, y * 64) });
                    }
                }
            }
        }
コード例 #9
0
ファイル: World.cs プロジェクト: Jowindebondt/AI_GTA
        internal void TagObstaclesWithinViewRange(MovingEntity pEntity, double radius)
        {
            //iterate through all entities checking for range
            foreach (ObstacleEntity curEntity in ObstacleEntities)
            {
                //first clear any current tag
                curEntity.IsTagged = false;

                Vector2D to = curEntity.Pos - pEntity.Pos;

                //the bounding radius of the other is taken into account by adding it
                //to the range
                double range = radius + curEntity.Bradius;

                //if entity within range, tag for further consideration. (working in
                //distance-squared space to avoid sqrts)
                if ((to.LengthSq() < range * range))
                {
                    if (pEntity.GetType() == typeof(Citizen) && (curEntity.Blocking == Blocking.All || curEntity.Blocking == Blocking.Person))
                        curEntity.IsTagged = true;
                }

            }//next entity
        }
コード例 #10
0
ファイル: Think.cs プロジェクト: Jowindebondt/AI_GTA
 public Think(MovingEntity owner)
 {
     Owner = owner;
     SubGoals = new Stack<Goal>();
     rand = new Random();
 }
コード例 #11
0
ファイル: AttackEnemy.cs プロジェクト: Jowindebondt/AI_GTA
 public AttackEnemy(MovingEntity owner)
 {
     Owner = owner;
     SubGoals = new Stack<Goal>();
     AddSubgoal(new Explore(Owner));
 }
コード例 #12
0
ファイル: Seek.cs プロジェクト: Jowindebondt/AI_GTA
 public Seek(MovingEntity owner)
 {
     Owner = owner;
 }