// Use this for initialization void Start() { TrackOBJ = GetComponent <SteamVR_TrackedObject>(); TeleportLine.gameObject.SetActive(false); TeleporterTargetObject.SetActive(false); TouchLast_x = 0; mySkybox.currentSkyBox = ChangeSkybox.skybox.Day; mySkybox.CheckCurrentSky(); }
void Update() { //for testing if (testing) { currentChapter = ChangeChapter; KillEnemyNum = killEnemyNum; testing = false; } else { ChangeChapter = currentChapter; killEnemyNum = KillEnemyNum; } //Chapter01 if (currentChapter == Chapter.Chapter1) { if (startbook.EventNowHappen) { UTCplayable01.Play(); startbook.EventNowHappen = false; } if (GetHappyBall) { UTCplayable01.Resume(); } else if (UTCplayable01.time > 12.42) { UTCplayable01.Pause(); Happyball.SetActive(true); } if (UTCplayable01.time > 19.15) { UTCplayable01.Stop(); UTC01.SetActive(false); currentChapter = Chapter.Chapter2; } } //Chapter02 if (currentChapter == Chapter.Chapter2) { if (door.isOpen || door2.isOpen) { start02 = true; } if (!hasPlay) { if (start02) { UTCplayable02.Play(); hasPlay = true; } } if (UTCplayable02.time > 8.8) { UTC02.SetActive(false); currentChapter = Chapter.Chapter3; } } //Chapter03 if (currentChapter == Chapter.Chapter3) { if (!isChangeWeather2) { if (PrincessDoor.EventNowHappen || PrincessDoor2.EventNowHappen) { changeSkybox.currentSkyBox = ChangeSkybox.skybox.Night; changeSkybox.CheckCurrentSky(); isChangeWeather = true; } } if (!isChangeWeather) { if (player.transform.position.x > 3f && player.transform.position.z < -15f) { changeSkybox.currentSkyBox = ChangeSkybox.skybox.Falling; changeSkybox.CheckCurrentSky(); isChangeWeather = true; } } if (lamp.EventNowHappen) { PrincessDoor.isLock = false; PrincessDoor2.isLock = false; UTCplayable03.Play(); lamp.EventNowHappen = false; if (UTCObject.transform.localPosition != Vector3.zero) { UTCObject.transform.localPosition = Vector3.zero; UTCObject.transform.localRotation = Quaternion.Euler(0, 0, 0); } if (!isCp3Audio1Play) { chapter3AudioSource.clip = chapter3AudioClips[0]; chapter3AudioSource.loop = false; chapter3AudioSource.Play(); isCp3Audio1Play = true; countTo2 = true; } } if (countTo2) { ToVoice2Timer += Time.deltaTime; if (ToVoice2Timer > 18.5f) { if (!chapter3AudioSource.isPlaying) { chapter3AudioSource.clip = chapter3AudioClips[1]; chapter3AudioSource.loop = true; chapter3AudioSource.Play(); countTo2 = false; } } } if (NotCry) { if (!isNotCry) { foreach (SkinnedMeshRenderer M in meshRenders) { M.material.shader = TransparentShader; } chapter3AudioSource.clip = chapter3AudioClips[2]; chapter3AudioSource.loop = true; chapter3AudioSource.Play(); isNotCry = true; } } if (Disappear) { UTC03.SetActive(false); UTCplayable03.Stop(); Elephant.GetComponent <Rigidbody>().isKinematic = false; fearBall.SetActive(true); Disappear = false; chapter3AudioSource.loop = false; chapter3AudioSource.Stop(); } if (GetFearBall) { TimeLine4.SetActive(true); currentChapter = Chapter.Chapter4; } } //Chapter04 if (currentChapter == Chapter.Chapter4) { if (player.transform.position.z > -13f) { if (!isVoice1Play) { chapter4AudioSource.clip = chapter4AudioClips[0]; chapter4AudioSource.loop = false; chapter4AudioSource.Play(); isVoice1Play = true; beginCountToVoice2 = true; } } if (beginCountToVoice2) { Cp4_ToVoice2Timer += Time.deltaTime; if (Cp4_ToVoice2Timer > 7) { playerAudioSource.Play(); chapter4AudioSource.clip = chapter4AudioClips[1]; chapter4AudioSource.loop = true; chapter4AudioSource.Play(); beginCountToVoice2 = false; } } if (GetAngryBall) { playerHealth.HP.gameObject.SetActive(true); if (!playerHealth.Alive) { LoadLevel.levelName = "BadEnd"; LoadLevel.Trigger(); } else { if (KillEnemyNum == 5) { chapter4AudioSource.clip = chapter4AudioClips[2]; chapter4AudioSource.loop = false; chapter4AudioSource.Play(); TimeLine4.SetActive(false); TimeLine5.SetActive(true); currentChapter = Chapter.Chapter5; } } } } //Chapter05 if (currentChapter == Chapter.Chapter5) { if (GetSadBall) { player.transform.position = new Vector3(-1f, 0, -10f); BlackWall.SetActive(true); emotionSys.IndexIsLock = true; } if (Vector3.Angle(Head.transform.forward, BlackWall.transform.forward) < 60 && Vector3.Angle(rightHand.transform.forward, BlackWall.transform.forward) < 60 && SpotLighting.activeInHierarchy) { if (!hasPlayed) { Lastvideo.Play(); chapter5AudioSource.Play(); hasPlayed = true; } } if (Lastvideo.isPlaying) { if (Lastvideo.time > 22.4f) { BlackWall.SetActive(false); player.transform.position = new Vector3(-1f, 0, -11f); TimeLine6.SetActive(true); emotionSys.IndexIsLock = false; emotionSys.InitBalls(); emotionSys.IndexIsLock = true; currentChapter = Chapter.Chapter6; } } } //Chapter06 if (currentChapter == Chapter.Chapter6) { if (GetLastBall) { combine.Combine = true; CombineTimer += Time.deltaTime; if (CombineTimer > 15.0f) { if (CheckTrueEndCondition()) { //player.transform.position = new Vector3(-1.5f, 0, -11f); iTween.MoveTo(player, new Vector3(-1.5f, 0, -11f), 3.0f); TimeLine6.SetActive(false); TimeLine7.SetActive(true); currentChapter = Chapter.Chapter7; } else { LoadLevel.levelName = "NormalEnd"; LoadLevel.Trigger(); } } } } //Chapter07 if (currentChapter == Chapter.Chapter7) { if (!TrueEndhasplayed) { iTween.MoveTo(player, new Vector3(1.5f, 0, -11f), 2.0f); trueEnd.Play(); TrueEndhasplayed = true; } trueEndTimer += Time.deltaTime; if (trueEndTimer > 27) { LoadLevel.levelName = "TrueEnd"; LoadLevel.Trigger(); } } }