void OnTriggerEnter(Collider other) { if (other.tag == "Player") { soundEffectManager.playMentalityPotionSound(); if (!mentality) { mentality = other.GetComponent <Mentality>(); } mentality.gain(mentalityGain); Vector3 randomEventPosition = maze.getNewEventPosition(transform.position); transform.position = randomEventPosition; } }
void Update() { if (GameState.state != GameState.PLAYING) { return; } if (Input.GetKeyDown(KeyCode.Keypad1) || Input.GetKeyDown(KeyCode.Alpha1)) { if (vitality.enough(vitalityCost)) { soundEffectManager.playRoarSound(); vitality.use(vitalityCost); mentality.gain(mentalityGain); } else { // soundEffectManager.playErrorSound(); // MessageViewer.showErrorMessage("Not enough vitality"); } } }
void Update() { if (GameState.state != GameState.PLAYING) { return; } if (GameMode.mode == GameMode.ESCAPING) { if (EscapingState.state == EscapingState.BEGINNING || EscapingState.state == EscapingState.EXIT_FOUND) { if (npcState.state != NPCState.STUNNING) { turnToStunningState(); } } if (!isInsane) { closingEyesChecking(); } } if (npcState.state == NPCState.STUNNING) { stunnedTime += Time.deltaTime; if (stunnedTime >= stunningTime) { npcState.state = NPCState.MAKING_DECISION; for (int i = 0; i < childrenRenderers.Length; i++) { float r = childrenRenderers[i].material.color.r; float g = childrenRenderers[i].material.color.g; float b = childrenRenderers[i].material.color.b; float a = 1; childrenRenderers[i].material.color = new Color(r, g, b, a); } collider.enabled = true; } return; } if (isCameraMoving) { cameraMovedTime += Time.deltaTime; player.transform.rotation = Quaternion.Slerp(player.transform.rotation, cameraQuaternion, Time.deltaTime / cameraMovingTime); if (cameraMovedTime >= cameraMovingTime) { StartCoroutine(cameraShaker.shakeCamera()); // soundEffectManager.playZombieGaspSound(); isCameraMoving = false; player.transform.LookAt(lookAtPoint.transform); fakeBossTextureIndex = random.Next(fakeBossTextures.Length); for (int i = 0; i < childrenRenderers.Length; i++) { float r = childrenRenderers[i].material.color.r; float g = childrenRenderers[i].material.color.g; float b = childrenRenderers[i].material.color.b; float a = 0; childrenRenderers[i].material.color = new Color(r, g, b, a); } } return; } if (isMoving) { // Do nothing when boss is moving return; } if (npcState.state == NPCState.STARING) { if (lookAtAndCheckIfSeenPlayer()) { if (isVisible()) { turnToTracingState(); return; } return; } else { npcState.state = NPCState.MAKING_DECISION; } return; } if (npcState.state == NPCState.TRACING) { if (!lookAtAndCheckIfSeenPlayer()) { audio.Stop(); npcState.state = NPCState.MAKING_DECISION; return; } if (playerIsInTheRadius(attackingRadius)) { turnToAttackingState(); return; } else if (playerIsInTheRadius(staringTriggerRadius)) { if (isVisible()) { // Restore the mentality of the player playerMentality.gain(mentalityRestorePerSecond * Time.deltaTime); } } path = maze.getSimpleShortestPath(transform.position, player.transform.position); if (path.Count > 0) { // Do the first moving instruction StartCoroutine(move(path[0])); } return; } if (npcState.state == NPCState.ATTACKING) { QTEShowedTime += Time.deltaTime; if (QTEShowedTime >= QTESwitchTime) { QTEShowedTime = 0; QTEsmall = !QTEsmall; } maskAlpha = ((int)(Time.time * 100) % 100) / 100.0f; // Absorb the mentality of the player playerMentality.use(mentalityAbsorbPerSecond * Time.deltaTime); bool wrong = false; bool success = false; QTETimeUsed += Time.deltaTime; if (QTETimeUsed >= QTETimeLimit) { wrong = true; } KeyCode[] secondHotkeys = new KeyCode[4]; secondHotkeys[0] = KeyCode.W; secondHotkeys[1] = KeyCode.S; secondHotkeys[2] = KeyCode.D; secondHotkeys[3] = KeyCode.A; for (int direction = 0; direction < 4 && !wrong; direction++) { if (Input.GetKeyDown(KeyCode.UpArrow + direction) || Input.GetKeyDown(secondHotkeys[direction])) { if (QTEvent[0] == direction) { soundEffectManager.playQTEHitSound(); success = true; } else { // soundEffectManager.playQTEMissSound(); wrong = true; } } } if (wrong) { StartCoroutine(shakeFakeBoss()); StartCoroutine(cameraShaker.shakeCamera()); bloodSplatter.addBlood(-1, 2.5f); perfectQTE = false; playerMentality.use(mentalityAbsorbPerQTEWrong); QTEvent = generateQTE(QTELength); QTETimeUsed = 0; } if (success) { StartCoroutine(shakeFakeBoss()); StartCoroutine(cameraShaker.shakeCamera()); QTEvent.RemoveAt(0); if (QTEvent.Count == 0) { bloodSplatter.addBlood(5, 5.0f); turnToStunningState(); float bonusScale = 1 - (QTETimeUsed / QTETimeLimit) + (perfectQTE ? 1 : 0); scoreboard.addScore((int)(250 * (QTELength * (1 + bonusScale)))); if (isInsane) { addQTELength(insaneAdditionalQTELength); addQTEWrongMentality(insaneAdditionalMentalityAbsorbPerQTEWrong); addQTETimeLimit(insaneAdditionalQTETimeLimitPerKey); } } else { if (random.Next(5) == 0) { bloodSplatter.addBlood(1, 0.2f, 0.05f); } } } return; } if (lookAtAndCheckIfSeenPlayer()) { turnToStaringState(); return; } if (npcState.state == NPCState.WANDERING) { if (pathIndex >= path.Count) // Finish { npcState.state = NPCState.MAKING_DECISION; return; } // Do the next moving instruction StartCoroutine(move(path[pathIndex++])); } if (npcState.state == NPCState.CHASING) { path = maze.getSimpleShortestPath(transform.position, player.transform.position); if (path.Count > 0) { // Do the first moving instruction StartCoroutine(move(path[0])); } else { npcState.state = NPCState.MAKING_DECISION; return; } } if (npcState.state == NPCState.MAKING_DECISION) { makeDecision(); } }