void Awake() { //Check if on Desktop or Mobile. CheckDeviceType(); //Set External References. gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); musicController = GameObject.FindGameObjectWithTag("MusicController").GetComponent <MusicController>(); //Set Internal References. rb2d = this.GetComponent <Rigidbody2D>(); streetcarAnimator = this.GetComponent <Animator>(); colorStrobe = this.GetComponentInChildren <ColorStrobe>(); //Lists and other things. PassengerInfo = new List <PedestrianData>(); currentPassengers = 0; currentAbilities = new List <string>(); for (int i = 0; i < 5; i++) { currentAbilities.Add(""); } //Initialize parameters. maxSpeed = baseMaxSpeed; acceleration = baseAcceleration; speedBoostUI.text = inspectorNum.ToString(); scoreMultiplier = false; score = 0; shields = 0; speedBoosts = 0; abilities = 0; }
private void AudioMeter_Extended_Solid_Color_Strobe(ColorStrobe LightStrobeMode) { switch (LightStrobeMode) { case ColorStrobe.White: case ColorStrobe.SingleWhite: for (int i = 0; i < LightSystem.LIGHT_COUNT; i++) { CurrentFrame [i].R = 255; CurrentFrame [i].G = 255; CurrentFrame [i].B = 255; } break; case ColorStrobe.Rainbow: case ColorStrobe.SingleRainbow: AnimationUpdateColorShift (); for (int i = 0; i < LightSystem.LIGHT_COUNT; i++) { CurrentFrame [i].R = ColorShift_Red; CurrentFrame [i].G = ColorShift_Green; CurrentFrame [i].B = ColorShift_Blue; } break; case ColorStrobe.Hueshift: for (int i = 0; i < LightSystem.LIGHT_COUNT; i++) { if (LightProcessing.Is_LED_Dark_Brightness (CurrentFrame, i, LightSystem.Color_DARK)) { CurrentFrame [i].R = 0; CurrentFrame [i].G = 0; CurrentFrame [i].B = 0; } } //Assigning colors handled below break; default: break; } double CurrentLight_VU_Max = 0; if (LightStrobeMode != ColorStrobe.SingleRainbow & LightStrobeMode != ColorStrobe.SingleWhite) { for (int i = 0; i < (LightSystem.LIGHT_COUNT / 2); i++) { if (i < AudioProcessedSnapshot.Count) { CurrentLight_VU_Max = AudioProcessedSnapshot [Math.Min (((LightSystem.LIGHT_COUNT / 2 - 1) - i), AudioProcessedSnapshot.Count - 1)]; } if (LightStrobeMode == ColorStrobe.Hueshift) { if (LightProcessing.Is_LED_Dark_Brightness (CurrentFrame, i, LightSystem.Color_DARK)) { if ((Randomizer.RandomProvider.NextDouble () < Audio_Low_Intensity * VU_Solid_Color_Strobe_Hueshift_Flicker_Chance)) { CurrentFrame [i].B = 255; CurrentFrame [i].Brightness = 255; } else if ((Randomizer.RandomProvider.NextDouble () < Audio_Mid_Intensity * VU_Solid_Color_Strobe_Hueshift_Flicker_Chance)) { CurrentFrame [i].G = 255; CurrentFrame [i].Brightness = 255; } else if ((Randomizer.RandomProvider.NextDouble () < Audio_High_Intensity * VU_Solid_Color_Strobe_Hueshift_Flicker_Chance)) { CurrentFrame [i].R = 255; CurrentFrame [i].Brightness = 255; } else { CurrentFrame [i].Brightness = 0; } } else { CurrentFrame [i].Brightness = 0; } } else { if ((Randomizer.RandomProvider.NextDouble () < Audio_Average_Intensity * VU_Solid_Color_Strobe_Flicker_Chance) && LightProcessing.Is_LED_Dark_Brightness (CurrentFrame, i, LightSystem.Color_DARK)) { CurrentFrame [i].R = LightSystem.Color_MAX; CurrentFrame [i].G = LightSystem.Color_MAX; CurrentFrame [i].B = LightSystem.Color_MAX; CurrentFrame [i].Brightness = 255; //Strobe mode overrides the standard VU-based flickering } else { if (CurrentLight_VU_Max > 0.5) { CurrentFrame [i].Brightness = (byte)(255 * (CurrentLight_VU_Max - 0.5) * VU_ColorShift_Brightness_Multiplier); } else { CurrentFrame [i].Brightness = 0; } } } } //Clone upper half to lower half int i_source = 0; for (int i = LightSystem.LIGHT_INDEX_MAX; i > (LightSystem.LIGHT_INDEX_MIDDLE); i--) { i_source = (LightSystem.LIGHT_INDEX_MAX - i); CurrentFrame [i].R = CurrentFrame [i_source].R; CurrentFrame [i].G = CurrentFrame [i_source].G; CurrentFrame [i].B = CurrentFrame [i_source].B; CurrentFrame [i].Brightness = CurrentFrame [i_source].Brightness; } } else if (LightStrobeMode == ColorStrobe.SingleRainbow | LightStrobeMode == ColorStrobe.SingleWhite) { if (VU_Solid_Color_Single_Strobe_Off_Count > MathUtilities.ConvertRange (Audio_Average_Intensity, 0, 1, VU_Solid_Color_Single_Strobe_Max_Delay, VU_Solid_Color_Single_Strobe_Min_Delay)) { VU_Solid_Color_Single_Strobe_Off_Count = 0; for (int i = 0; i < LightSystem.LIGHT_COUNT; i++) { CurrentFrame [i].Brightness = 255; } } else { VU_Solid_Color_Single_Strobe_Off_Count ++; for (int i = 0; i < LightSystem.LIGHT_COUNT; i++) { CurrentFrame [i].Brightness = 0; } } } if (LightStrobeMode == ColorStrobe.SingleRainbow | LightStrobeMode == ColorStrobe.SingleWhite) { SmoothingAmount = Math.Min (Math.Max ((1 - (Audio_Average_Intensity * 1.1)), 0.45), 0.75); SmoothingAmount = Math.Max (SmoothingAmount - (VU_Solid_Color_Single_Strobe_Smoothing_Decrease * Audio_Average_Intensity), 0); //ApplySmoothing (Math.Max (VU_Smoothing_Percentage - (VU_Solid_Color_Single_Strobe_Smoothing_Decrease * VU_Average_Intensity), 0), true); } }