Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -----------------------------------------------------------------------
- // <copyright file="NeonGlow.cs" company="Morten">
- // 2011 © Morten T. Pedersen aka MulleDK19 ® All rights reserved.
- // </copyright>
- // -----------------------------------------------------------------------
- namespace NeonGlow
- {
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Text;
- using GTA;
- /// <summary>
- /// Makes your car glow
- /// </summary>
- public class NeonGlow : Script
- {
- public NeonGlow()
- {
- Interval = 250;
- BindKey(Keys.I, ToggleNeonGlow);
- }
- #region Private Fields
- /// <summary>
- /// The Light object.
- /// </summary>
- private Light light;
- /// <summary>
- /// The available colors.
- /// </summary>
- private Color[] colors;
- /// <summary>
- /// The index of the current color.
- /// </summary>
- private int currentColor;
- /// <summary>
- /// The timer used to keep change the light.
- /// </summary>
- private GTA.Timer glowTimer;
- #endregion
- #region Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="NeonGlow"/> class.
- /// </summary>
- public NeonGlow()
- {
- this.Interval = 10;
- this.Light = new Light(Color.Lime, 3, 100.0f);
- this.Tick += new EventHandler(this.NeonGlow_Tick);
- List<Color> colors = new List<Color>();
- colors.Add(Color.Magenta);
- colors.Add(Color.Cyan);
- colors.Add(Color.Blue);
- colors.Add(Color.Red);
- colors.Add(Color.Orange);
- colors.Add(Color.Pink);
- colors.Add(Color.Lime);
- colors.Add(Color.Purple);
- this.Colors = colors.ToArray();
- this.CurrentColor = 0;
- this.GlowTimer = new Timer(500);
- this.GlowTimer.Tick += new EventHandler(this.GlowTimer_Tick);
- this.GlowTimer.Start();
- }
- #endregion
- #region Properties
- /// <summary>
- /// Gets the light.
- /// </summary>
- internal Light Light
- {
- get { return this.light; }
- private set { this.light = value; }
- }
- /// <summary>
- /// Gets the colors.
- /// </summary>
- internal Color[] Colors
- {
- get { return this.colors; }
- private set { this.colors = value; }
- }
- /// <summary>
- /// Gets the index of the current color.
- /// </summary>
- /// <value>
- /// The index of the current color.
- /// </value>
- internal int CurrentColor
- {
- get { return this.currentColor; }
- private set { this.currentColor = value; }
- }
- /// <summary>
- /// Gets the glow timer.
- /// </summary>
- internal GTA.Timer GlowTimer
- {
- get { return this.glowTimer; }
- private set { this.glowTimer = value; }
- }
- #endregion
- #region Private Methods
- /// <summary>
- /// Handles the Tick event of the GlowTimer control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
- private void GlowTimer_Tick(object sender, EventArgs e)
- {
- if (this.CurrentColor < this.colors.Length - 1)
- {
- ++this.CurrentColor;
- }
- else
- {
- this.CurrentColor = 0;
- }
- this.Light.Color = this.Colors[this.CurrentColor];
- }
- /// <summary>
- /// Handles the Tick event of the NeonGlow control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
- private void NeonGlow_Tick(object sender, EventArgs e)
- {
- if (!Player.Character.isInVehicle())
- {
- if (this.Light.Enabled)
- {
- this.Light.Enabled = false;
- }
- return;
- }
- else
- {
- if (!this.Light.Enabled)
- {
- this.Light.Enabled = true;
- }
- }
- Vector3 position = this.Player.Character.CurrentVehicle.Position;
- position = position.ToGround();
- position.Z += 0.1f;
- this.Light.Position = position;
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement