From 3ceb5634df7c6e44fdd41b6a63654a85b8e0b587 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Mon, 13 Feb 2023 19:38:57 -0400 Subject: [PATCH] Did some work --- .idea/.idea.MAAC3601-TD-Game/.idea/.gitignore | 10 ++++++ .../.idea/encodings.xml | 4 +++ .../.idea/indexLayout.xml | 8 +++++ .idea/.idea.MAAC3601-TD-Game/.idea/vcs.xml | 6 ++++ Assets/Prefabs/Generation.prefab | 36 +++++++++++++++++++ Assets/Scenes/SampleScene.unity | 4 ++- Assets/Scripts/GenerationController.cs | 35 ++++++++++++++++-- Assets/Scripts/PathingController.cs | 31 +++++++++++++--- ProjectSettings/ShaderGraphSettings.asset | 16 +++++++++ 9 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 .idea/.idea.MAAC3601-TD-Game/.idea/.gitignore create mode 100644 .idea/.idea.MAAC3601-TD-Game/.idea/encodings.xml create mode 100644 .idea/.idea.MAAC3601-TD-Game/.idea/indexLayout.xml create mode 100644 .idea/.idea.MAAC3601-TD-Game/.idea/vcs.xml create mode 100644 ProjectSettings/ShaderGraphSettings.asset diff --git a/.idea/.idea.MAAC3601-TD-Game/.idea/.gitignore b/.idea/.idea.MAAC3601-TD-Game/.idea/.gitignore new file mode 100644 index 0000000..f9dcb57 --- /dev/null +++ b/.idea/.idea.MAAC3601-TD-Game/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +/.idea.MAAC3601-TD-Game.iml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.MAAC3601-TD-Game/.idea/encodings.xml b/.idea/.idea.MAAC3601-TD-Game/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.MAAC3601-TD-Game/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.MAAC3601-TD-Game/.idea/indexLayout.xml b/.idea/.idea.MAAC3601-TD-Game/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.MAAC3601-TD-Game/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.MAAC3601-TD-Game/.idea/vcs.xml b/.idea/.idea.MAAC3601-TD-Game/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.MAAC3601-TD-Game/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Assets/Prefabs/Generation.prefab b/Assets/Prefabs/Generation.prefab index 54ccbd8..f73dc36 100644 --- a/Assets/Prefabs/Generation.prefab +++ b/Assets/Prefabs/Generation.prefab @@ -10,6 +10,8 @@ GameObject: m_Component: - component: {fileID: 4476842061966021075} - component: {fileID: 2981135554967256007} + - component: {fileID: 1540579659150390887} + - component: {fileID: 7146678828090736945} m_Layer: 0 m_Name: Generation m_TagString: Untagged @@ -84,3 +86,37 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!114 &1540579659150390887 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1458536803320539101} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6d151e6102b72db4590ce83309573f1c, type: 3} + m_Name: + m_EditorClassIdentifier: + PathGameObject: {fileID: 0} +--- !u!50 &7146678828090736945 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1458536803320539101} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 0 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index aa0c691..8122d53 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -491,7 +491,7 @@ GameObject: - component: {fileID: 1292283378} - component: {fileID: 1292283377} m_Layer: 0 - m_Name: Pathing + m_Name: Path m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -509,6 +509,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 62f8cdc29b6f43e4998a2750b3b9a023, type: 3} m_Name: m_EditorClassIdentifier: + waypointPrefab: {fileID: 2624247600710686983, guid: fad75b8b6a5d5a6468eef0f0782ea835, type: 3} + enemyPrefab: {fileID: 1458536803320539101, guid: f1eab3cea41682c4ba2ff7c2b218fc0b, type: 3} --- !u!4 &1292283378 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/GenerationController.cs b/Assets/Scripts/GenerationController.cs index ef6e9c0..d1929aa 100644 --- a/Assets/Scripts/GenerationController.cs +++ b/Assets/Scripts/GenerationController.cs @@ -1,13 +1,24 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; -public class GenerationController : MonoBehaviour -{ +public class GenerationController : MonoBehaviour { + + public GameObject PathGameObject; + private Rigidbody2D rb; + + int pathIndex = 0; + + bool moving = false; + + private GameObject pathPointer; + // Start is called before the first frame update void Start() { - + rb = GetComponent(); + PathGameObject = GameObject.Find("Path"); } // Update is called once per frame @@ -15,4 +26,22 @@ public class GenerationController : MonoBehaviour { } + + private void FixedUpdate() { + pathPointer = PathGameObject.GetComponent().waypointList[pathIndex] as GameObject; + + if (!moving) { + Vector2 force = new Vector2(pathPointer.transform.position.x, pathPointer.transform.position.y); + rb.AddForce(force); + moving = true; + } + + } + + private void OnTriggerEnter2D(Collider2D col) { + if (col.gameObject == pathPointer) { + moving = false; + pathIndex++; + } + } } diff --git a/Assets/Scripts/PathingController.cs b/Assets/Scripts/PathingController.cs index 1746fc7..f06f649 100644 --- a/Assets/Scripts/PathingController.cs +++ b/Assets/Scripts/PathingController.cs @@ -1,15 +1,25 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; -public class PathingController : MonoBehaviour -{ - - +public class PathingController : MonoBehaviour { + + public GameObject waypointPrefab; + public ArrayList waypointList = new ArrayList(); + public GameObject enemyPrefab; + + private ArrayList enemyList = new ArrayList(); + + int counter = 0; + // Start is called before the first frame update void Start() { + waypointList.Add(Instantiate(waypointPrefab, new Vector3(0, 0, 0), Quaternion.identity)); + waypointList.Add(Instantiate(waypointPrefab, new Vector3(0, 5, 0), Quaternion.identity)); + waypointList.Add(Instantiate(waypointPrefab, new Vector3(5, 5, 0), Quaternion.identity)); } @@ -18,4 +28,17 @@ public class PathingController : MonoBehaviour { } + + private void FixedUpdate() { + if (counter == 0) { + enemyList.Add(Instantiate(enemyPrefab)); + counter++; + } + else if (counter >= 50) { + counter = 0; + } + else { + counter++; + } + } } diff --git a/ProjectSettings/ShaderGraphSettings.asset b/ProjectSettings/ShaderGraphSettings.asset new file mode 100644 index 0000000..9b28428 --- /dev/null +++ b/ProjectSettings/ShaderGraphSettings.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1 +MonoBehaviour: + m_ObjectHideFlags: 61 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3} + m_Name: + m_EditorClassIdentifier: + customInterpolatorErrorThreshold: 32 + customInterpolatorWarningThreshold: 16