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().isKinematic = true; OL.GetComponent().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().isKinematic = true; OR.GetComponent().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().isKinematic = true; UL.GetComponent().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().isKinematic = true; UR.GetComponent().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); } }