Merge branch 'features/world' of https://git.bib.de/PBA3H24ASE/ConvenientHorror
# Conflicts: # Assets/Scenes/Lilia.unity
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:
|
||||
31
Assets/Scripts/Cameras/CameraLook.cs
Normal file
31
Assets/Scripts/Cameras/CameraLook.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraLook : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float cameraSensivity;
|
||||
[SerializeField] private float minLookDist;
|
||||
[SerializeField] private float maxLookDist;
|
||||
|
||||
Vector2 touchDeltaPosition;
|
||||
float camLookDist;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
camLookDist = transform.localRotation.y;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.touchCount > 0 &&
|
||||
Input.GetTouch(0).phase == TouchPhase.Moved) {
|
||||
|
||||
touchDeltaPosition = Input.GetTouch(0).deltaPosition;
|
||||
camLookDist = Mathf.Clamp(camLookDist + touchDeltaPosition.x * cameraSensivity, minLookDist, maxLookDist);
|
||||
transform.localRotation = Quaternion.Euler(0f, camLookDist, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
Assets/Scripts/Cameras/CameraLook.cs.meta
Normal file
2
Assets/Scripts/Cameras/CameraLook.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49abaa4b8268a754399fa82119a91c67
|
||||
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
|
||||
8
Assets/Scripts/Door.meta
Normal file
8
Assets/Scripts/Door.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d0ed0651b788d043acff35acd73ef9d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
59
Assets/Scripts/Door/Door.cs
Normal file
59
Assets/Scripts/Door/Door.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Door : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject light;
|
||||
|
||||
[SerializeField] private Vector3 openPos;
|
||||
[SerializeField] private Vector3 closePos;
|
||||
|
||||
[SerializeField] private float doorSpeed;
|
||||
|
||||
public bool isOpen;
|
||||
public bool isOn;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
transform.position = openPos;
|
||||
isOpen = true;
|
||||
|
||||
ChangeLights();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (isOpen) {
|
||||
if (transform.position != openPos) {
|
||||
// Damit sich die Tür smooth öffnen lässt.
|
||||
if (Vector3.Distance(transform.position, openPos) <= 0.5f) {
|
||||
transform.position = openPos;
|
||||
}
|
||||
else {
|
||||
transform.position = Vector3.Lerp(transform.position, openPos, doorSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (transform.position != closePos) {
|
||||
// Damit sich die Tür smooth öffnen lässt.
|
||||
if (Vector3.Distance(transform.position, closePos) <= 0.5f) {
|
||||
transform.position = closePos;
|
||||
} else {
|
||||
transform.position = Vector3.Lerp(transform.position, closePos, doorSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeLights() {
|
||||
isOn = !isOn;
|
||||
|
||||
if (isOn) {
|
||||
light.SetActive(true);
|
||||
}
|
||||
else {
|
||||
light.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Door/Door.cs.meta
Normal file
2
Assets/Scripts/Door/Door.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a009b121b39a02d4a8dddf11cbda97cc
|
||||
10
Assets/Scripts/Door/DoorController.cs
Normal file
10
Assets/Scripts/Door/DoorController.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DoorController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Door door;
|
||||
|
||||
private void OnMouseDown() {
|
||||
door.isOpen = !door.isOpen;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Door/DoorController.cs.meta
Normal file
2
Assets/Scripts/Door/DoorController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b48d47b843b1eb242981ed20cce0db89
|
||||
10
Assets/Scripts/Door/LightController.cs
Normal file
10
Assets/Scripts/Door/LightController.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class LightSystem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Door door;
|
||||
|
||||
private void OnMouseDown() {
|
||||
door.ChangeLights();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Door/LightController.cs.meta
Normal file
2
Assets/Scripts/Door/LightController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eef5257bc8558642b991b9857cf053f
|
||||
Reference in New Issue
Block a user