Пример #1
0
    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();
        }
    }
Пример #2
0
    public void character_loaded()
    {
        //this means we are start/restarting the game
        if (NGM.CurrentCharacterLoader.Character == CharacterIndex.sFetus)
        {
            reset_stats_and_difficulties();
        }

        //reveal the character with sound
        mManager.mMusicManager.play_sound_effect("transitionOut");
        slide_image(mFlatCamera, mSunsetImage, null, false);

        //we use the hack version instead that allows us to skip characters
        set_last_performance_stat_to_character(NGM.CurrentCharacterIndex);

        //mPerformanceStats.Add(new PerformanceStats(NGM.CurrentCharacterIndex));
        //CurrentPerformanceStat.Stats = NGM.CharacterHelper.Characters[NGM.CurrentCharacterIndex];

        mInterfaceManager.begin_new_character(CurrentPerformanceStat);
        //set particle color
        mParticles.mParticles.set_emitter_particle_color(mManager.mCharacterBundleManager.get_character_stat(NGM.CurrentCharacterIndex).CharacterInfo.CharacterOutlineColor / 2f, 2);
        if (NGM.CurrentCharacterLoader.Character != CharacterIndex.sFetus)
        {
            mGiftManager.add_character(NGM.CurrentCharacterLoader.Character);
        }
        switch (NGM.CurrentCharacterLoader.Name)
        {
        case "0-1":
            set_time_for_PLAY(999999f);
            setup_next_poses(true);
            transition_to_PLAY();
            float gTextDisplayDur = 4;
            NGM.CurrentTargetPose = null;

            System.Action transPose = delegate()
            {
                NGM.CurrentTargetPose = mManager.mReferences.mCheapPose.to_pose();
                mManager.mTransparentBodyManager.set_target_pose(NGM.CurrentTargetPose);
                mManager.mTransparentBodyManager.transition_character_in(mManager.mCharacterBundleManager.get_character_stat(NGM.CurrentCharacterIndex).CharacterInfo.CharacterOutlineColor);
            };

            if (mManager.mMetaManager.UnlockManager.mUnlocked.numberGamesPlayed == 0 || GameConstants.TUTORIAL_ONCE != true)
            {
                TED.add_event(
                    mInterfaceManager.skippable_text_bubble_event(GameStrings.GetString("MNPfetus1"), gTextDisplayDur),
                    3).then_one_shot(
                    transPose,
                    0).then(
                    mInterfaceManager.skippable_text_bubble_event(GameStrings.GetString("MNPfetus2"), gTextDisplayDur),
                    1.5f);
            }
            else
            {
                TED.add_one_shot_event(transPose, 2);
            }

            break;

        case "110":
            set_time_for_PLAY(GameConstants.playAstronautPlayTime); //astronaut scene is shorter
            setup_next_poses(true);                                 //astronaut scene has no transparent pose
            mAstronaut.start_astro();
            mManager.mBackgroundManager.hide_bg_and_fg_elements(true);
            mInterfaceManager.hide_interface();
            transition_to_PLAY();
            TED.add_event(
                mInterfaceManager.skippable_text_bubble_event(GameStrings.GetString("MNPfetus3"), 4),
                1);
            CurrentPerformanceStat.update_score(0, 1);     //give astronaut perfect score
            CurrentPerformanceStat.update_score(1, 1);
            break;

        default:
            set_time_for_PLAY(GameConstants.playDefaultPlayTime);
            setup_next_poses(false);
            transition_to_PLAY();
            break;
        }
    }