// 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(); }
void Start() { if (powerBar == null && Canvas != null) { if (name == "Player1") { Transform tr = Canvas.Find("Johnson_UI"); powerBar = tr.Find("battery_johnson").GetComponent <Image>(); } else { powerBar = Canvas.Find("Victoria_UI").Find("battery_victoria").GetComponent <Image>(); } } if (powerBar == null) { this.enabled = false; return; } powerBar.fillAmount = 100; _battery = GetComponent <FlashlightBattery>(); }