Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If anyone with XNA and MonoGame experience can help me with my homework assignment, that would be helpful. It is in C# and there are

If anyone with XNA and MonoGame experience can help me with my homework assignment, that would be helpful. It is in C# and there are more files in order to understand it which Ill have link for it down below. If you understand it but its too much to do then could you help me understand it so I can finish this class.

https://drive.google.com/open?id=1_E8f7C2v9myy_EDAPn8mqqGMxsqvC8j5

Agent Alien 20

Develop the Agent class based on our Game Object using other geometry and colors. (10)

It should have an AStarSearch instance based on the maze created in section 1. A grid position with a wall (higher altitude) is an impassable node. Each agent jumps to one of the prizes and moves towards the center zone by finding the path. (10).

The Agent also inherits from the GameObject. It should have the AStartSearch and List of Vector3 for A* Search. The usage of these instance has been studied at the Lab 9. In the constructor, make the 20 x 20 nodes and specify the passable.

public class Agent : GameObject

{

public AStarSearch search;

List path;

private float speed = 5f; //moving speed

private int gridSize = 20; //grid size

private TerrainRenderer Terrain;

public Agent(TerrainRenderer terrain, ContentManager Content,

Camera camera, GraphicsDevice graphicsDevice, Light light):base()

{

Terrain = terrain;

path = null; ...

As explained, you have to pay more attention get the proper maze coordinate from the grid search space.

search = new AStarSearch(gridSize, gridSize);

float gridW = Terrain.size.X/gridSize;

float gridH = Terrain.size.Y/gridSize;

for (int i = 0; i< gridSize; i++)

for (int j = 0; j < gridSize; j++)

{

Vector3 pos = new Vector3(gridW*i+gridW/2-errain.size.X/2, ... );

if (Terrain.GetAltitude(pos) > 1.0)

search.Nodes[i, j].Passable = false;

}

3 (a) The followings are required methods in Agent class.

public override void Update()

{

if (path != null)

{

// Move to the destination along the path

if (... ) // if it reaches to a point, go to the next in path

{

if (...) // if it reached to the goal

{

path = null;

return;

}

}

}

else

{

// Search again to make a new path.

}

this.Transform.LocalPosition = new Vector3(

this.Transform.LocalPosition.X,

Terrain.GetAltitude(this.Transform.LocalPosition),

this.Transform.LocalPosition.Z) + Vector3.Up;

Transform.Update();

base.Update();

}

3 (c) The following is the template to get the maze coordinate from search grid space GetGridPosition, and to search the path randomly RandomPathFinding. Finished them in the Agent class.

private Vector3 GetGridPosition(Vector3 gridPos)

{

float gridW = Terrain.size.X/search.Cols;

float gridH = Terrain.size.Y/search.Rows;

return new Vector3(gridW*gridPos.X+gridW/2-Terrain.size.X/2, ...);

}

private void RandomPathFinding()

{

Random random = new Random();

while (!(search.Start = search.Nodes[random.Next(search.Cols),

random.Next(search.Rows)]).Passable) ;

search.End = search.Nodes[search.Cols / 2, search.Rows / 2];

search.Search();

path = new List();

AStarNode current = search.End;

var count =0;

while (current != null)

{

path.Insert(0, current.Position);

current = current.Parent;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

What stategies could primark use to recover after the pandemic?

Answered: 1 week ago

Question

=+ At what rate does capital per person grow?

Answered: 1 week ago