Initial commit
This commit is contained in:
23
Assets/Scripts/FlagScript.cs
Normal file
23
Assets/Scripts/FlagScript.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class FlagScript : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log("Spieler hat die Flagge ber<65>hrt! Level gewonnen!");
|
||||
|
||||
WinLevel();
|
||||
}
|
||||
}
|
||||
|
||||
private void WinLevel()
|
||||
{
|
||||
SceneManager.LoadScene("NextLevel");
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/FlagScript.cs.meta
Normal file
11
Assets/Scripts/FlagScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eef05e33fda97a341a002be538fdc65f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Scripts/GameOver.cs
Normal file
25
Assets/Scripts/GameOver.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class GameOverUI : MonoBehaviour
|
||||
{
|
||||
public void RestartGame()
|
||||
{
|
||||
SceneManager.LoadScene("LVL1");
|
||||
}
|
||||
|
||||
|
||||
public void GoToMainMenu()
|
||||
{
|
||||
SceneManager.LoadScene("MainMenu");
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Debug.Log("Spiel beendet! (Funktioniert nur in einer Build-Version)");
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/GameOver.cs.meta
Normal file
11
Assets/Scripts/GameOver.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53744f45837228b4c90956fd73c01b00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Assets/Scripts/MainMenuUi.cs
Normal file
20
Assets/Scripts/MainMenuUi.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class MainMenuUI : MonoBehaviour
|
||||
{
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
SceneManager.LoadScene("LVL1");
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Debug.Log("Spiel beendet! (Funktioniert nur in einer Build-Version)");
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/MainMenuUi.cs.meta
Normal file
11
Assets/Scripts/MainMenuUi.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31a0120d4322fc94eba8038d7ff3905f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Assets/Scripts/PlayerMovement.cs
Normal file
45
Assets/Scripts/PlayerMovement.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMovement2D : MonoBehaviour
|
||||
{
|
||||
public float speed = 5f;
|
||||
public float jumpForce = 10f;
|
||||
private Rigidbody2D rb;
|
||||
private bool isGrounded;
|
||||
|
||||
void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Bewegung
|
||||
float move = Input.GetAxis("Horizontal");
|
||||
rb.velocity = new Vector2(move * speed, rb.velocity.y);
|
||||
|
||||
// Springen
|
||||
if (Input.GetButtonDown("Jump") && isGrounded)
|
||||
{
|
||||
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Ground"))
|
||||
{
|
||||
isGrounded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionExit2D(Collision2D collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Ground"))
|
||||
{
|
||||
isGrounded = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/PlayerMovement.cs.meta
Normal file
11
Assets/Scripts/PlayerMovement.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abb3c97f77e7020499882b024a7aabec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
31
Assets/Scripts/WallMovement.cs
Normal file
31
Assets/Scripts/WallMovement.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class DeathWall : MonoBehaviour
|
||||
{
|
||||
public Transform player;
|
||||
public float speed = 2f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
Vector3 targetPosition = new Vector3(player.position.x, transform.position.y, transform.position.z);
|
||||
transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
SceneManager.LoadScene("GameOverScene");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
11
Assets/Scripts/WallMovement.cs.meta
Normal file
11
Assets/Scripts/WallMovement.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32b373bd36e3ddc4caabafb5556617f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user