From fe38db5f3786e1103b6da78925b2b688e4cd6065 Mon Sep 17 00:00:00 2001 From: Simon O'Shea Date: Tue, 8 Aug 2023 12:31:23 -0400 Subject: [PATCH] ready for logan? getting ready to piece UI elements together with the logic of the grid --- .../Assets/GridColorMaterials/MATERIAL.png | Bin 1706 -> 1716 bytes .../Assets/Scenes/MainScene.unity | 71 ++++++++++++++++- .../Assets/Scripts/CellMesh.cs | 74 +++++++----------- Pathfinding Visualizer/Assets/Scripts/Main.cs | 56 +++++++++---- 4 files changed, 137 insertions(+), 64 deletions(-) diff --git a/Pathfinding Visualizer/Assets/GridColorMaterials/MATERIAL.png b/Pathfinding Visualizer/Assets/GridColorMaterials/MATERIAL.png index b660f24a804d5c9279fa120c216c138d9f100914..58de9aeba67d37a7f7d99c330a0cbb3001412635 100644 GIT binary patch delta 601 zcmZ3*yMVWR5q$^MM`lNErt zj`7OmD@e%?S)kzF|!6o zM6h&*X-O$&Bu{+6eMM>BgVj6dOm{i)ct^L#2GJZ=){Do&7uGj!Yuc)y(WS60O8eG| zImK}bj%Rc>e}0=^-gY#Em6!i(x(8(k8a z^Y8!L)l*;a@4PCl6!1CacE0R`+fDC%Z~wE|^7g&*2fIVA+osI7ZfGpOXzm?VAV2Hc z!#A6j94&uP!yF~gb2X%1b^Q+Yi4E6LQu5%< jJF@p5ym987{~(9qhB3PuGjGUzph5;uS3j3^P6wLQT6v^e@6Yu3P4=P zcxCb~CRtw3+{E+(#qImazC>soV}lUDV&|nlE>0iS9xdhT^9NJ{oYQ2BFF8s7JgywmXeZES><_{ zYsoaWr8+CvOiyH8oNmulZ*wo$DXKYap+eTn>jCwSYaNRPL|g^dnu>3ovgh3C106Qg zi_br=dvDubeV#R2WpT<^HvN=hR$Y-VyPqxQ*845Y_h!rEqe8(YrD`^U3)k(vpJe!W z>+v$sv zO}3J|s||I(>E1lD_N2-l8Ru*ft91)9H{RMjzqaq4!X~x&QcmmL7xbUc^^W&gnttPC z-E4nJ2$cY_aS7wSH2DgksHmrlV+hC0(); - Material m_material; - if (myRenderer != null) - { - m_material = myRenderer.material; - - if(gridValue == -1) - { - m_material.color = Color.black; - } - if (gridValue == 0) - { - m_material.color = Color.white; - } - if (gridValue == 1) - { - m_material.color = Color.green; - } - if (gridValue == 2) - { - m_material.color = Color.cyan; - }*//* - } -*/ private void Update() { -/* if(Input.GetKeyDown("1")) - { - Debug.Log("1"); - m_Material.color = Color.white; - //m_Material.SetColor("_Color", Color.white); - } - if (Input.GetKeyDown("2")) - { - Debug.Log("2"); - m_Material.color = Color.black; - //m_Material.SetColor("_Color", Color.white); - } - - if (Input.GetKeyDown("3")) - { - Debug.Log("3"); - m_Material.color = Color.green; - //m_Material.SetColor("_Color", Color.white); - }*/ } } diff --git a/Pathfinding Visualizer/Assets/Scripts/Main.cs b/Pathfinding Visualizer/Assets/Scripts/Main.cs index cdc64db..fcac001 100644 --- a/Pathfinding Visualizer/Assets/Scripts/Main.cs +++ b/Pathfinding Visualizer/Assets/Scripts/Main.cs @@ -16,10 +16,10 @@ public class Main : MonoBehaviour void Start() { // Create world - world = new LogicGrid(5, 5, 10f, new Vector3(0, 0)); + world = new LogicGrid(100, 100, 5f, new Vector3(-110, -110)); // Set default placement to Obstacle - placementValue = -1; + placementValue = 1; placementMode = 'o'; cellMesh.SetGrid(world); @@ -32,38 +32,43 @@ public class Main : MonoBehaviour void Update() { // Change Placement Modes: - // Place Agent in grid - // TODO change modes via UI button - if(Input.GetKeyDown("a")) + + // Place Obstacle in grid + if (Input.GetKeyDown("o")) { - Debug.Log("Placing Mode: Agent"); - placementMode = 'a'; - placementValue = 3; + Debug.Log("Placing Mode: Obstacle"); + placementMode = 'o'; + placementValue = 1; } - // Place Sample in grid + // Place Sample in cell if(Input.GetKeyDown("s")) { Debug.Log("Placing Mode: Sample"); placementMode = 's'; placementValue = 2; } - // Place Obstacle in grid - if(Input.GetKeyDown("o")) + // Place agent in cell + if (Input.GetKeyDown("a")) { - Debug.Log("Placing Mode: Obstacle"); - placementMode = 'o'; - placementValue = 1; + Debug.Log("Placing Mode: Agent"); + placementMode = 'a'; + placementValue = 3; + } + // Reset Canvas + if (Input.GetKeyDown("r")) + { + } - + // Update Cell: // Change cell to obstacle - if (Input.GetMouseButtonDown(0)) + if (Input.GetMouseButton(0)) { world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), placementValue); } // Clear cell - if (Input.GetMouseButtonDown(1)) + if (Input.GetMouseButton(1)) { world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), 0); } @@ -73,4 +78,21 @@ public class Main : MonoBehaviour // and perform the selected algorithm } + + + public void SetModeObstacle() + { + placementValue = 1; + } + public void SetModeSample() + { + placementValue = 2; + } + + public void SetModeAgent() + { + placementValue = 3; + } + + }