Beispiel #1
0
 //Methods
 public void Reset()
 {
     mOpenList   = new BinaryHeap();
     mGrid       = new BinaryGrid();
     mGeneration = 1;
     mSolution   = null;
     mGoal       = null;
 }
Beispiel #2
0
 //Methods
 public void Reset()
 {
     _movementList.Clear();
     _openList.Clear();
     _grid = new BinaryGrid <RouteNode>();
     _nodeFactory.Clear();
     _solution = null;
     _goal     = null;
 }
Beispiel #3
0
        //Constructors
        public Route()
        {
            _movementList = new MovementCostQueue();
            _openList     = new TotalCostQueue();
            _grid         = new BinaryGrid <RouteNode>();
            _nodeFactory  = new ListFactory <RouteNode>();
            _terrain      = new BinaryGrid <TerrainPoint>();

            Reset();
            _grain = 10;
        }
Beispiel #4
0
        //Loop through each rectangle and create a terrain grid
        //Make sure grid has been cleared
        private void CreateTerrain(Point startPoint, Point endPoint)
        {
            if (mContainer == null)
            {
                return;
            }

            mTerrain = new BinaryGrid();

            int terraincost = mGrain * mModifier * mTerrainCost;

            //Add all shapes if avoid is on, otherwise only the start and end
            if (Avoid)
            {
                foreach (Shape shape in mContainer.Shapes.Values)
                {
                    //Reduce the terrain rectangle if rectangle intersection
                    //and starting or ending shapes
                    if (shape == Start || shape == End)
                    {
                        Rectangle rect = GetInflatedRectangle(shape);
                        AddRectangleToTerrain(rect, terraincost);
                    }
                    else
                    {
                        Rectangle rect = GetInflatedRectangle(shape);
                        if (!rect.Contains(startPoint) && !rect.Contains(endPoint))
                        {
                            AddRectangleToTerrain(rect, terraincost);
                        }
                    }
                }
            }
            else
            {
                if (Start != null)
                {
                    AddRectangleToTerrain(GetInflatedRectangle(Start), terraincost);
                }
                if (End != null)
                {
                    AddRectangleToTerrain(GetInflatedRectangle(End), terraincost);
                }
            }
        }
Beispiel #5
0
		//Loop through each rectangle and create a terrain grid
		//Make sure grid has been cleared
		private void CreateTerrain(Point startPoint, Point endPoint)
		{
			if (mContainer == null) return;

			mTerrain = new BinaryGrid();

			int terraincost = mGrain * mModifier * mTerrainCost;

			//Add all shapes if avoid is on, otherwise only the start and end
			if (Avoid)
			{
				foreach (Shape shape in mContainer.Shapes.Values)
				{
					//Reduce the terrain rectangle if rectangle intersection 
					//and starting or ending shapes
					if (shape == Start || shape == End)
					{
						Rectangle rect = GetInflatedRectangle(shape);
						AddRectangleToTerrain(rect, terraincost);
					}
					else
					{
						Rectangle rect = GetInflatedRectangle(shape);
						if (!rect.Contains(startPoint) && !rect.Contains(endPoint)) AddRectangleToTerrain(rect, terraincost);
					}
				}
			}
			else
			{
				if (Start != null) AddRectangleToTerrain(GetInflatedRectangle(Start), terraincost);
				if (End != null) AddRectangleToTerrain(GetInflatedRectangle(End), terraincost);
			}
		}
Beispiel #6
0
		//Determines if the impassable structures must be recreated
		public void Reform()
		{
			mTerrain = null;
		}
Beispiel #7
0
		//Methods
		public void Reset()
		{
			mOpenList = new BinaryHeap();
			mGrid = new BinaryGrid();
			mGeneration = 1;
			mSolution = null;
			mGoal = null;
		}
Beispiel #8
0
 //Determines if the impassable structures must be recreated
 public void Reform()
 {
     mTerrain = null;
 }