// Update is called once per frame void Update() { if (lightToRandomize == null) { return; } if (updateInterval.IsRunning) { lightToRandomize.intensity = Mathf.Lerp(start_light, current_light, updateInterval.TimeNormalized); if (lightWobble) { float normalize_start = start_light / (lightIntensity.Max - lightIntensity.Min); float normalize_current = current_light / (lightIntensity.Max - lightIntensity.Min); transform.localPosition = _light_start_position + wobbleAxis * Mathf.Lerp(normalize_start, normalize_current, updateInterval.TimeNormalized) * lightWobbleMax; } return; } start_light = lightToRandomize.intensity; current_light = Random.Range(lightIntensity.Min, lightIntensity.Max); float intervalTime = Mathf.Max(0.01f, updateIntervalRange.RandomValuef()); updateInterval.Start(intervalTime); }
public static TimedRoutine Fade(this AudioSource target, float fadeToVolume, float fadeTime, bool stopPlaybackOnStop = false) { if (target == null) { return(null); } float startVolume = target.volume; TimedRoutine fadeAction = new TimedRoutine(fadeTime); fadeAction.OnLerp = (float timeNormalized) => { target.volume = Mathf.Lerp(startVolume, fadeToVolume, timeNormalized); }; fadeAction.OnStop = (bool isComplete) => { if (stopPlaybackOnStop) { target.Stop(); } }; fadeAction.Start(); return(fadeAction); }
void UpdateRaycaster(Collider other) { if (ignoreList.Contains(other)) { return; } if (!is2DRaycast && useBoxColliderCache) { _box_cached = false; } if (debugCheckAlways && !raycastChecker.IsRunning) { StartCoroutine(raycastChecker.Start()); } }
//Creates a temporary raycaster that will destroy itself after a short while public static Raycaster CreateTempRaycaster() { GameObject r_obj = new GameObject("Temp Raycaster"); Raycaster ray = r_obj.AddComponent <Raycaster>(); TimedRoutine time = new TimedRoutine(.5f); //destroy the object when the timer runs out time.Start(() => { GameObject.Destroy(r_obj); }); return(ray); }
public override void TryActivate() { base.TryActivate(); if (shootCooldown.IsRunning) { return; } GameObject missle = (GameObject)Instantiate(projectilePrefab, emitPoint.position, Quaternion.identity); Rigidbody body = missle.GetComponent <Rigidbody>(); body.velocity = emitPoint.forward * (owner.velocity.magnitude + shotVelocity); shootCooldown = new TimedRoutine(shootCooldownTime); shootCooldown.Start(); }
//Called each time an object comes into view public override void BindDataToView(ShotData data) { if (this.data != null) { //Debug.Log( "OOPS this data is still alive " + this.data.shotData ); this.data.IsAlive = false; lifetime.Reset(); NotifyLifetimeEnd(); } //before this call this object (the view) does not have an instance assigned //so we bind our data to this view and then do any additional setup required //example: we could set the text used by a ui text object by reading some value from the data base.BindDataToView(data); //Debug.Log( "Activating shot "+data.shotData ); lifetime = new TimedRoutine(maxLifetime, NotifyLifetimeEnd); lifetime.Start(); shotBehavior.Setup(this); }
void Update() { if (!active) { return; } HandleInput(); if (moreObject.activeInHierarchy) { moreFader.Start(); float t = moreFader.TimeRemainingNormalized; if (t < .5) { moreObject.GetComponentInChildren <UnityEngine.UI.Text>().color = Color.white * (t / .5f) + Color.yellow * (1f - (t / .5f)); } else { moreObject.GetComponentInChildren <UnityEngine.UI.Text>().color = Color.yellow * ((t - .5f) / .5f) + Color.white * (1f - ((t - .5f) / .5f)); } } if (packageOpened != packageOpenedPrev) { AdvanceStory(); } packageOpenedPrev = packageOpened; if (!extraPackageTimer.IsRunning) { extraPackageTimer.Start(); //Piece[] parts = GameObject.FindObjectsOfType<Piece>(); //if( parts.Length < minPieces ) // TryBackupDelivery(); } }
public void Awake() { ignoreTimer.Start(); AdvanceStory(); }