Advertisement
zjqyf

GLQ_StoryModeTimer.cs

May 12th, 2018
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.17 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using Turbo.Plugins.Default;
  4. namespace Turbo.Plugins.glq
  5. {
  6. public class GLQ_StoryModeTimer : BasePlugin, INewAreaHandler, IInGameTopPainter, IAfterCollectHandler
  7. {
  8. public IFont TotalTimerFont { get; set; }
  9. public IFont A1TimerFont { get; set; }
  10. public IFont A2TimerFont { get; set; }
  11. public IFont A3TimerFont { get; set; }
  12. public IFont A4TimerFont { get; set; }
  13. public IFont A5TimerFont { get; set; }
  14. private IWatch TotalTimeWatch;
  15. private IWatch A1TimeWatch;
  16. private IWatch A2TimeWatch;
  17. private IWatch A3TimeWatch;
  18. private IWatch A4TimeWatch;
  19. private IWatch A5TimeWatch;
  20. private bool _IsStoryMode;
  21. public GLQ_StoryModeTimer()
  22. {
  23. Enabled = true;
  24. }
  25. public override void Load(IController hud)
  26. {
  27. base.Load(hud);
  28. TotalTimerFont = Hud.Render.CreateFont("tahoma", 7.5f, 230, 0, 255, 255, true, false, true);
  29. A1TimerFont = Hud.Render.CreateFont("tahoma", 7.5f, 230, 128, 64, 64, true, false, true);
  30. A2TimerFont = Hud.Render.CreateFont("tahoma", 7.5f, 230, 255, 128, 64, true, false, true);
  31. A3TimerFont = Hud.Render.CreateFont("tahoma", 7.5f, 230, 128, 128, 192, true, false, true);
  32. A4TimerFont = Hud.Render.CreateFont("tahoma", 7.5f, 230, 0, 128, 192, true, false, true);
  33. A5TimerFont = Hud.Render.CreateFont("tahoma", 7.5f, 230, 170, 215, 255, true, false, true);
  34. TotalTimeWatch = Hud.Time.CreateWatch();
  35. A1TimeWatch = Hud.Time.CreateWatch();
  36. A2TimeWatch = Hud.Time.CreateWatch();
  37. A3TimeWatch = Hud.Time.CreateWatch();
  38. A4TimeWatch = Hud.Time.CreateWatch();
  39. A5TimeWatch = Hud.Time.CreateWatch();
  40. }
  41. public void OnNewArea(bool newGame, ISnoArea area)
  42. {
  43. if (newGame)
  44. {
  45. _IsStoryMode = Hud.Game.SpecialArea == SpecialArea.None && !Hud.Game.Bounties.Any();
  46. TotalTimeWatch.Reset();
  47. A1TimeWatch.Reset();
  48. A2TimeWatch.Reset();
  49. A3TimeWatch.Reset();
  50. A4TimeWatch.Reset();
  51. A5TimeWatch.Reset();
  52. }
  53. }
  54. public void PaintTopInGame(ClipState clipState)
  55. {
  56. if (clipState != ClipState.AfterClip) return;
  57. if(!_IsStoryMode) return;
  58. var TotaltextLayout = "TimeElapsed :" + ValueToString((long)TotalTimeWatch.ElapsedMilliseconds * 10000, ValueFormat.LongTime);
  59. var A1textLayout = "A1Elapsed:" + ValueToString((long)A1TimeWatch.ElapsedMilliseconds * 10000, ValueFormat.LongTime);
  60. var A2textLayout = "A2Elapsed:" + ValueToString((long)A2TimeWatch.ElapsedMilliseconds * 10000, ValueFormat.LongTime);
  61. var A3textLayout = "A3Elapsed:" + ValueToString((long)A3TimeWatch.ElapsedMilliseconds * 10000, ValueFormat.LongTime);
  62. var A4textLayout = "A4Elapsed:" + ValueToString((long)A4TimeWatch.ElapsedMilliseconds * 10000, ValueFormat.LongTime);
  63. var A5textLayout = "A5Elapsed:" + ValueToString((long)A5TimeWatch.ElapsedMilliseconds * 10000, ValueFormat.LongTime);
  64. var x = Hud.Window.Size.Width / 1.18f;
  65. var y = Hud.Window.Size.Height / 1.15f;
  66. TotalTimerFont.DrawText(TotaltextLayout, x, y);
  67. A1TimerFont.DrawText(A1textLayout, x, y + 20);
  68. A2TimerFont.DrawText(A2textLayout, x, y + 40);
  69. A3TimerFont.DrawText(A3textLayout, x, y + 60);
  70. A4TimerFont.DrawText(A4textLayout, x, y + 80);
  71. A5TimerFont.DrawText(A5textLayout, x, y + 100);
  72. }
  73. public void AfterCollect()
  74. {
  75. if(!_IsStoryMode) return;
  76. if (Hud.Game.IsPaused || (Hud.Game.NumberOfPlayersInGame == 1 && Hud.Game.IsLoading))
  77. {
  78. if (TotalTimeWatch.IsRunning)
  79. {
  80. TotalTimeWatch.Stop();
  81. }
  82. if (A1TimeWatch.IsRunning)
  83. {
  84. A1TimeWatch.Stop();
  85. }
  86. if (A2TimeWatch.IsRunning)
  87. {
  88. A2TimeWatch.Stop();
  89. }
  90. if (A3TimeWatch.IsRunning)
  91. {
  92. A3TimeWatch.Stop();
  93. }
  94. if (A4TimeWatch.IsRunning)
  95. {
  96. A4TimeWatch.Stop();
  97. }
  98. if (A5TimeWatch.IsRunning)
  99. {
  100. A5TimeWatch.Stop();
  101. }
  102. return;
  103. }
  104. if (!TotalTimeWatch.IsRunning) TotalTimeWatch.Start();
  105. int CurrentAct = Hud.Game.CurrentAct;
  106. if (CurrentAct == 1 && !A1TimeWatch.IsRunning)
  107. {
  108. A1TimeWatch.Start();
  109. A2TimeWatch.Stop();
  110. A3TimeWatch.Stop();
  111. A4TimeWatch.Stop();
  112. A5TimeWatch.Stop();
  113. }
  114. if (CurrentAct == 2 && !A2TimeWatch.IsRunning)
  115. {
  116. A1TimeWatch.Stop();
  117. A2TimeWatch.Start();
  118. A3TimeWatch.Stop();
  119. A4TimeWatch.Stop();
  120. A5TimeWatch.Stop();
  121. }
  122. if (CurrentAct == 3 && !A3TimeWatch.IsRunning)
  123. {
  124. A1TimeWatch.Stop();
  125. A2TimeWatch.Stop();
  126. A3TimeWatch.Start();
  127. A4TimeWatch.Stop();
  128. A5TimeWatch.Stop();
  129. }
  130. if (CurrentAct == 4 && !A4TimeWatch.IsRunning)
  131. {
  132. A1TimeWatch.Stop();
  133. A2TimeWatch.Stop();
  134. A3TimeWatch.Stop();
  135. A4TimeWatch.Start();
  136. A5TimeWatch.Stop();
  137. }
  138. if (CurrentAct == 5 && !A5TimeWatch.IsRunning)
  139. {
  140. A1TimeWatch.Stop();
  141. A2TimeWatch.Stop();
  142. A3TimeWatch.Stop();
  143. A4TimeWatch.Stop();
  144. A5TimeWatch.Start();
  145. }
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement