Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. // -----------------------------------------------------------------------
  2. // <copyright file="NeonGlow.cs" company="Morten">
  3. // 2011 © Morten T. Pedersen aka MulleDK19 ® All rights reserved.
  4. // </copyright>
  5. // -----------------------------------------------------------------------
  6.  
  7. namespace NeonGlow
  8. {
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Text;
  13. using GTA;
  14.  
  15. /// <summary>
  16. /// Makes your car glow
  17. /// </summary>
  18. public class NeonGlow : Script
  19. {
  20. public NeonGlow()
  21. {
  22. Interval = 250;
  23. BindKey(Keys.I, ToggleNeonGlow);
  24. }
  25. #region Private Fields
  26. /// <summary>
  27. /// The Light object.
  28. /// </summary>
  29. private Light light;
  30.  
  31. /// <summary>
  32. /// The available colors.
  33. /// </summary>
  34. private Color[] colors;
  35.  
  36. /// <summary>
  37. /// The index of the current color.
  38. /// </summary>
  39. private int currentColor;
  40.  
  41. /// <summary>
  42. /// The timer used to keep change the light.
  43. /// </summary>
  44. private GTA.Timer glowTimer;
  45. #endregion
  46.  
  47. #region Constructors
  48. /// <summary>
  49. /// Initializes a new instance of the <see cref="NeonGlow"/> class.
  50. /// </summary>
  51. public NeonGlow()
  52. {
  53. this.Interval = 10;
  54. this.Light = new Light(Color.Lime, 3, 100.0f);
  55.  
  56. this.Tick += new EventHandler(this.NeonGlow_Tick);
  57.  
  58. List<Color> colors = new List<Color>();
  59. colors.Add(Color.Magenta);
  60. colors.Add(Color.Cyan);
  61. colors.Add(Color.Blue);
  62. colors.Add(Color.Red);
  63. colors.Add(Color.Orange);
  64. colors.Add(Color.Pink);
  65. colors.Add(Color.Lime);
  66. colors.Add(Color.Purple);
  67. this.Colors = colors.ToArray();
  68. this.CurrentColor = 0;
  69.  
  70. this.GlowTimer = new Timer(500);
  71. this.GlowTimer.Tick += new EventHandler(this.GlowTimer_Tick);
  72. this.GlowTimer.Start();
  73. }
  74. #endregion
  75.  
  76. #region Properties
  77. /// <summary>
  78. /// Gets the light.
  79. /// </summary>
  80. internal Light Light
  81. {
  82. get { return this.light; }
  83. private set { this.light = value; }
  84. }
  85.  
  86. /// <summary>
  87. /// Gets the colors.
  88. /// </summary>
  89. internal Color[] Colors
  90. {
  91. get { return this.colors; }
  92. private set { this.colors = value; }
  93. }
  94.  
  95. /// <summary>
  96. /// Gets the index of the current color.
  97. /// </summary>
  98. /// <value>
  99. /// The index of the current color.
  100. /// </value>
  101. internal int CurrentColor
  102. {
  103. get { return this.currentColor; }
  104. private set { this.currentColor = value; }
  105. }
  106.  
  107. /// <summary>
  108. /// Gets the glow timer.
  109. /// </summary>
  110. internal GTA.Timer GlowTimer
  111. {
  112. get { return this.glowTimer; }
  113. private set { this.glowTimer = value; }
  114. }
  115. #endregion
  116.  
  117. #region Private Methods
  118. /// <summary>
  119. /// Handles the Tick event of the GlowTimer control.
  120. /// </summary>
  121. /// <param name="sender">The source of the event.</param>
  122. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  123. private void GlowTimer_Tick(object sender, EventArgs e)
  124. {
  125. if (this.CurrentColor < this.colors.Length - 1)
  126. {
  127. ++this.CurrentColor;
  128. }
  129. else
  130. {
  131. this.CurrentColor = 0;
  132. }
  133.  
  134. this.Light.Color = this.Colors[this.CurrentColor];
  135. }
  136.  
  137. /// <summary>
  138. /// Handles the Tick event of the NeonGlow control.
  139. /// </summary>
  140. /// <param name="sender">The source of the event.</param>
  141. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  142. private void NeonGlow_Tick(object sender, EventArgs e)
  143. {
  144. if (!Player.Character.isInVehicle())
  145. {
  146. if (this.Light.Enabled)
  147. {
  148. this.Light.Enabled = false;
  149. }
  150.  
  151. return;
  152. }
  153. else
  154. {
  155. if (!this.Light.Enabled)
  156. {
  157. this.Light.Enabled = true;
  158. }
  159. }
  160.  
  161. Vector3 position = this.Player.Character.CurrentVehicle.Position;
  162. position = position.ToGround();
  163. position.Z += 0.1f;
  164. this.Light.Position = position;
  165. }
  166. #endregion
  167. }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement