holopy3/Assets/Scripts/MiniGamePlay.cs

117 lines
3.1 KiB
C#
Raw Permalink Normal View History

2020-12-10 14:25:12 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MiniGamePlay : MonoBehaviour
{
public GameObject FireWork;
public GameObject OL;
public GameObject OR;
public GameObject UL;
public GameObject UR;
private bool ol;
private bool or;
private bool ul;
private bool ur;
void Start()
{
FireWork.SetActive(false);
}
// Update is called once per frame
void Update()
{
// Puzzleteil ObenLinks
if (OL != null)
{
if (OL.transform.position.x > 0.9f && OL.transform.position.x < 1.1f && OL.transform.position.z > -1.1f && OL.transform.position.z < -0.9f)
{
OL.transform.position = new Vector3(1, 1, -1);
OL.transform.rotation = Quaternion.identity;
print(OL.transform.position);
OL.GetComponent<Rigidbody>().isKinematic = true;
OL.GetComponent<Rigidbody>().detectCollisions = false;
ol = true;
}
}
// Puzzleteil ObenRechts
if (OR != null)
{
if (OR.transform.position.x > -1.1f && OR.transform.position.x < -0.9f && OR.transform.position.z > -1.1f && OR.transform.position.z < -0.9f)
{
OR.transform.position = new Vector3(-1, 1, -1);
OR.transform.rotation = Quaternion.identity;
print(OR.transform.position);
OR.GetComponent<Rigidbody>().isKinematic = true;
OR.GetComponent<Rigidbody>().detectCollisions = false;
or = true;
}
}
// Puzzleteil UntenLinks
if (UL != null)
{
if (UL.transform.position.x > 0.9f && UL.transform.position.x < 1.1f && UL.transform.position.z > 0.9f && UL.transform.position.z < 1.1f)
{
UL.transform.position = new Vector3(1, 1, 1);
UL.transform.rotation = Quaternion.identity;
print(OL.transform.position);
UL.GetComponent<Rigidbody>().isKinematic = true;
UL.GetComponent<Rigidbody>().detectCollisions = false;
ul = true;
}
}
// Puzzleteil UntenRechts
if (UR != null)
{
if (UR.transform.position.x > -1.1f && UR.transform.position.x < -0.9f && UR.transform.position.z > 0.9f && UR.transform.position.z < 1.1f)
{
UR.transform.position = new Vector3(-1, 1, 1);
UR.transform.rotation = Quaternion.identity;
print(OR.transform.position);
UR.GetComponent<Rigidbody>().isKinematic = true;
UR.GetComponent<Rigidbody>().detectCollisions = false;
ur = true;
}
}
// Winning
if (ol && or && ul && ur)
{
StartCoroutine("Winning");
}
}
private IEnumerator Winning()
{
yield return new WaitForSeconds(2f);
Destroy(OL);
Destroy(OR);
Destroy(UL);
Destroy(UR);
FireWork.SetActive(true);
}
}