imported and translated java code

starting to implement algorithms
This commit is contained in:
Simon O'Shea
2023-08-08 15:27:37 -04:00
parent f825ec9c27
commit 3ac2b11494
4 changed files with 257 additions and 180 deletions
+19 -9
View File
@@ -16,7 +16,12 @@ public class Main : MonoBehaviour
void Start()
{
// Create world
world = new LogicGrid(100, 100, 5f, new Vector3(-110, -110));
int width = 100;
int height = 100;
float cellSize = 5f;
Vector3 origin = new Vector3(-110, -110);
world = new LogicGrid(width, height, cellSize, origin);
// Set default placement to Obstacle
placementValue = 1;
@@ -28,11 +33,16 @@ public class Main : MonoBehaviour
}
// Update is called once per frame
public void StartAStar()
{
AStar astar = new AStar(world, 0);
}
// Update contains keyboard shortcut options
void Update()
{
// Change Placement Modes:
// Change Placement Mode Keyboard Shortcuts:
////////////////////////////////
// Place Obstacle in grid
if (Input.GetKeyDown("o"))
{
@@ -59,15 +69,16 @@ public class Main : MonoBehaviour
{
ResetGrid();
}
//////////////////////////
// Update Cell:
// Change cell to obstacle
// Place value in cell based on selected placementValue with left click
if (Input.GetMouseButton(0))
{
world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), placementValue);
}
// Clear cell
// Clear cell with right click
if (Input.GetMouseButton(1))
{
world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), 0);
@@ -79,7 +90,6 @@ public class Main : MonoBehaviour
}
public void SetModeObstacle()
{
placementValue = 1;
@@ -96,5 +106,5 @@ public class Main : MonoBehaviour
{
world.reset();
}
}