Fertiges Game hochgeladen
This commit is contained in:
129
Assets/Scripts/Spielwelt/Enemie_Spawn_System.cs
Normal file
129
Assets/Scripts/Spielwelt/Enemie_Spawn_System.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class Enemie_Spawn_System : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public int roundCounter = 0; //Kann die Runden im Inspector manuell erh<72>hen
|
||||
[SerializeField] public int roundModifierMax3 = 0; // regelt die schwierigkeit der Anfangsrunden
|
||||
|
||||
public int spawnCounter = 0; // z<>hlt wie viele Enemies gespawnt wurden & sorgt daf<61>r, dass der Shop wieder gespawnt wird
|
||||
|
||||
public GameObject Tank; // <---- Zu spawnende Prefab Einf<6E>gen
|
||||
public GameObject Standart; // <---- Zu spawnende Prefab Einf<6E>gen
|
||||
public GameObject Kamikaze; // <---- Zu spawnende Prefab Einf<6E>gen
|
||||
|
||||
public GameObject ShopPrefab;
|
||||
public Transform SpawnShop; // Punkt, an welchem der Shop respawnt wird
|
||||
|
||||
public Transform SpawnMitteOben; // Punkt, von dem die Enemies gespawnt werden
|
||||
public Transform SpawnMitteUnten; // Punkt, von dem die Enemies gespawnt werden
|
||||
public Transform SpawnMitteLinks; // Punkt, von dem die Enemies gespawnt werden
|
||||
public Transform SpawnMitteRechts; // Punkt, von dem die Enemies gespawnt werden
|
||||
public Transform SpawnLinksUnten; // Punkt, von dem die Enemies gespawnt werden
|
||||
public Transform SpawnRechtsUnten; // Punkt, von dem die Enemies gespawnt werden
|
||||
public Transform SpawnLinksOben; // Punkt, von dem die Enemies gespawnt werden
|
||||
public Transform SpawnRechtsOben; // Punkt, von dem die Enemies gespawnt werden
|
||||
|
||||
public TextMeshProUGUI Round_Counter; // <---- Kontrolliert die Rundenanzeige
|
||||
public TextMeshProUGUI Enemie_Counter; // <---- Kontrolliert die Anzahlanzeige der Gegner
|
||||
|
||||
private bool canSpawnShop = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//ShopPrefab = Resources.Load<GameObject>("Shop Prefab");
|
||||
canSpawnShop = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
ShopRespawner();
|
||||
}
|
||||
|
||||
public void SpawnEnemies()
|
||||
{
|
||||
if (Tank != null && Standart != null && Kamikaze != null && SpawnMitteOben != null && SpawnMitteUnten != null && SpawnMitteLinks != null && SpawnMitteRechts != null && SpawnLinksUnten != null && SpawnRechtsUnten != null && SpawnLinksOben != null && SpawnRechtsOben != null)
|
||||
{
|
||||
Destroy(GameObject.FindGameObjectWithTag("Shop Prefab"));
|
||||
roundCounter++;
|
||||
Round_Counter.text = roundCounter.ToString();
|
||||
|
||||
Instantiate(Standart, SpawnMitteOben.position, SpawnMitteOben.rotation);
|
||||
Instantiate(Standart, SpawnMitteUnten.position, SpawnMitteUnten.rotation);
|
||||
Instantiate(Kamikaze, SpawnMitteLinks.position, SpawnMitteLinks.rotation);
|
||||
Instantiate(Kamikaze, SpawnMitteRechts.position, SpawnMitteRechts.rotation);
|
||||
ChangeEnemyCounter(4);
|
||||
|
||||
|
||||
if (roundCounter == roundModifierMax3) // Special-Runde0
|
||||
{
|
||||
Instantiate(Kamikaze, SpawnLinksUnten.position, SpawnLinksUnten.rotation);
|
||||
Instantiate(Kamikaze, SpawnRechtsUnten.position, SpawnRechtsUnten.rotation);
|
||||
Instantiate(Kamikaze, SpawnLinksOben.position, SpawnLinksOben.rotation);
|
||||
Instantiate(Kamikaze, SpawnRechtsOben.position, SpawnRechtsOben.rotation);
|
||||
ChangeEnemyCounter(4);
|
||||
}
|
||||
|
||||
if (roundCounter == roundModifierMax3 * 2) // Special-Runde1 Kamikaze
|
||||
{
|
||||
Instantiate(Standart, SpawnLinksUnten.position, SpawnLinksUnten.rotation);
|
||||
Instantiate(Standart, SpawnRechtsUnten.position, SpawnRechtsUnten.rotation);
|
||||
Instantiate(Standart, SpawnLinksOben.position, SpawnLinksOben.rotation);
|
||||
Instantiate(Standart, SpawnRechtsOben.position, SpawnRechtsOben.rotation);
|
||||
ChangeEnemyCounter(4);
|
||||
}
|
||||
|
||||
if (roundCounter == roundModifierMax3 * 3) // Special-Runde2 Standart Enemies & Tanks
|
||||
{
|
||||
Instantiate(Tank, SpawnLinksUnten.position, SpawnLinksUnten.rotation);
|
||||
Instantiate(Tank, SpawnRechtsUnten.position, SpawnRechtsUnten.rotation);
|
||||
Instantiate(Tank, SpawnLinksOben.position, SpawnLinksOben.rotation);
|
||||
Instantiate(Tank, SpawnRechtsOben.position, SpawnRechtsOben.rotation);
|
||||
Instantiate(Standart, SpawnMitteOben.position, SpawnMitteOben.rotation);
|
||||
Instantiate(Standart, SpawnMitteUnten.position, SpawnMitteUnten.rotation);
|
||||
Instantiate(Standart, SpawnMitteLinks.position, SpawnMitteLinks.rotation);
|
||||
Instantiate(Standart, SpawnMitteRechts.position, SpawnMitteRechts.rotation);
|
||||
ChangeEnemyCounter(8);
|
||||
}
|
||||
|
||||
if (roundCounter >= 20)
|
||||
{
|
||||
for (int i = 0 + roundCounter - 15; i > 0; i--)
|
||||
{
|
||||
Instantiate(Tank, SpawnLinksUnten.position, SpawnLinksUnten.rotation);
|
||||
Instantiate(Tank, SpawnRechtsUnten.position, SpawnRechtsUnten.rotation);
|
||||
Instantiate(Tank, SpawnLinksOben.position, SpawnLinksOben.rotation);
|
||||
Instantiate(Tank, SpawnRechtsOben.position, SpawnRechtsOben.rotation);
|
||||
Instantiate(Standart, SpawnMitteOben.position, SpawnMitteOben.rotation);
|
||||
Instantiate(Standart, SpawnMitteUnten.position, SpawnMitteUnten.rotation);
|
||||
Instantiate(Standart, SpawnMitteLinks.position, SpawnMitteLinks.rotation);
|
||||
Instantiate(Standart, SpawnMitteRechts.position, SpawnMitteRechts.rotation);
|
||||
Instantiate(Kamikaze, SpawnLinksOben.position, SpawnLinksOben.rotation);
|
||||
Instantiate(Kamikaze, SpawnRechtsOben.position, SpawnRechtsOben.rotation);
|
||||
Instantiate(Kamikaze, SpawnMitteOben.position, SpawnMitteOben.rotation);
|
||||
Instantiate(Kamikaze, SpawnMitteUnten.position, SpawnMitteUnten.rotation);
|
||||
ChangeEnemyCounter(12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ShopRespawner()
|
||||
{
|
||||
if (spawnCounter <= 0 && ShopPrefab != null && canSpawnShop)
|
||||
{
|
||||
Instantiate(ShopPrefab, SpawnShop.position, SpawnShop.rotation);
|
||||
Debug.Log("Spawned Shop" + roundCounter);
|
||||
canSpawnShop = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeEnemyCounter(int count)
|
||||
{
|
||||
spawnCounter += count;
|
||||
Enemie_Counter.text = spawnCounter.ToString();
|
||||
canSpawnShop = true;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Spielwelt/Enemie_Spawn_System.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/Enemie_Spawn_System.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea056f8883035a844856aa6ee265b621
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Assets/Scripts/Spielwelt/GameOverScreen.cs
Normal file
17
Assets/Scripts/Spielwelt/GameOverScreen.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class GameOverScreen : MonoBehaviour
|
||||
{
|
||||
public void RestartGame()
|
||||
{
|
||||
SceneManager.LoadScene(2);
|
||||
}
|
||||
|
||||
public void Back2MainMenue()
|
||||
{
|
||||
SceneManager.LoadScene(1);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Spielwelt/GameOverScreen.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/GameOverScreen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc6282b8ad9fc524293130bb565357e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
Assets/Scripts/Spielwelt/ItemShopButtons.cs
Normal file
30
Assets/Scripts/Spielwelt/ItemShopButtons.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ItemShopButtons : MonoBehaviour
|
||||
{
|
||||
public Button buyButton; // Der Button im Shop
|
||||
public GameObject player; // Dein Spieler-Objekt
|
||||
public MonoBehaviour weaponScript; // Das Skript f<>r die Waffe
|
||||
|
||||
private bool isUnlocked = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
buyButton.onClick.AddListener(UnlockWeapon);
|
||||
weaponScript.enabled = false; // Waffe ist am Anfang deaktiviert
|
||||
}
|
||||
|
||||
void UnlockWeapon()
|
||||
{
|
||||
if (!isUnlocked)
|
||||
{
|
||||
isUnlocked = true;
|
||||
weaponScript.enabled = true; // Aktiviere das Waffenskript
|
||||
buyButton.interactable = false; // Deaktiviere den Button nach dem Kauf
|
||||
Debug.Log("Waffe wurde freigeschaltet!");
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Spielwelt/ItemShopButtons.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/ItemShopButtons.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d14de6a589d29848958c530af44e3f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Assets/Scripts/Spielwelt/ParallaxBackground.cs
Normal file
45
Assets/Scripts/Spielwelt/ParallaxBackground.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class ParallaxBackground : MonoBehaviour
|
||||
{
|
||||
public ParallaxCamera parallaxCamera;
|
||||
List<ParallaxLayer> parallaxLayers = new List<ParallaxLayer>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (parallaxCamera == null)
|
||||
parallaxCamera = Camera.main.GetComponent<ParallaxCamera>();
|
||||
|
||||
if (parallaxCamera != null)
|
||||
parallaxCamera.onCameraTranslate += Move;
|
||||
|
||||
SetLayers();
|
||||
}
|
||||
|
||||
void SetLayers()
|
||||
{
|
||||
parallaxLayers.Clear();
|
||||
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
ParallaxLayer layer = transform.GetChild(i).GetComponent<ParallaxLayer>();
|
||||
|
||||
if (layer != null)
|
||||
{
|
||||
layer.name = "Layer-" + i;
|
||||
parallaxLayers.Add(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Move(float delta)
|
||||
{
|
||||
foreach (ParallaxLayer layer in parallaxLayers)
|
||||
{
|
||||
layer.Move(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
//https://www.youtube.com/watch?v=MEy-kIGE-lI
|
11
Assets/Scripts/Spielwelt/ParallaxBackground.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/ParallaxBackground.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96957a179dc92144fa00120f927aafd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
31
Assets/Scripts/Spielwelt/ParallaxCamera.cs
Normal file
31
Assets/Scripts/Spielwelt/ParallaxCamera.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class ParallaxCamera : MonoBehaviour
|
||||
{
|
||||
public delegate void ParallaxCameraDelegate(float deltaMovement);
|
||||
public ParallaxCameraDelegate onCameraTranslate;
|
||||
|
||||
private float oldPosition;
|
||||
|
||||
void Start()
|
||||
{
|
||||
oldPosition = transform.position.x;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (transform.position.x != oldPosition)
|
||||
{
|
||||
if (onCameraTranslate != null)
|
||||
{
|
||||
float delta = oldPosition - transform.position.x;
|
||||
onCameraTranslate(delta);
|
||||
}
|
||||
|
||||
oldPosition = transform.position.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//https://www.youtube.com/watch?v=MEy-kIGE-lI
|
11
Assets/Scripts/Spielwelt/ParallaxCamera.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/ParallaxCamera.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46fad2045c7b5a0479a7682ddba2f2bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Assets/Scripts/Spielwelt/ParallaxLayer.cs
Normal file
16
Assets/Scripts/Spielwelt/ParallaxLayer.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class ParallaxLayer : MonoBehaviour
|
||||
{
|
||||
public float parallaxFactor;
|
||||
|
||||
public void Move(float delta)
|
||||
{
|
||||
Vector3 newPos = transform.localPosition;
|
||||
newPos.x -= delta * parallaxFactor;
|
||||
|
||||
transform.localPosition = newPos;
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/Spielwelt/ParallaxLayer.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/ParallaxLayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00e70683d35fa6e4abd43e85299f0a21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Scripts/Spielwelt/Reset_Highscore.cs
Normal file
14
Assets/Scripts/Spielwelt/Reset_Highscore.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SocialPlatforms.Impl;
|
||||
|
||||
public class Reset_Highscore : MonoBehaviour
|
||||
{
|
||||
public void ResetHighscore()
|
||||
{
|
||||
PlayerPrefs.DeleteKey("HighScore");
|
||||
PlayerPrefs.SetFloat("HighScore", 0f);
|
||||
Debug.Log("HighScore wurde Gel<65>scht");
|
||||
}
|
||||
}
|
11
Assets/Scripts/Spielwelt/Reset_Highscore.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/Reset_Highscore.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96876b6494284c1498943a8af18d279e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/Scripts/Spielwelt/Start_Next_Round.cs
Normal file
22
Assets/Scripts/Spielwelt/Start_Next_Round.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Start_Next_Round : MonoBehaviour
|
||||
{
|
||||
public GameObject shopPrefab;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void DeaktiviereShop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Spielwelt/Start_Next_Round.cs.meta
Normal file
11
Assets/Scripts/Spielwelt/Start_Next_Round.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4cb09af40c6c3b46b8920eeb732730d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user