summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs
diff options
context:
space:
mode:
authordereelatwit <54997325+dereelatwit@users.noreply.github.com>2023-08-08 15:30:55 -0400
committerdereelatwit <54997325+dereelatwit@users.noreply.github.com>2023-08-08 15:30:55 -0400
commitaec4fc6d37f7e790c1deef38270caf9d71c236f4 (patch)
treeefa04460c21af951847373c8c004f40ec7680efe /Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs
parent3ac2b11494bd372d77465c97dc925ab28d87d8dc (diff)
UI components completed
added button functionality and mesh grid to scene
Diffstat (limited to 'Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs')
-rw-r--r--Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs101
1 files changed, 101 insertions, 0 deletions
diff --git a/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs b/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs
new file mode 100644
index 0000000..95e936f
--- /dev/null
+++ b/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs
@@ -0,0 +1,101 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class nMain : MonoBehaviour
+{
+
+ [SerializeField] private CellMesh cellMesh;
+
+ public LogicGrid world;
+ char placementMode;
+ int placementValue;
+
+
+ // Start is called before the first frame update
+ void Start()
+ {
+ // Create world
+ world = new LogicGrid(32, 16, 5f, new Vector3(-76, -34));
+
+ // Set default placement to Obstacle
+ placementValue = 1;
+ placementMode = 'o';
+
+ cellMesh.SetGrid(world);
+
+ Debug.Log("Loaded. Placing Mode: Obstacle");
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+ // Change Placement Modes:
+
+ // Place Obstacle in grid
+ if (Input.GetKeyDown("o"))
+ {
+ Debug.Log("Placing Mode: Obstacle");
+ placementMode = 'o';
+ placementValue = 1;
+ }
+ // Place Sample in cell
+ if(Input.GetKeyDown("s"))
+ {
+ Debug.Log("Placing Mode: Sample");
+ placementMode = 's';
+ placementValue = 2;
+ }
+ // Place agent in cell
+ if (Input.GetKeyDown("a"))
+ {
+ Debug.Log("Placing Mode: Agent");
+ placementMode = 'a';
+ placementValue = 3;
+ }
+ // Reset Canvas
+ if (Input.GetKeyDown("r"))
+ {
+
+ }
+
+
+ // Update Cell:
+ // Change cell to obstacle
+ if (Input.GetMouseButton(0))
+ {
+ world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), placementValue);
+ }
+ // Clear cell
+ if (Input.GetMouseButton(1))
+ {
+ world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), 0);
+ }
+
+ // Make functionality for when "start" button is pressed.
+ // should call some sort of function that will take in the world
+ // and perform the selected algorithm
+
+ }
+
+
+ public void SetModeObstacle()
+ {
+ placementValue = 1;
+ }
+ public void SetModeSample()
+ {
+ placementValue = 2;
+ }
+
+ public void SetModeAgent()
+ {
+ placementValue = 3;
+ }
+ public void ResetGrid()
+ {
+ world.reset();
+ }
+
+}