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; }
public void popup_character(CharacterIndex[] aChars, int[] aDiffs, int[] aOldDiffs, bool isGreen) { int count = aChars.Length; float gTimeBeforeBadges = .7f; float scaleTime = Mathf.Sqrt(Mathf.Sqrt(1 / (float)count)); float gBadgeTime = scaleTime * .3f; float gTimeAfterBadges = 1.0f; FlatElementImage[] mCharacters = null; FlatElementImage[] mBadges = null; FlatElementImage[] mBackgrounds = null; FlatElementText[] mNames = null; mCharacters = new FlatElementImage[count]; mBadges = new FlatElementImage[count]; mBackgrounds = new FlatElementImage[count]; mNames = new FlatElementText[count]; //var sizeImg = ManagerManager.Manager.mCharacterBundleManager.get_image("ICON_05-1"); //TODO read from sizeImg float gIconHeight = 343; //float gIconWidth = 266; Vector3 step = new Vector3(-500, 0, 0); Vector3 start = NIM.mFlatCamera.get_point(0, -1) - new Vector3(0, gIconHeight / 2, 0); Vector3 offset = (count - 1) * (-step) / 2f; Vector3 badgeOffset = new Vector3(-150, 165, 0); Vector3 nameOffset = new Vector3(0, -180, 0); CharacterBundleManager.ImageSizePair[] badgeImages = new CharacterBundleManager.ImageSizePair[] { ManagerManager.Manager.mCharacterBundleManager.get_image("label_easy"), ManagerManager.Manager.mCharacterBundleManager.get_image("label_normal"), ManagerManager.Manager.mCharacterBundleManager.get_image("label_hard"), ManagerManager.Manager.mCharacterBundleManager.get_image("label_extreme") }; var chain = TED.add_event( delegate(float aTime) { for (int i = 0; i < count; i++) { //TODO delete all the fallback stuff CharacterBundleManager.ImageSizePair img = null; img = ManagerManager.Manager.mCharacterBundleManager.get_image("ICON_" + aChars[i].StringIdentifier); if (img == null || img.Data == null || img.Image == null) { img = ManagerManager.Manager.mCharacterBundleManager.get_image("ANGELS_" + aChars[i].StringIdentifier); } if (img == null || img.Data == null || img.Image == null) { mCharacters[i] = new FlatElementImage(null, 10); } else { mCharacters[i] = new FlatElementImage(img.Image, img.Data.Size, 10); } mCharacters[i].HardPosition = start + offset + step * i; mCharacters[i].SoftPosition = mCharacters[i].SoftPosition + new Vector3(0, gIconHeight + 43, 0); mCharacters[i].HardScale = Vector3.one * 0.8f; mBadges[i] = new FlatElementImage(badgeImages[aOldDiffs[i]].Image, badgeImages[aOldDiffs[i]].Data.Size, 11); //mBadges[i].HardColor = GameConstants.UiWhiteTransparent; mBadges[i].HardColor = GameConstants.UiWhite; mBadges[i].HardPosition = mCharacters[i].HardPosition + badgeOffset; mBadges[i].SoftPosition = mCharacters[i].SoftPosition + badgeOffset; mBadges[i].HardScale = Vector3.one * 0.9f; var boxImage = ManagerManager.Manager.mCharacterBundleManager.get_image("CUTSCENE_BOX"); FlatElementImage box = new FlatElementImage(boxImage.Image, boxImage.Data.Size, 3); box.HardPosition = mCharacters[i].HardPosition; box.SoftPosition = mCharacters[i].SoftPosition; box.HardColor = isGreen ? GameConstants.UiYellowTransparent : GameConstants.UiRedTransparent; box.HardColor = isGreen ? GameConstants.UiYellow : GameConstants.UiRed; mBackgrounds[i] = box; var text = ManagerManager.Manager.mGameManager.CharacterHelper.Characters[aChars[i]].CharacterInfo.ShortName.ToUpper(); mNames[i] = new FlatElementText( ManagerManager.Manager.mNewRef.genericFont, text.Length > 10 ? 42 : 57, text, 11); mNames[i].HardPosition = mCharacters[i].HardPosition + nameOffset; mNames[i].SoftPosition = mCharacters[i].SoftPosition + nameOffset; mNames[i].HardColor = (!isGreen) ? GameConstants.UiWhite : GameConstants.UiRed; //set speeds.. mCharacters[i].PositionInterpolationMinLimit = 250; mCharacters[i].SoftInterpolation = 0.15f; mBadges[i].PositionInterpolationMinLimit = 250; mBadges[i].SoftInterpolation = 0.15f; mNames[i].PositionInterpolationMinLimit = 250; mNames[i].SoftInterpolation = 0.15f; mBackgrounds[i].PositionInterpolationMinLimit = 250; mBackgrounds[i].SoftInterpolation = 0.15f; mElement.Add(mCharacters[i]); mElement.Add(mBadges[i]); mElement.Add(mBackgrounds[i]); mElement.Add(mNames[i]); create_shine_over_character(mCharacters[i], isGreen, gBadgeTime * (count) + gTimeAfterBadges + 0.5f); } return(true); }, gTimeBeforeBadges); chain = chain.wait(0.5f); for (int j = 0; j < count; j++) { int workingIndex = j; chain = chain.then_one_shot( delegate() { //TODO DELETE //mBadges[workingIndex].destroy(); //Vector3 pos = mBadges[workingIndex].HardPosition; //mBadges[workingIndex] = new FlatElementImage(badgeImages[aDiffs[workingIndex]].Image,badgeImages[aDiffs[workingIndex]].Data.Size,11); //mBadges[workingIndex].HardPosition = pos; //mElement.Add(mBadges[workingIndex]); mBadges[workingIndex].set_new_texture(badgeImages[aDiffs[workingIndex]].Image, badgeImages[aDiffs[workingIndex]].Data.Size); //pulsating scale animation mBadges[workingIndex].Events.add_event( delegate(FlatElementBase aBase, float aTime) { aBase.mLocalScale = Vector3.one * (1 + Mathf.Sin(aTime * 12) * 0.3f); if (aTime > 0.225f) { return(true); } return(false); }, 0); /* * mCharacters[workingIndex].Events.add_event( * delegate(FlatElementBase aBase, float aTime) * { * aBase.mLocalScale = Vector3.one * (1+Mathf.Sin(aTime*6)*0.1f); * if(aTime > 0.3f) * return true; * return false; * }, * 0);*/ //play a sound if (isGreen) { ManagerManager.Manager.mMusicManager.play_sound_effect("headPopupGood"); } else { ManagerManager.Manager.mMusicManager.play_sound_effect("headPopupBad"); } }, gBadgeTime); } chain = chain.then_one_shot( delegate() { for (int i = 0; i < count; i++) { int index = i; //mBadges[i].SoftColor = GameConstants.UiWhiteTransparent; mCharacters[i].SoftPosition = start + offset + step * i + new Vector3(0, -200, 0); //move down a little more to compensate for scale change mNames[i].SoftPosition = mCharacters[i].SoftPosition + nameOffset; mBackgrounds[i].SoftPosition = mCharacters[i].SoftPosition; mBadges[i].SoftPosition = mCharacters[i].SoftPosition + badgeOffset; mBadges[i].SoftColor = GameConstants.UiWhiteTransparent; //destroy them eventually. TED.add_one_shot_event( delegate() { mElement.Remove(mCharacters[index]); mElement.Remove(mBadges[index]); mElement.Remove(mBackgrounds[index]); mElement.Remove(mNames[index]); mBadges[index].destroy(); mCharacters[index].destroy(); mBackgrounds[index].destroy(); mNames[index].destroy(); }, 3); } }, gTimeAfterBadges); }
//TEXT public PopupTextObject add_timed_text_bubble(string aMsg, float duration, float yRelOffset = 0, CharacterBundleManager.ImageSizePair image = null) { PopupTextObject to = null; if (image == null) { to = new PopupTextObject(aMsg, 30); } else { to = new PopupTextObject(aMsg, 30, image.Image, image.Data.Size); } to.HardPosition = mFlatCamera.get_random_point_off_camera(-2300); to.HardColor = GameConstants.UiWhiteTransparent; to.SoftColor = GameConstants.UiWhite; to.set_text_color(GameConstants.UiRedTransparent, true); to.set_text_color(GameConstants.UiRed); to.set_background_color(GameConstants.UiWhiteTransparent, true); to.set_background_color(GameConstants.UiPopupBubble); TED.add_event( delegate(float aTime) { to.SoftPosition = mFlatCamera.get_point(0, yRelOffset); //fly in //to.HardPosition = mFlatCamera.get_point(0.40f,yRelOffset); //cut in mElement.Add(to); return(true); }, 0.1f).then( //bleah, hacky delay delegate(float aTime) { if (aTime > duration) { return(true); } if (mModeNormalPlay.DoSkipSingleThisFrame) { mModeNormalPlay.DoSkipSingleThisFrame = false; return(true); } return(false); }, 0).then_one_shot( delegate() { //cutout //mElement.Remove(to); //to.destroy(); //fadeout to.fade_out(); }, 0).then_one_shot( delegate() { //fadeout mElement.Remove(to); to.destroy(); }, 2); return(to); }