void SetAnimation() { if (spawn) { RendererRun.sprite = AnimationSpawn.GetNext(); RendererDust.sprite = null; spawn = !AnimationSpawn.IsFinished(); } else { RendererRun.sprite = AnimationRun.GetNext(); RendererDust.sprite = AnimationDust.GetNext(); } }
void Update() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, 9999)) { GameObject obj = hit.transform.gameObject; Debug.Log(obj.tag); if (obj.tag == "North") { pointer.eulerAngles = northRotation; Debug.Log("North Wall Hit!"); } else if (obj.tag == "South") { pointer.eulerAngles = southRotation; Debug.Log("South Wall Hit!"); } else if (obj.tag == "East") { pointer.eulerAngles = eastRotation; Debug.Log("East Wall Hit!"); } else if (obj.tag == "West") { pointer.eulerAngles = westRotation; Debug.Log("West Wall Hit!"); } else if (obj.tag == "Floor") { pointer.eulerAngles = floorRotation; Debug.Log("Floor Hit!"); } else if (obj.tag == "Ceiling") { pointer.eulerAngles = ceilingRotation; Debug.Log("Ceiling Hit!"); } Vector3 toCamera = (cam.position - hit.point).normalized; pointer.position = hit.point + toCamera * offset; bool hittingTarget = obj.tag == "Button" || obj.tag == "SoundEmitter" || obj.tag == "StartButton"; if (!animationPlaying && hittingTarget) { //pointerPlayer.enabled = true; //pointerPlayer.Play (); animationPlaying = true; wandPointerAnimation.Begin(); if (obj.tag == "StartButton") { startButtonMaterial.SetTexture("_MainTex", pressedButtonTexture); sendStartButton.startClue = true; } } else if (animationPlaying && !hittingTarget) { //pointerPlayer.Stop (); //pointerPlayer.enabled = false; animationPlaying = false; wandPointerAnimation.Halt(); startButtonMaterial.SetTexture("_MainTex", unpressedButtonTexture); sendStartButton.startClue = false; } if (wandPointerAnimation.IsFinished()) { int currRoom = MoveToNextRoom.GetCurrentRoom(); if (obj.tag == "Button" || obj.tag == "SoundEmitter") { obj.GetComponent <ChangeRoomObject> ().Disable(); if (currRoom == 1) { level1ObjectsPassed++; } else if (currRoom == 2) { level2ObjectsPassed++; } else if (currRoom == 3) { level3ObjectsPassed++; } } bool room0Passed = currRoom == 0; bool room1Passed = currRoom == 1 && level1ObjectsPassed == level1ObjectsTotal; bool room2Passed = currRoom == 2 && level2ObjectsPassed == level2ObjectsTotal; bool room3Passed = currRoom == 3 && level3ObjectsPassed == level3ObjectsTotal; if (room0Passed || room1Passed || room2Passed || room3Passed) { ContinueToNextRoom(); } } } }
void Update() { if (executing) { camSpeed += cameraAcceleration; if (camSpeed > maxSpeed) { camSpeed = maxSpeed; } rotY += camSpeed; if (shakingUp) { rotX += shakeFactor; } else { rotX -= shakeFactor; } if (shakingUp && rotX >= maxShakeHeight) { rotX = maxShakeHeight; shakingUp = false; } else if (!shakingUp && rotX <= -maxShakeHeight) { rotX = -maxShakeHeight; shakingUp = true; } cam.transform.eulerAngles = new Vector3(rotX, rotY, 0); if (winAnimation.GetTimePassed() >= winAnimation.durationInSeconds - fadeAnimation.durationInSeconds / 2 && !fadeRunning) { //fadeAnimationLeft.Begin(); //fadeAnimationRight.Begin(); //fadeAnimationFront.Begin(); //fadeAnimationBack.Begin(); fadeAnimation.Begin(); fadeRunning = true; } currentTime += Time.deltaTime; if (currentTime >= timeBetweenBlinks) { canvas.enabled = !canvas.enabled; currentTime = 0; } TimeUpdater.running = false; if (winAnimation.IsFinished()) { winAnimation.Halt(); executing = false; canvas.enabled = true; RayCastController.level1ObjectsPassed = 0; RayCastController.level2ObjectsPassed = 0; RayCastController.level3ObjectsPassed = 0; titleAnimation.Halt(); titleAnimation.Begin(); MoveToNextRoom.MoveToMainRoom(); TimeUpdater.ResetCounter(); //SceneManager.LoadScene (SceneManager.GetActiveScene ().name); for (int i = 0; i < disabledRoomObjects.Length; i++) { disabledRoomObjects [i].Enable(); } soundEmitter1.startClue = false; soundEmitter2.startClue = false; } } sendEarthquake.GetComponent <SendCueLocation> ().startClue = executing; }
/// <summary> /// /// </summary> void Update() { if (GameState.isDead) { SetAnimation(); if (AnimationDead.IsFinished()) { GameObject.Find("GameOverUI").gameObject.GetComponent <GameOver>().Show(); } return; } //Wait until the first tile has been placed and the game begins if (!firstTileSet) { tileDestination = startTile?.GetRandomNextTile(startTile); if (tileDestination != null) { firstTileSet = true; tileDestination.CanRotate = false; spawn = false; } else { SetAnimation(); return; } } _currentSpeed = (Speed + SpeedMax * (FearLevel / FearLevelMax)) * Time.deltaTime; Vector3 targetPos = tileDestination.transform.position; targetPos.z = transform.position.z; // move to next tile if ((targetPos - transform.position).magnitude < 0.01f) { transform.position = targetPos; if (tileDestination.isGoal) { winLevel(); return; } tileDestination.AddModifiers(this); DropTile nextStartTile = tileDestination; tileDestination = tileDestination.GetRandomNextTile(startTile); //There is no next tile if (tileDestination == null) { Die(); return; } startTile = nextStartTile; nextStartTile.CanRotate = false; } else { this.gameObject.transform.position = Vector3.MoveTowards(transform.position, targetPos, _currentSpeed); } SetAnimation(); if (this.FearLevel >= this.FearLevelMax) { //TODO: Was soll passieren, wenn FearLevel voll ist?? } }