public void update_PLAY() { TimeRemaining -= KeyMan.GetKey("Fast") ? Time.deltaTime * 5 : Time.deltaTime; if (NGM.CurrentPose != null) //this should never happen but just in case { if (KeyMan.GetKey("Perfect")) { mManager.mBodyManager.set_target_pose(NGM.CurrentTargetPose); } else { mManager.mBodyManager.set_target_pose(NGM.CurrentPose); } } //this basically means we aren't 0 or 100 or 999 if (NGM.CurrentPoseAnimation != null && NGM.CurrentCharacterIndex.LevelIndex != 0) { NGM.CurrentTargetPose = NGM.CurrentPoseAnimation.get_pose(Time.time); mManager.mTransparentBodyManager.set_target_pose(NGM.CurrentTargetPose); mGrading.update(mManager.mBodyManager.get_current_pose(), mManager.mTransparentBodyManager.get_current_pose()); float grade = ProGrading.grade_pose(mManager.mBodyManager.get_current_pose(), mManager.mTransparentBodyManager.get_current_pose()); grade = ProGrading.grade_to_perfect(grade); //old smooth grading /* * float newGrade = mLastGrade*0.95f + grade*0.05f; * if(newGrade < mLastGrade) * mLastGrade = Mathf.Max(newGrade,mLastGrade - Time.deltaTime/6f); * else mLastGrade = newGrade; * grade = mLastGrade;*/ //new smooth grading, this version gives grace to sudden drops in performance if (grade < mLastGrade) { float newGrade = mLastGrade * 0.95f + grade * 0.05f; if (newGrade < mLastGrade) { grade = Mathf.Max(newGrade, mLastGrade - Time.deltaTime / 2f); } else { grade = newGrade; } } mLastGrade = grade; bool switchEffect = false; if (PercentTimeCompletion > 0.01f) { mParticles.create_particles(mGrading, true); if (GameConstants.NEW_POSE_SWITCHING) { //TODO test if switch conditions are right //TODO switch } else { if (NGM.CurrentPoseAnimation.does_pose_change_precoginitive(Time.time, Time.deltaTime, 0.07f)) { switchEffect = true; //TODO give 1 second of bonus score for being close right when pose switches } } } if (TimeRemaining > 0) //insurance, something funny could happen if music runs slightly longer than it should. { CurrentPerformanceStat.update_score(PercentTimeCompletion, grade); } //TODO needs to be tested //improve score for good switches if (switchEffect) { CurrentPerformanceStat.adjust_score(PercentTimeCompletion, grade * GameConstants.switchBonusScoreMultiplier, NGM.CurrentPoseAnimation.ChangeTime); } //trigger effects after adjusting score if (switchEffect) { mGiftManager.capture_player(); mParticles.create_particles(mGrading); if (grade > GameConstants.playSuperCutoff && IsFever) { mManager.mMusicManager.play_sound_effect("pose5", 0.6f); } else { mManager.mMusicManager.play_sound_effect("pose" + Mathf.Clamp((int)(5 * grade), 0, 4), 0.8f); } } //mManager.mCameraManager.set_camera_effects(grade); //update score mInterfaceManager.update_bb_score(TotalScore); } else if (NGM.CurrentCharacterIndex.LevelIndex == 0 && true) //fetus { if (NGM.CurrentTargetPose != null) { mManager.mTransparentBodyManager.set_target_pose(NGM.CurrentTargetPose); float grade = ProGrading.grade_pose(mManager.mBodyManager.get_current_pose(), NGM.CurrentTargetPose); //should be mManager.mTransparentBodyManager.get_current_pose() but it does not matter grade = ProGrading.grade_to_perfect(grade); //this is a total hack, but we don't use mTotalScore for the fetus anyways FieldInfo scoreProp = typeof(PerformanceStats).GetField("mTotalScore", BindingFlags.NonPublic | BindingFlags.Instance); float oldGrade = (float)scoreProp.GetValue(CurrentPerformanceStat); float newGrade = oldGrade * 0.93f + grade * 0.07f; scoreProp.SetValue(CurrentPerformanceStat, newGrade); if (newGrade > GameConstants.playFetusPassThreshold) { //this may or may not work depending on which update gets called first SkipSingle(); scoreProp.SetValue(CurrentPerformanceStat, 0); mManager.mMusicManager.play_sound_effect("cutGood"); TimeRemaining = 0; } } } else if (NGM.CurrentCharacterIndex == CharacterIndex.sOneHundred) { mAstronaut.update_astro(); } else { CurrentPerformanceStat.update_score(PercentTimeCompletion, 0.5f); } //warning if (NGM.CurrentPoseAnimation != null && NGM.CurrentCharacterIndex.LevelIndex != 0) { float perc = 3f / GameConstants.playDefaultPlayTime; if (PercentTimeCompletion > GameConstants.warningMinTime && CurrentPerformanceStat.last_score(perc) / (perc) < 0.2f) { mInterfaceManager.enable_warning_text(true); } else { mInterfaceManager.enable_warning_text(false); } } //make sure music is finished too! //if((TimeRemaining <= 0 && !mManager.mMusicManager.IsMusicSourcePlaying) || TimeRemaining < -4) //but don't wait too long if (TimeRemaining <= 0) { CurrentPerformanceStat.Finished = true; mInterfaceManager.enable_warning_text(false); transition_to_CUTSCENE(); //if we don't want fetus to have a cutscene use this //if(CurrentPerformanceStat.Character.Index != 0) // transition_to_CUTSCENE(); //else transition_to_CHOICE(); //handle astronaut //note maybe we want to use physics for cutscene as well in which case we should move this into transition_to_CUTSCENE if (NGM.CurrentCharacterIndex == CharacterIndex.sOneHundred) { mAstronaut.finish_astro(); } return; } //if we don't want the music to play during the cutscenes and whatont... //if(GS != NormalPlayGameState.PLAY) // mManager.mMusicManager.fade_out(); //early death bool die = false; die |= KeyMan.GetKeyDown("Die"); //if (NGM.CurrentPoseAnimation != null && mManager.mZigManager.has_user() && NGM.CurrentCharacterIndex.LevelIndex != 0) if (NGM.CurrentPoseAnimation != null && mManager.mZigManager.is_reader_connected() == 2 && NGM.CurrentCharacterIndex.LevelIndex != 0) { if (PercentTimeCompletion > GameConstants.deathMinTime) { float perc = GameConstants.deathRequiredTime / GameConstants.playDefaultPlayTime; if (CurrentPerformanceStat.last_score(perc) / perc < GameConstants.deathPerformanceThreshold) { die |= true; } } } float perc2 = GameConstants.deathRequiredTime / GameConstants.playDefaultPlayTime; //ManagerManager.Manager.mDebugString = CurrentPerformanceStat.last_score(perc2).ToString("#.##") + " " + (CurrentPerformanceStat.last_score(perc2) / perc2).ToString("#.##") + " " + (PercentTimeCompletion).ToString("#.##"); if (die && NGM.CurrentCharacterIndex != CharacterIndex.sOneHundred) //can't die as astronaut, even if we want to { if (NGM.CurrentCharacterIndex != CharacterIndex.sFetus) //this only happens if we try and force die on fetus { mGiftManager.capture_player(); } CurrentPerformanceStat.Finished = true; mInterfaceManager.enable_warning_text(false); transition_to_DEATH(); } }