Exemple #1
0
    public void transition_to_CUTSCENE()
    {
        GS = NormalPlayGameState.CUTSCENE;
        NUPD.ChangeSet changes = CurrentPerformanceStat.CutsceneChangeSet;

        load_CUTSCENE(changes);

        mInterfaceManager.set_for_CUTSCENE(
            delegate(){ CUTSCENE_finished(changes); },
            changes,
            space_camp_final_exam()
            );
    }
Exemple #2
0
 public void CUTSCENE_finished(NUPD.ChangeSet changes = null)
 {
     TED.add_one_shot_event(
         delegate()
     {
         mManager.mMusicManager.fade_out(3);     //fadeout whataver is playing, either the cutscene music or the character music (which plays after cutscene music finishes
         //apply all the diff changes again (in case we skipped and tehy werent applied duringcutscene)
         if (changes != null)
         {
             foreach (var e in changes.Changes)
             {
                 CharIndexContainerInt diffChanges = e.Changes;
                 //string changeMsg = e.Description;
                 foreach (CharacterIndex cchar in CharacterIndex.sAllCharacters)
                 {
                     if (diffChanges[cchar] != 0)
                     {
                         mManager.mGameManager.change_character_difficulty(cchar, diffChanges[cchar]);
                     }
                 }
             }
         }
     }
         , 0).then_one_shot(
         delegate()
     {
         if (CurrentPerformanceStat.Character.LevelIndex > 6)                    //if natural death :)
         {
             if (space_camp_final_exam())
             {
                 transition_to_ASTRONAUT();
             }
             else
             {
                 //natural death
                 mInterfaceManager.set_for_DEATH(CurrentPerformanceStat.Character)
                 .then_one_shot(
                     delegate()
                 {
                     transition_to_TRANSITION_play(new CharacterIndex("999"));
                 }
                     , 0);
             }
         }
         else
         {
             transition_to_CHOICE();
         }
     }
         , GameConstants.transitionToChoiceDelayTime);
 }
