Änderungen am 17.03.2025 aus der Schule getroffen.

This commit is contained in:
2025-03-17 20:17:49 +01:00
parent 7ab25e1ae9
commit 0698d6020e
21 changed files with 541 additions and 194 deletions

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyScanner : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerExit2D(Collider2D collision)
{
Destroy(collision.gameObject);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e386a9af92c72140910ee7319eae6a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Platform destroyer
/// Original script found in: https://stackoverflow.com/questions/75924903/instantiating-and-destroying-unity-prefabs.
/// </summary>
public class OffScreenDestroyPlatform : MonoBehaviour
{
public static Vector2? screenBounds;
private void FixedUpdate()
{
if (screenBounds == null) screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z));
if (transform.position.x < screenBounds.Value.x * 5)
{
Destroy(gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e1f87050f92a0048829711096bc7730
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -6,7 +6,7 @@ using UnityEngine;
public class PlatformGenerator : MonoBehaviour
{
/*
[SerializeField] private Transform platformStart;
[SerializeField] private System.Collections.Generic.List<Transform> platformList;
[SerializeField] Vector2 nextSpawnPos;
@@ -38,5 +38,5 @@ public class PlatformGenerator : MonoBehaviour
{
Transform platformLevelTransform = Instantiate(levelPlat, spawnPosition, Quaternion.identity);
return platformLevelTransform;
}
}*/
}

View File

@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Platform spawner
/// Original script found in: https://stackoverflow.com/questions/75924903/instantiating-and-destroying-unity-prefabs.
/// </summary>
public class PlatformSpawner : MonoBehaviour
{
[SerializeField] private int platformCount;
[SerializeField] private OffScreenDestroyPlatform platformPrefab;
void Start()
{
for (int i = 0; i < platformCount; i++)
{
var spawnPosition = new Vector2(Random.Range(1f, 10f), Random.Range(-2f, 2f));
Instantiate(platformPrefab, spawnPosition, Quaternion.identity);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c31972b8c73d95d4098ee6aca9c698e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -8,8 +8,9 @@ using UnityEngine;
/// </summary>
public class PlayerController : MonoBehaviour
{
[SerializeField] public float speed;
/*[SerializeField] public float speed;
[SerializeField] public float acceleration;
*/
[SerializeField] public float jumpPower;
private Rigidbody2D body;
@@ -25,9 +26,11 @@ public class PlayerController : MonoBehaviour
private void Update()
{
/*
// run logic auto
speed += acceleration * Time.deltaTime;
transform.Translate(new Vector2(1f, 0f) * speed * Time.deltaTime);
*/
// jump logic + jump animation
if (Input.GetKey(KeyCode.W) && isGround)

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnScanner : MonoBehaviour
{
[SerializeField] private GameObject platform;
private void OnTriggerExit2D(Collider2D collision)
{
Spawn();
}
private void Spawn()
{
Vector3 ggg = new Vector3(1f, 4f, 4f);
Instantiate(platform, ggg, Quaternion.identity);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: abc71bc493ba9934db2ea213b5133ba0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movePlatform : MonoBehaviour
{
[SerializeField] private float speed;
public float acceleration;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
speed += acceleration * Time.deltaTime;
transform.Translate(new Vector2(-1f, 0f) * speed * Time.deltaTime);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cd6ee5b0f1fa5844b8e9c942d62e9028
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: