Camera System halb fertig, wurde in letzter Unterrichtsstunde gemacht.
This commit is contained in:
8
Assets/Scripts/Cameras.meta
Normal file
8
Assets/Scripts/Cameras.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10a0d1b128cd3b246ab50fa65a2019d4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
Assets/Scripts/Cameras/CameraSystem.cs
Normal file
73
Assets/Scripts/Cameras/CameraSystem.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraSystem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject[] cams;
|
||||
[SerializeField] private GameObject mainCam;
|
||||
[SerializeField] private int currentCam;
|
||||
[SerializeField] private KeyCode openCam;
|
||||
[SerializeField] private bool camIsOpen;
|
||||
[SerializeField] private float cdTimer;
|
||||
[SerializeField] private float cdTime = 0.5f;
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < cams.Length; i++) {
|
||||
cams[i].SetActive(false);
|
||||
}
|
||||
mainCam.SetActive(true);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(openCam)) {
|
||||
camIsOpen = !camIsOpen;
|
||||
ShowCam();
|
||||
}
|
||||
|
||||
if (cdTimer <= 0) {
|
||||
if (Input.GetAxis("Horizontal") > 0) {
|
||||
cams[currentCam].SetActive(false);
|
||||
currentCam = currentCam + 1;
|
||||
if (currentCam >= cams.Length) {
|
||||
currentCam = 0;
|
||||
}
|
||||
Go2Cam(currentCam);
|
||||
cdTimer = cdTime;
|
||||
}
|
||||
else if (Input.GetAxis("Horizontal") < 0) {
|
||||
cams[currentCam].SetActive(false);
|
||||
currentCam = currentCam - 1;
|
||||
if (currentCam < 0) {
|
||||
currentCam = cams.Length - 1;
|
||||
}
|
||||
Go2Cam(currentCam);
|
||||
cdTimer = cdTime;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cdTimer -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowCam() {
|
||||
if (camIsOpen) {
|
||||
cams[currentCam].SetActive(true);
|
||||
mainCam.SetActive(false);
|
||||
}
|
||||
else {
|
||||
cams[currentCam].SetActive(false);
|
||||
mainCam.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Go2Cam(int progression) {
|
||||
cams[currentCam].SetActive(false);
|
||||
currentCam = progression;
|
||||
ShowCam();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Cameras/CameraSystem.cs.meta
Normal file
2
Assets/Scripts/Cameras/CameraSystem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc016bf314b3fa446a75c1810d0e5df6
|
||||
@@ -1,29 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DoorSystem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject[] doors;
|
||||
[SerializeField] private GameObject[] doorSwitchers;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool DoorOpen() {
|
||||
// Tür ist zu, dann zieh Energie ab, Gegner können nicht angereifen, man kann Schalter drücken um zu öffnen
|
||||
// Tür ist offen, Angriff auf Spieler ist möglich, man kann auf Schalter drücken und zu machen
|
||||
return true;
|
||||
}
|
||||
|
||||
// Plan
|
||||
// Script an Tür, damit es auf und zu geht, also hoch und runter, dabei wird es in Y Achse skaliert + Y Achse neu positioniert
|
||||
// Wenn man auf Schalter neben der Tür tippt, dann betätigt man die Tür, aber es zieht Strom ab
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe9a94abb4818624cbe981af6c2f18cd
|
||||
Reference in New Issue
Block a user