diff --git a/Pathfinding Visualizer/Assets/Scenes/Testing.unity b/Pathfinding Visualizer/Assets/Scenes/Testing.unity index 144deae..519e1a3 100644 --- a/Pathfinding Visualizer/Assets/Scenes/Testing.unity +++ b/Pathfinding Visualizer/Assets/Scenes/Testing.unity @@ -207,7 +207,19 @@ MonoBehaviour: m_Group: {fileID: 175665621} onValueChanged: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 246942501} + m_TargetAssemblyTypeName: nMain, Assembly-CSharp + m_MethodName: AstarToggle + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 1 --- !u!1 &124050057 GameObject: @@ -314,7 +326,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2fafe2cfe61f6974895a912c3755e8f1, type: 3} m_Name: m_EditorClassIdentifier: - m_AllowSwitchOff: 1 + m_AllowSwitchOff: 0 --- !u!4 &175665622 Transform: m_ObjectHideFlags: 0 @@ -588,6 +600,84 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: cellMesh: {fileID: 885170986} + agent: {x: 0, y: 0} + obstacles: [] + samples: [] +--- !u!1 &368052877 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 368052878} + - component: {fileID: 368052880} + - component: {fileID: 368052879} + m_Layer: 5 + m_Name: Handle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &368052878 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 368052877} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2069650738} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 20, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &368052879 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 368052877} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &368052880 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 368052877} + m_CullTransparentMesh: 1 --- !u!1 &392904971 GameObject: m_ObjectHideFlags: 0 @@ -893,7 +983,19 @@ MonoBehaviour: m_Group: {fileID: 175665621} onValueChanged: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 246942501} + m_TargetAssemblyTypeName: nMain, Assembly-CSharp + m_MethodName: DFSToggle + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 0 --- !u!1 &504177782 GameObject: @@ -1508,7 +1610,19 @@ MonoBehaviour: m_Group: {fileID: 175665621} onValueChanged: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 246942501} + m_TargetAssemblyTypeName: nMain, Assembly-CSharp + m_MethodName: BFSToggle + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 0 --- !u!1 &874042116 GameObject: @@ -1778,6 +1892,18 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 246942501} + m_TargetAssemblyTypeName: nMain, Assembly-CSharp + m_MethodName: StartAlgorithm + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!114 &1119505057 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2022,6 +2148,96 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1180983250 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1180983251} + - component: {fileID: 1180983252} + m_Layer: 5 + m_Name: Speed + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1180983251 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1180983250} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1606952144} + - {fileID: 1249508208} + - {fileID: 2069650738} + m_Father: {fileID: 1968387423} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 301, y: -178} + m_SizeDelta: {x: 160, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1180983252 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1180983250} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 368052879} + m_FillRect: {fileID: 2130071965} + m_HandleRect: {fileID: 368052878} + m_Direction: 1 + m_MinValue: 0 + m_MaxValue: 5 + m_WholeNumbers: 0 + m_Value: 3 + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] --- !u!1 &1214747637 GameObject: m_ObjectHideFlags: 0 @@ -2156,6 +2372,42 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1214747637} m_CullTransparentMesh: 1 +--- !u!1 &1249508207 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1249508208} + m_Layer: 5 + m_Name: Fill Area + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1249508208 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1249508207} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2130071965} + m_Father: {fileID: 1180983251} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.25} + m_AnchorMax: {x: 1, y: 0.75} + m_AnchoredPosition: {x: 5, y: 0} + m_SizeDelta: {x: -20, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1441249333 GameObject: m_ObjectHideFlags: 0 @@ -2431,6 +2683,81 @@ MonoBehaviour: m_StringArgument: Show m_BoolArgument: 0 m_CallState: 2 +--- !u!1 &1606952143 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1606952144} + - component: {fileID: 1606952146} + - component: {fileID: 1606952145} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1606952144 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1606952143} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1180983251} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.25} + m_AnchorMax: {x: 1, y: 0.75} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1606952145 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1606952143} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1606952146 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1606952143} + m_CullTransparentMesh: 1 --- !u!1 &1968387419 GameObject: m_ObjectHideFlags: 0 @@ -2530,6 +2857,7 @@ RectTransform: - {fileID: 2091057173} - {fileID: 408861379} - {fileID: 175665622} + - {fileID: 1180983251} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -2746,6 +3074,42 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2057092154} m_CullTransparentMesh: 1 +--- !u!1 &2069650737 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2069650738} + m_Layer: 5 + m_Name: Handle Slide Area + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2069650738 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2069650737} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 368052878} + m_Father: {fileID: 1180983251} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -20, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &2091057172 GameObject: m_ObjectHideFlags: 0 @@ -3006,6 +3370,81 @@ MonoBehaviour: _compressClip: {fileID: 8300000, guid: da50785b5dbcab544815db0295e83b30, type: 3} _uncompressClip: {fileID: 8300000, guid: bd4c3c6a5e50e144d8ef38bd3e966fdb, type: 3} _source: {fileID: 2091057175} +--- !u!1 &2130071964 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2130071965} + - component: {fileID: 2130071967} + - component: {fileID: 2130071966} + m_Layer: 5 + m_Name: Fill + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2130071965 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2130071964} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1249508208} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 10, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2130071966 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2130071964} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &2130071967 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2130071964} + m_CullTransparentMesh: 1 --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs b/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs index 95e936f..cd4c5df 100644 --- a/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs +++ b/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs @@ -6,21 +6,34 @@ public class nMain : MonoBehaviour { [SerializeField] private CellMesh cellMesh; - - public LogicGrid world; - char placementMode; + + private LogicGrid world; int placementValue; + int algorithm; + bool astarSelected; + bool bfsSelected; + bool dfsSelected; + + + // Coordinates for pathfinding + public Vector2Int agent = new Vector2Int(); + public List obstacles = new List(); + public List samples = new List(); // Start is called before the first frame update void Start() { // Create world - world = new LogicGrid(32, 16, 5f, new Vector3(-76, -34)); - + int width = 32; + int height = 16; + float cellSize = 5f; + Vector3 origin = new Vector3(-77, -34); + + world = new LogicGrid(width, height, cellSize, origin); + // Set default placement to Obstacle placementValue = 1; - placementMode = 'o'; cellMesh.SetGrid(world); @@ -28,58 +41,55 @@ public class nMain : MonoBehaviour } - // Update is called once per frame + // Update contains keyboard shortcut options void Update() { - // Change Placement Modes: - + // Change Placement Mode Keyboard Shortcuts: + //////////////////////////////// // 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")) + 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")) { - + ResetGrid(); } + if (Input.GetKeyDown("g")) + { + StartAlgorithm(); + } + + ////////////////////////// // 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); } - - // 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; @@ -88,7 +98,6 @@ public class nMain : MonoBehaviour { placementValue = 2; } - public void SetModeAgent() { placementValue = 3; @@ -98,4 +107,80 @@ public class nMain : MonoBehaviour world.reset(); } + public void StartAlgorithm() + { + Vector2Int coord = new Vector2Int(); + + // Collect information about world + for (int x = 0; x < world.GetWidth(); x++) + for (int y = 0; y < world.GetHeight(); y++) + { + int index = x * world.GetHeight() + y; + int value = world.GetValue(x, y); + + Debug.Log("x: " + x + " y: " + y + " | value: " + value); + + // Add coordinate to obstacle array + if (value == 1) + { + coord.x = x; + coord.y = y; + + if (!obstacles.Contains(coord)) + obstacles.Add(coord); + } + // Add coordinate to sample array + if (value == 2) + { + coord.x = x; + coord.y = y; + + if (!samples.Contains(coord)) + samples.Add(coord); + } + // Add coordinate to obstacle array + if (value == 3) + { + agent.x = x; + agent.y = y; + } + } + + + if (true) + { + Pathfinder astar = new Pathfinder(world, agent, obstacles, samples, algorithm, 0); + astar.go(); + } + } + + + + + public void AstarToggle(bool tickOn) + { + astarSelected = tickOn; + Debug.Log(astarSelected); + algorithm = 0; + Debug.Log(algorithm); + + } + + public void DFSToggle(bool tickOn) + { + dfsSelected = tickOn; + Debug.Log(dfsSelected); + algorithm = 1; + Debug.Log(algorithm); + } + + public void BFSToggle(bool tickOn) + { + bfsSelected = tickOn; + Debug.Log(bfsSelected); + algorithm = 2; + Debug.Log(algorithm); + + } + }