Fertiges Game hochgeladen

This commit is contained in:
2025-03-14 15:09:56 +01:00
parent d1ed78ae57
commit eb964d5fca
558 changed files with 81656 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Bullet_movement : MonoBehaviour
{
[SerializeField] private float verticalSpeed = 15.0f;
[SerializeField] private float remainInAir = 1.0f;
private float counter = 0f;
public GameObject player;
private PlayerMovement playerMovement;
// Start is called before the first frame update
void Start()
{
player = GameObject.FindWithTag("Starship");
playerMovement = player.GetComponent<PlayerMovement>();
}
// Update is called once per frame
void Update()
{
Movement();
}
private void Movement()
{
transform.Translate(Vector3.up * Time.deltaTime * verticalSpeed);
counter += Time.deltaTime;
if (counter >= remainInAir)
{
Destroy(gameObject);
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Enemy"))
{
playerMovement.score += 1f;
Destroy(gameObject);
}
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Menü_Rotation : MonoBehaviour
{
void Update()
{
Movement();
}
private void Movement()
{
Vector3 mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
Vector2 direction = new Vector2(mousePosition.x - transform.position.x, mousePosition.y - transform.position.y);
transform.up = direction;
}
}

View File

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

View File

@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UIElements;
public class OnPlayerDeath : MonoBehaviour
{
[SerializeField] private UnityEngine.UI.Image DeathScreen;
[SerializeField] private TMP_Text Score;
[SerializeField] private TMP_Text Highscore;
[SerializeField] private TMP_Text RoundCounter;
[SerializeField] private TMP_Text Verbleibend;
// Start is called before the first frame update
public void onDeathUI()
{
DeathScreen.gameObject.SetActive(true);
Score.gameObject.SetActive(false);
Highscore.gameObject.SetActive(false);
RoundCounter.gameObject.SetActive(false);
Verbleibend.gameObject.SetActive(false);
}
}

View File

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

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerRotation : MonoBehaviour
{
// Update is called once per frame
void Update()
{
Vector3 mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
Vector2 direction = new Vector2(mousePosition.x - transform.position.x, mousePosition.y - transform.position.y);
transform.up = direction;
//https://www.youtube.com/watch?v=9_i6S_rDZuA script von hier
}
}

View File

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

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerShooting_Laser : MonoBehaviour
{
[SerializeField] private KeyCode shootingKeyCode = KeyCode.Mouse0;
[SerializeField] private float shootDelay = 1;
private float timer = 0;
public GameObject Starship_LASER_bullet;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
HandleShooting();
}
private void HandleShooting()
{
timer += Time.deltaTime;
if (Input.GetKey(shootingKeyCode) && timer >= shootDelay)
{
timer = 0;
if (Starship_LASER_bullet != null)
{
GameObject newBullet = Instantiate(Starship_LASER_bullet, transform.position, Quaternion.identity);
newBullet.transform.up = transform.up;
}
}
}
}

View File

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

View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Shooting_Plasma : MonoBehaviour
{
[SerializeField] private KeyCode shootingKeyCode = KeyCode.Mouse1;
public GameObject Plasma_Prefab;
public bool isUnlocked = false; // Bool wird durch den Shop ge<67>ndert
[SerializeField] private float shootDelay = 1;
private float timer = 0;
void Update()
{
HandleShootingPlasma();
}
private void HandleShootingPlasma()
{
if (!isUnlocked) return;
timer += Time.deltaTime;
if (Input.GetKey(shootingKeyCode) && timer >= shootDelay)
{
timer = 0;
if (Plasma_Prefab != null)
{
GameObject newBullet = Instantiate(Plasma_Prefab, transform.position, Quaternion.identity);
newBullet.transform.up = transform.up;
}
}
}
public void UnlockPlasma()
{
isUnlocked = true;
Debug.Log("Plasma wurde freigeschaltet!");
}
}

View File

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

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Shooting_Rockets : MonoBehaviour
{
[SerializeField] private KeyCode shootingKeyCode = KeyCode.Mouse1;
public GameObject Rockets_Prefab;
public bool isUnlocked = false; // Bool wird durch den Shop ge<67>ndert
[SerializeField] private float shootDelay = 1;
private float timer = 0;
void Update()
{
HandleShootingRockets();
}
private void HandleShootingRockets()
{
if (!isUnlocked) return;
timer += Time.deltaTime;
if (Input.GetKeyDown(shootingKeyCode) && timer >= shootDelay)
{
timer = 0;
if (Rockets_Prefab != null)
{
GameObject newBullet = Instantiate(Rockets_Prefab, transform.position, Quaternion.identity);
newBullet.transform.up = transform.up;
}
}
}
public void UnlockWeapon()
{
isUnlocked = true;
Debug.Log("Raketenwerfer wurde freigeschaltet!");
}
}

View File

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

View File

@@ -0,0 +1,111 @@
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using TMPro;
public class PlayerMovement : MonoBehaviour
{
public float score = 0f;
public Vector3 moveVector;
public GameObject character;
private Rigidbody2D rb;
public GameObject uiElement;
public TextMeshProUGUI scoreText;
public TextMeshProUGUI highscoreText;
[SerializeField] private float minXCoordinate = -8.0f;
[SerializeField] private float maxXCoordinate = 8.0f;
[SerializeField] private float minYCoordinate = -5.0f;
[SerializeField] private float maxYCoordinate = 5.0f;
[SerializeField] private float horizontalSpeed = 5;
[SerializeField] private float verticalSpeed = 5;
void Start()
{
rb = GetComponent<Rigidbody2D>();
moveVector = Vector3.zero;
highscoreText.text = PlayerPrefs.GetFloat("HighScore").ToString();
}
// Update is called once per frame
void Update()
{
handleMovement();
ScorePanel();
}
private void handleMovement()
{
// Aufgabe:
// 1. Abfragen der Vertical Axis
// 2. Wert in movementDirection setzen
// 3. Neue Grenzen f<>r oben und unten anlegen
// 4. Position des Spieler auf neue Grenzen testen
// und ggf. zur<75>cksetzen
Vector3 movementDirection;
float deltaX = Input.GetAxis("Horizontal"); // Vertical
float deltaY = Input.GetAxis("Vertical"); // Vertical
movementDirection = new Vector3(deltaX, 0, 0);
// x-movement
transform.position += movementDirection * horizontalSpeed * Time.deltaTime;
// Alternativ: transform.Translate(movementDirection * horizontalSpeed * Time.deltaTime);
if (transform.position.x < minXCoordinate)
{
transform.position = new Vector3(minXCoordinate, transform.position.y, transform.position.z);
}
else if (transform.position.x > maxXCoordinate)
{
transform.position = new Vector3(maxXCoordinate, transform.position.y, transform.position.z);
}
// y-movement
movementDirection = new Vector3(0, deltaY, 0);
transform.position += movementDirection * verticalSpeed * Time.deltaTime;
if (transform.position.y < minYCoordinate)
{
transform.position = new Vector3(transform.position.x, minYCoordinate, transform.position.z);
}
else if (transform.position.y > maxYCoordinate)
{
transform.position = new Vector3(transform.position.x, maxYCoordinate, transform.position.z);
}
}
public void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Shop Prefab") && uiElement != null)
{
uiElement.SetActive(true);
}
Debug.Log("Aktiviert");
}
public void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.CompareTag("Shop Prefab") && uiElement != null)
{
uiElement.SetActive(false);
}
Debug.Log("Deaktiviert");
}
private void ScorePanel()
{
scoreText.text = score.ToString();
if (score > PlayerPrefs.GetFloat("HighScore", 0f))
{
PlayerPrefs.SetFloat("HighScore", score);
highscoreText.text = score.ToString($"{score}");
}
}
}

View File

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