// Update is called once per frame void Update() { if (RInput.GetButtonDown("Flashlight") && !_modifying) { if (_ool.Toggled && isActiv) { AkSoundEngine.PostEvent("play_flashlight_off", this.gameObject); _ool.ToggleOff(); } else if (!_ool.Toggled && _battery.CurrentBattery > _battery.ToggleOnCost && isActiv) { AkSoundEngine.PostEvent("play_flashlight_on", this.gameObject); Debug.Log("SOUND PLAYER"); _ool.ToggleOn(); } } }
void Update() { Percentage = CurrentBattery / MaxBattery; CurrentBatteryColor = Color.Lerp(MinBatteryColor, FullBatteryColor, Percentage); if (_light != null) { _light.color = CurrentBatteryColor; } // If flashlight is off, waited the regen cooldown and hasn't max battery if (!_ool.Toggled && Time.time > _regenStart && CurrentBattery < MaxBattery) { IsLoading = true; CurrentBattery += RegenSpeed * Time.deltaTime; if (CurrentBattery > MaxBattery) { CurrentBattery = MaxBattery; } } // If the flashlight is lit, consume battery and test if it has to be shutdown if (_ool.Toggled) { CurrentBattery -= (Boosted ? BoostedConsumptionPerSecond : NormalConsumptionPerSecond) * Time.deltaTime; if (CurrentBattery <= 0) { CurrentBattery = 0; AkSoundEngine.PostEvent("play_flashlight_shut_off", this.gameObject); if (NoBatterySound != null) { _ool.ToggleOff(false); AudioSource source = gameObject.AddComponent <AudioSource>(); source.clip = NoBatterySound; source.Play(); Destroy(source, NoBatterySound.length); } else { _ool.ToggleOff(); } } } }
IEnumerator startSequence() { //Turn off lamp1 lamp1.ToggleOff(); lamp3.ToggleOff(); yield return(new WaitForSeconds(delay1)); //Turn on lamp1 lamp1.ToggleOn(); yield return(new WaitForSeconds(delay2)); //Turn off lamp2 lamp2.ToggleOff(); yield return(new WaitForSeconds(delay3)); //Turn off lamp1 lamp1.ToggleOff(); lamp3.ToggleOn(); }
// Use this for initialization void Start() { if (Player == null) { Player = gameObject; } _playerStatus = GetComponent <Lightable>(); _battery = GetComponent <FlashlightBattery>(); _ool = GetComponent <OnOffLight>(); //le joueur démarre la lampe allumé _playerStatus.LightSources = 1; _ool.OnToggle += (on) => { if (on == true) { _playerStatus.LightSources += 1; } else { _playerStatus.LightSources -= 1; } }; _fov = GetComponent <FieldOfView>(); _baseAngle = _fov.ViewAngle; if (_baseAngle + AngleIncrease > 360) { AngleIncrease = 360 - _baseAngle; } _baseLightAngle = _ool.Lights[0].spotAngle; // To determine joypad or keyboard inputManager = GameObject.Find("GameManager").GetComponent <InputManager>(); if (Player.name == "Player2") { RInput = Rewired.ReInput.players.GetPlayer(inputManager.Player2Index); } else { RInput = Rewired.ReInput.players.GetPlayer(inputManager.Player1Index); } _ool.ToggleOff(); }