void Update() { if (bouge) { transform.position = Vector3.MoveTowards(transform.position, other.transform.position, Time.deltaTime * vitesse / 2); transform.position = Vector3.Lerp(transform.position, other.transform.position, Time.deltaTime * smoothing); if (Vector3.Distance(transform.position, other.transform.position) < 0.1) { bouge = false; Logique.jouable = true; suit = true; } } if (suit) { transform.position = other.transform.position; } if (pose) { suit = false; transform.position = Vector3.MoveTowards(transform.position, other.transform.position + Control.direction, Time.deltaTime * vitesse / 2); transform.position = Vector3.Lerp(transform.position, other.transform.position + Control.direction, Time.deltaTime * smoothing); if (Vector3.Distance(transform.position, other.transform.position) > 0.4) { Logique.jouable = true; pose = false; colliderBoite.enabled = true; } } if (Input.GetKeyDown(KeyCode.Return)) { //Debug.Log("THIS : " + this + " minObject : " + Logique.minObject() + "comparaison : " + this.GetComponent<CubeIntObject>()); //Debug.Log("Test bool : " + (Logique.minObject().GetComponent<CubeIntObject>() == this.GetComponent<CubeIntObject>())); if (porte) { porte = false; bouge = false; Logique.jouable = false; pose = true; } else if (colliderBoite.Distance(colliderJoueur).distance < 0.25 && (Logique.minObject() == this.gameObject)) { if (this.GetComponent <CubeEnigmeObject> () != null) { Debug.Log("CLEF = " + this.GetComponent <CubeEnigmeObject> ().cubeEnigme.enigme.clef); } if (!porte) { colliderBoite.enabled = false; porte = true; bouge = true; Logique.jouable = false; } } } }
// Use this for initialization void Awake() { //var lvl = PlayerPrefs.GetInt("level", 1); //var secteur = PlayerPrefs.GetInt("secteur", 1); sceneName = "Level " + secteur + "-" + lvl; #if UNITY_EDITOR //var editor = UnityEditor.SceneManagement.EditorSceneManager.GetSceneManagerSetup(); //Debug.Log(editor); #endif if (instance != null && sceneName == instance.sceneName) { Destroy(gameObject); return; } else if (instance != null) { Destroy(instance.gameObject); } instance = this; DontDestroyOnLoad(gameObject); Kill.kill(null); #if !UNITY_EDITOR UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName, UnityEngine.SceneManagement.LoadSceneMode.Additive); #endif }