Did some work

This commit is contained in:
2023-02-13 19:38:57 -04:00
parent 7f94dd7761
commit 3ceb5634df
9 changed files with 142 additions and 8 deletions

View File

@ -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<Rigidbody2D>();
PathGameObject = GameObject.Find("Path");
}
// Update is called once per frame
@ -15,4 +26,22 @@ public class GenerationController : MonoBehaviour
{
}
private void FixedUpdate() {
pathPointer = PathGameObject.GetComponent<PathingController>().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++;
}
}
}

View File

@ -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++;
}
}
}