Scene Change und basic Inventory implementiert

This commit is contained in:
Maximilian Wagner 2023-05-30 20:40:18 +02:00
parent 792c90a214
commit 4ea6222f27
7 changed files with 548 additions and 168 deletions

View File

@ -0,0 +1,29 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ChangeScene : MonoBehaviour
{
public Scene changeTo;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("SceneChanger"))
{
SceneManager.LoadScene(other.gameObject.name);
}
}
}

View File

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

View File

@ -0,0 +1,40 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class PickupCollision : MonoBehaviour
{
private List<GameObject> items;
// Start is called before the first frame update
void Start()
{
items = new List<GameObject>();
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter2D(Collision2D other)
{
switch (other.gameObject.tag) // switch-case hier damit in zukunft einfach fälle hinzugefügt werden können
{
case "Item":
other.gameObject.SetActive(false);
items.Add(other.gameObject);
Debug.Log("Pickup: Take " + other.gameObject.name);
break;
case "Openable":
// Entfernt den ersten "Key" welcher unter den Items gefunden wird, falls es einen gibt
if ( items.Remove((from item in items where item.name == "Key" select item).First()) )
{ // falls ein "Key" gefunden wurde, wird dieser genutzt
other.gameObject.SetActive(false);
Debug.Log("Pickup: Use Key");
}
break;
}
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -8,4 +8,7 @@ EditorBuildSettings:
- enabled: 1 - enabled: 1
path: Assets/Scenes/SampleScene.unity path: Assets/Scenes/SampleScene.unity
guid: 8c9cfa26abfee488c85f1582747f6a02 guid: 8c9cfa26abfee488c85f1582747f6a02
- enabled: 1
path: Assets/Scenes/Prototype.unity
guid: 690ad3268ada5f94b8d8d2ab06075ca8
m_configObjects: {} m_configObjects: {}

View File

@ -6,6 +6,9 @@ TagManager:
tags: tags:
- PressurePlatable - PressurePlatable
- PlayerIsOnIt - PlayerIsOnIt
- Item
- Openable
- SceneChanger
layers: layers:
- Default - Default
- TransparentFX - TransparentFX