public RhythmMinigame(Vector2 position, Player owner, IRhythmWeapon item, int bPM, SoundEffect music) { Position = position; BPM = bPM; maxTime = 60f / BPM; Notes = new List <RhythmNote>(); ComboScale = new InterpolatedFloat(0f, 0.1f, InterpolatedFloat.EaseInOut); BeatScale = new InterpolatedFloat(0, 0.25f); Music = music.CreateInstance(); Music.Volume = 0; Music.IsLooped = true; Music.Play(); MusicVolume = new InterpolatedFloat(0f, 0.25f); MusicVolume.Set(0.05f); Visibility = new InterpolatedFloat(0f, 0.5f, InterpolatedFloat.EaseInOut); Visibility.Set(1f); Main.OnTick += MinigameDisposal; Owner = owner; Weapon = item; }
public Interpolator<float> Initialize(InterpolatedFloat interpolated, bool useThreshold = false) { m_interpolator = new Interpolator<float>(interpolated, useThreshold); m_interpolated = interpolated; m_initialized = true; return m_interpolator; }
/// <summary> /// Coroutine for smooth scrolling to an new item /// </summary> /// <param name="targetValue"></param> /// <returns></returns> private IEnumerator ScrollToTarget(float targetValue) { var interpolatedFloat = new InterpolatedFloat(contentPanel.anchoredPosition.y); _stopAutoScroll = false; while (!interpolatedFloat.IsAtValue(targetValue) && !_stopAutoScroll) { interpolatedFloat.ToValue(targetValue); contentPanel.anchoredPosition = new Vector2(0, interpolatedFloat.Value); // Check, if the scroll view will scroll outside the viewport if (scrollRect.normalizedPosition.y <= 0) { scrollRect.normalizedPosition = scrollRect.viewport.anchorMin; break; } if (scrollRect.normalizedPosition.y >= 1) { scrollRect.normalizedPosition = scrollRect.viewport.anchorMax; break; } yield return(new WaitForEndOfFrame()); } }
public void Beat() { Combo++; ComboScale.Set(Combo); BeatScale = new InterpolatedFloat(1f, 0.25f); BeatScale.Set(0f); Weapon.OnBeat(true, Combo); MusicVolume.Set(0.1f + Utils.Clamp(Combo, 0, 10) * 0.09f); }
public RhythmNote(RhythmMinigame owner) { Owner = owner; TimeLeft = 1f; Active = true; vertOffset = new InterpolatedFloat(0f, 0.2f, InterpolatedFloat.EaseInOutBack); vertOffset.Set(20f); disappearTimer = new InterpolatedFloat(0f, 0.3f, InterpolatedFloat.EaseInOut); }
public AnthemCircle(Vector2 position, Vector2 velocity, float startScale, float endScale, float timeLeft) { Position = position; Velocity = velocity; Scale = startScale; interpolatedScale = new InterpolatedFloat(startScale, timeLeft); interpolatedScale.Set(endScale); progress = new InterpolatedFloat(1f, timeLeft); progress.Set(0); }
public void Unpause() { if (Paused) { MusicVolume = new InterpolatedFloat(0f, 0.25f); MusicVolume.Set(0.1f); Music.Play(); Paused = false; Visibility.Set(1f); } }
void Start() { m_transformInterpolator = GetComponent<TransformInterpolator>(); m_pivotInterpolator = pivot.GetComponent<TransformInterpolator>(); InterpolatedFloat zoom = new InterpolatedFloat(() => (m_zoom), (val) => { m_zoom = val; }); m_zoomInterpolator = gameObject.AddComponent<FloatInterpolator>().Initialize(zoom); GameController.CharacterChanged += PlayerCharacterChanged; }
void Start() { m_movement = GetComponent<TSMovement>(); m_animator = GetComponent<Animator>(); m_camRig = FindObjectOfType<CameraRig>(); InterpolatedFloat speed = new InterpolatedFloat(() => (m_forwardSpeed), (val) => { m_forwardSpeed = val; }); gameObject.AddComponent<FloatInterpolator>().Initialize(speed); SetRagdoll(false); StoreBasePose(); m_lastHeadRot = m_headBone.rotation; m_lastHeadLocalRot = m_headBone.localRotation; }
void Update() { if (vehicle == null || !vehicle.isActiveAndEnabled) { speedNeedle.SetValue(0.0f); rpmNeedle.SetValue(0.0f); m_speedMs.Reset(0.0f); m_engineRpm.Reset(0.0f); SetEnabled(stalledSignal, false); SetEnabled(handbrakeSignal, false); SetEnabled(warningSignal, false); SetEnabled(retarderSignal, false); SetEnabled(fullDiffLockSignal, false); SetEnabled(axleDiffLockSignal, false); SetEnabled(centerDiffLockSignal, false); SetEnabled(singleAxleDriveSignal, false); SetEnabled(singleAxleDiffLockSignal, false); if (gearLabel != null) { gearLabel.text = "-"; } if (speedMphLabel != null) { speedMphLabel.text = "-"; } m_lastVehicleTime = -1.0f; return; } // Needles use interpolated values computed at visual frame rate float frameRatio = InterpolatedFloat.GetFrameRatio(); float speedMs = m_speedMs.GetInterpolated(frameRatio); float engineRpm = m_engineRpm.GetInterpolated(frameRatio); if (speedMs < 0) { speedMs = 0.0f; } if (engineRpm < 0) { engineRpm = 0.0f; } speedNeedle.SetValue(speedMs * 3.6f); rpmNeedle.SetValue(engineRpm); // Warning signal also at update rate because of its timing int[] vehicleData = vehicle.data.Get(Channel.Vehicle); bool abs = vehicleData[VehicleData.AbsEngaged] != 0; bool tcs = vehicleData[VehicleData.TcsEngaged] != 0; bool esc = vehicleData[VehicleData.EscEngaged] != 0; bool asr = vehicleData[VehicleData.AsrEngaged] != 0; if (abs || tcs || esc || asr) { m_warningTime = Time.time; } if (Time.time - m_warningTime < 0.5f) { SetEnabled(warningSignal, Mathf.Repeat(Time.time, 0.3f) < 0.2f); } else { SetEnabled(warningSignal, false); } // Visual stuff (Update) that is updated at FixedUpdate rate. // Ignore frames without updates. if (vehicle.time > m_lastVehicleTime) { // Prepare bus values int[] inputData = vehicle.data.Get(Channel.Input); int[] settingsData = vehicle.data.Get(Channel.Settings); // Stalled, handbrake and retarder signals bool vehicleEnabled = inputData[InputData.Key] >= 0; bool vehicleStalled = vehicleEnabled && vehicleData[VehicleData.EngineStalled] != 0; SetEnabled(stalledSignal, vehicleStalled); float handbrakeInput = inputData[InputData.Handbrake] / 10000.0f; bool handbrakeEngaged = vehicleEnabled && handbrakeInput > 0.1f; SetEnabled(handbrakeSignal, handbrakeEngaged); bool retarderEngaged = inputData[InputData.Retarder] > 0; SetEnabled(retarderSignal, retarderEngaged); // Driveline lock / unlock signals bool axleDiffLock = settingsData[SettingsData.DifferentialLock] == 1; bool centerDiffLock = settingsData[SettingsData.DrivelineLock] == 1; bool centerDiffUnlock = settingsData[SettingsData.DrivelineLock] == 2; SetEnabled(fullDiffLockSignal, axleDiffLock && centerDiffLock); SetEnabled(axleDiffLockSignal, axleDiffLock && !centerDiffLock && !centerDiffUnlock); SetEnabled(centerDiffLockSignal, !axleDiffLock && centerDiffLock); SetEnabled(singleAxleDriveSignal, !axleDiffLock && centerDiffUnlock); SetEnabled(singleAxleDiffLockSignal, axleDiffLock && centerDiffUnlock); // Speed Mph label if (speedMphLabel != null) { speedMphLabel.text = (speedMs * 2.237f).ToString("0") + "\nmph"; } // Gear label if (gearLabel != null) { int gearId = vehicleData[VehicleData.GearboxGear]; int gearMode = vehicleData[VehicleData.GearboxMode]; bool switchingGear = vehicleData[VehicleData.GearboxShifting] != 0; switch (gearMode) { case 0: // M if (gearId == 0) { gearLabel.text = switchingGear? " " : "N"; } else if (gearId > 0) { gearLabel.text = gearId.ToString(); } else { if (gearId == -1) { gearLabel.text = "R"; } else { gearLabel.text = "R" + (-gearId).ToString(); } } break; case 1: // P gearLabel.text = "P"; break; case 2: // R if (gearId < -1) { gearLabel.text = "R" + (-gearId).ToString(); } else { gearLabel.text = "R"; } break; case 3: // N gearLabel.text = "N"; break; case 4: // D if (gearId > 0) { gearLabel.text = "D" + gearId.ToString(); } else { gearLabel.text = "D"; } break; case 5: // L if (gearId > 0) { gearLabel.text = "L" + gearId.ToString(); } else { gearLabel.text = "L"; } break; default: gearLabel.text = "-"; break; } } m_lastVehicleTime = vehicle.time; } }