Client LuaCsForBarotrauma
CampaignEndScreen.cs
1 using Barotrauma.Media;
2 using Microsoft.Xna.Framework;
3 using Microsoft.Xna.Framework.Graphics;
4 using System;
5 
6 namespace Barotrauma
7 {
9  {
10  private readonly CreditsPlayer creditsPlayer;
11 
12  private readonly Camera cam;
13 
14  public Action OnFinished;
15 
17 
19  {
20  creditsPlayer = new CreditsPlayer(new RectTransform(Vector2.One, Frame.RectTransform), "Content/Texts/Credits.xml")
21  {
22  AutoRestart = false,
23  ScrollBarEnabled = false,
24  AllowMouseWheelScroll = false
25  };
26  creditsPlayer.CloseButton.OnClicked = (btn, userdata) =>
27  {
28  creditsPlayer.Scroll = 1.0f;
29  return true;
30  };
31 
32  cam = new Camera();
33  }
34 
35  public override void Select()
36  {
37  base.Select();
38  if (SlideshowPrefab.Prefabs.TryGet("campaignending".ToIdentifier(), out var slideshow))
39  {
41  }
42  creditsPlayer.Restart();
43  creditsPlayer.Visible = false;
44  UnlockAchievement("campaigncompleted");
45  UnlockAchievement(
46  GameMain.GameSession is { Campaign.Settings.RadiationEnabled: true } ?
47  "campaigncompleted_radiationenabled" :
48  "campaigncompleted_radiationdisabled");
49 
50  static void UnlockAchievement(string id)
51  {
52  AchievementManager.UnlockAchievement(id.ToIdentifier(), unlockClients: true);
53  }
54  }
55 
56  public override void Deselect()
57  {
58  GUI.HideCursor = false;
59  SoundPlayer.OverrideMusicType = Identifier.Empty;
60  }
61 
62  public override void Update(double deltaTime)
63  {
64  slideshowPlayer?.UpdateManually((float)deltaTime);
65  if (creditsPlayer.Finished)
66  {
67  OnFinished?.Invoke();
68  SoundPlayer.OverrideMusicType = Identifier.Empty;
69  }
70  }
71 
72  public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
73  {
74  spriteBatch.Begin(SpriteSortMode.Deferred, null, GUI.SamplerState, null, GameMain.ScissorTestEnable);
75  graphics.Clear(Color.Black);
76  SoundPlayer.OverrideMusicType = "ending".ToIdentifier();
78  {
79  slideshowPlayer.DrawManually(spriteBatch);
80  }
81  else
82  {
83  GUI.HideCursor = false;
84  creditsPlayer.Visible = true;
85  }
86  GUI.Draw(cam, spriteBatch);
87  spriteBatch.End();
88  }
89  }
90 }
override void Update(double deltaTime)
override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
readonly GUIButton CloseButton
OnClickedHandler OnClicked
Definition: GUIButton.cs:16
static GUICanvas Instance
Definition: GUICanvas.cs:15
void UpdateManually(float deltaTime, bool alsoChildren=false, bool recursive=true)
By default, all the gui elements are updated automatically in the same order they appear on the updat...
virtual void DrawManually(SpriteBatch spriteBatch, bool alsoChildren=false, bool recursive=true)
By default, all the gui elements are drawn automatically in the same order they appear on the update ...
RectTransform RectTransform
static GameSession?? GameSession
Definition: GameMain.cs:88
static RasterizerState ScissorTestEnable
Definition: GameMain.cs:195
static readonly PrefabCollection< SlideshowPrefab > Prefabs