Exemple #3
0
    //this function updates music and background and removes characters
    //pass in CurrentPerformanceStat.CutsceneChangeSet;
    public void load_CUTSCENE(NUPD.ChangeSet changes)
    {
        int changeIndex = -1;

        if (changes == null)
        {
            Debug.Log("could not find change in threshold with performance: " + CurrentPerformanceStat);
            changes = new NUPD.ChangeSet();
            changes.Changes.Add(new NUPD.ChangeSubSet()
            {
                Description = "No changes available!!"
            });
        }
        else
        {
            changeIndex = changes.Index;
        }

        //audio
        //TODO change index is no longe relevant
        if (changeIndex != -1)
        {
            //if(CurrentCharacterLoader.Images.cutsceneMusic.Count > changeIndex)
            if (NGM.CurrentCharacterLoader.Images.cutsceneMusic.Count > 1)
            {
                if (NGM.CurrentCharacterIndex != CharacterIndex.sOneHundred)
                {
                    mManager.mMusicManager.play_sound_effect(CurrentPerformanceStat.BadPerformance ? "cutBad" : "cutGood");
                }
                AudioClip cutsceneClip = NGM.CurrentCharacterLoader.Images.cutsceneMusic[CurrentPerformanceStat.BadPerformance ? 0 : 1];
                mManager.mMusicManager.play_cutscene_music(cutsceneClip);
                //mManager.mMusicManager.fade_in_cutscene_music(CurrentCharacterLoader.Images.cutsceneMusic[changes.UpperThreshold <= 0.5 ? 0 : 1]);

                TED.add_event(
                    delegate(float aTime){
                    if (mManager.mMusicManager.MusicClip == cutsceneClip)
                    {
                        //if we're still in the cutscene and the cutscene music has stopped playing
                        if (!mManager.mMusicManager.IsMusicSourcePlaying && GS == NormalPlayGameState.CUTSCENE)
                        {
                            mManager.mMusicManager.play_music(NGM.CurrentCharacterLoader.Images.backgroundMusic, 0, true);
                            mManager.mMusicManager.fade_in(5, 0.2f);
                            return(true);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                    return(false);
                }
                    , 0);
            }
            else
            {
                //Debug.Log("ERROR no music found for change index " + changeIndex + " only " + CurrentCharacterLoader.Images.cutsceneMusic.Count + " sounds");
                Debug.Log("No cutscene music for " + NGM.CurrentCharacterIndex.StringIdentifier);
            }
        }

        //visuals
        mManager.mBodyManager.transition_character_out();
        mManager.mTransparentBodyManager.transition_character_out();

        if (space_camp_final_exam())
        {
            mManager.mBackgroundManager.hide_bg_and_fg_elements();
        }
        else if (CurrentPerformanceStat.BadPerformance && NGM.CurrentCharacterLoader.has_cutscene(1) && NGM.CurrentCharacterIndex != CharacterIndex.sOneHundred) //if bad performance, has cutscene and is NOT astronaut
        {
            mManager.mBackgroundManager.load_cutscene(1, NGM.CurrentCharacterLoader);
        }
        else
        {
            mManager.mBackgroundManager.load_cutscene(0, NGM.CurrentCharacterLoader);
        }
    }
    public void set_for_CUTSCENE(System.Action cutsceneCompleteCb, NUPD.ChangeSet aChanges, bool aAstronautHack)
    {
        //first we remove all characters from cutscene text that are locked
        List <NUPD.ChangeSubSet> newChanges = new List <NUPD.ChangeSubSet>(aChanges.Changes);

        for (int i = 0; i < aChanges.Changes.Count; i++)
        {
            foreach (CharacterIndex f in CharacterIndex.sAllCharacters)
            {
                if (mManager.mMetaManager.UnlockManager.is_unlocked(f) != 1)
                {
                    newChanges[i].Changes[f] = 0;
                }
            }
        }
        //then we remove text that has no characters assosciated with it
        newChanges = newChanges.Where(e => !e.Changes.is_zero()).ToList();



        //used for skipping cutscene

        /*
         * TED.add_event(
         *      delegate(float aTime)
         *      {
         *              add_timed_text_bubble("CUTSCENE HERE",1);
         *              return true;
         *      },
         * 0).then_one_shot( //dummy
         *      delegate(){cutsceneCompleteCb();},END_CUTSCENE_DELAY_TIME);
         * return;*/

        float gStartCutsceneDelay    = 2.5f;
        float gPerformanceText       = 3.5f;
        float gCutsceneText          = 5f;
        float gCutsceneTextIncrement = .3f;
        float gPreParticle           = 1.5f;
        float gBubblePos             = 0.2f;

        //TODO put in actual random bubbless
        int lastBubbleIndex = Random.Range(0, 3);
        var cutsceneBubbles = new CharacterBundleManager.ImageSizePair[] {
            mManager.mCharacterBundleManager.get_image("CUTSCENE_BUBBLE-0"),
            mManager.mCharacterBundleManager.get_image("CUTSCENE_BUBBLE-1"),
            mManager.mCharacterBundleManager.get_image("CUTSCENE_BUBBLE-2")
        };


        mLastCutsceneCompleteCb = delegate() {
            cutsceneCompleteCb();
            mLastCutsceneCompleteCb = null;
            mLastCutsceneChain      = null;
        };

        //string[] perfectPhrase = {"awful","mediocre","good", "perfect"};
        //string[] performancePhrase = {"horribly","poorly","well", "excellently"};
        PopupTextObject introPo = null;

        TimedEventDistributor.TimedEventChain chain = TED.add_event(
            delegate(float aTime)
        {
            //string text = "";
            if (mModeNormalPlay.CurrentPerformanceStat.Character == CharacterIndex.sFetus)
            {
                //DELETE this has been moved to text files..
                //text = "Prepare to be Born";
            }
            else if (mModeNormalPlay.CurrentPerformanceStat.DeathTime == -1)                    //if we did not die this time
            {
                //TODO use color text here... In fact you should replace color text as yoru standard text object really...
                //text = aChanges.PerformanceDescription.Replace("<P>",perfectPhrase[mBBLastPerformanceGraph.Stats.Perfect]);

                /*string noCapsDescription = mBBLastPerformanceGraph.Character.Description.ToLower();
                 * if(mBBLastPerformanceGraph.Character.IsDescriptionAdjective)
                 *      text = "You lived your life " + noCapsDescription + " " + performancePhrase[(int)Mathf.Clamp(mBBLastPerformanceGraph.Score*4,0,3)] + ".";
                 * else
                 *      text = "You lived your life as a " + noCapsDescription + " " + performancePhrase[(int)Mathf.Clamp(mBBLastPerformanceGraph.Score*4,0,3)] + ".";*/

                //TODO this should be different for age 85 if astronaut
                if (aAstronautHack)
                {
                    introPo = add_timed_text_bubble(GameStrings.GetString("NIM1"), gPerformanceText);
                }
                else
                {
                    introPo = add_timed_text_bubble(aChanges.PerformanceDescription, gPerformanceText);
                }
            }
            return(true);
        },
            gStartCutsceneDelay).then(
            delegate(float aTime)
        {
            if (introPo != null && introPo.IsDestroyed)
            {
                return(true);
            }
            if (!(mModeNormalPlay.CurrentPerformanceStat.Character == CharacterIndex.sFetus))
            {
                if (aTime > gPerformanceText)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        },
            0);


        foreach (var e in newChanges)
        {
            //string changeMsg = Random.Range(0,3) == 0 ? PDStats.negative_sentences[(int)e][0] : PDStats.positive_sentences[(int)e][0];
            var             changes     = e;
            var             diffChanges = e.Changes;
            string          changeMsg   = e.Description;
            PopupTextObject po          = null;

            List <CharacterIndex> aChangedChars = new List <CharacterIndex>();
            List <int>            oldDiffs      = new List <int>();
            List <int>            aDiffs        = new List <int>();
            foreach (CharacterIndex cchar in CharacterIndex.sAllCharacters)
            {
                if (diffChanges[cchar] != 0)
                {
                    aChangedChars.Add(cchar);
                    int nDiff = Mathf.Clamp(mManager.mGameManager.get_character_difficulty(cchar) + diffChanges[cchar], 0, 3);
                    oldDiffs.Add(mManager.mGameManager.get_character_difficulty(cchar));
                    aDiffs.Add(nDiff);
                }
            }

            chain = chain.then(
                delegate(float aTime)
            {
                if (po == null)
                {
                    po = add_timed_text_bubble(
                        changeMsg, gCutsceneText + gCutsceneTextIncrement * aChangedChars.Count,
                        gBubblePos,
                        cutsceneBubbles[lastBubbleIndex]);
                    lastBubbleIndex = (lastBubbleIndex + 1) % 3;

                    //dumb stuff I need to make sure there was actually a change
                    foreach (CharacterIndex cchar in CharacterIndex.sAllCharacters)
                    {
                        if (diffChanges[cchar] != 0)
                        {
                            set_popup_color_for_cutscene_particles(po, changes.is_positive());
                            break;
                        }
                    }
                }
                if (po.IsDestroyed || aTime > gPreParticle)
                {
                    return(true);
                }
                return(false);
            }
                , 0).then(
                delegate(float aTime)
            {
                if (!po.IsDestroyed)
                {
                    mHeadPop.popup_character(aChangedChars.ToArray(), aDiffs.ToArray(), oldDiffs.ToArray(), !changes.is_positive());
                }
                return(true);
            }
                , 0).then(
                delegate(float aTime)
            {
                if (po.IsDestroyed || aTime > gCutsceneText + gCutsceneTextIncrement * aChangedChars.Count - gPreParticle)
                {
                    return(true);
                }
                return(false);
            }
                , 0);
        }

        chain = chain.then_one_shot(delegate(){ mLastCutsceneCompleteCb(); }, END_CUTSCENE_DELAY_TIME);

        //TODO this is a hack fix, need to fix it properly...
        //chain = chain.then_one_shot(delegate() { if(mLastCutsceneCompleteCb != null) mLastCutsceneCompleteCb(); }, END_CUTSCENE_DELAY_TIME);

        mLastCutsceneChain = TED.LastEventKeyAdded;
    }