/// <summary> /// Initialize Player components /// <see cref="Unity Documentation"> /// </summary> protected override void Awake() { base.Awake(); this.controllerRumble = GetComponent <ControllerRumble>(); this.playerSound = GetComponent <PlayerSound>(); this.movement = new PlayerMovement(movementBean, this.Transform, this.Rigidbody, this.LightEnergy); this.lightToggle = new PlayerLightToggle(this.Transform.Find("LightsToToggle").gameObject, this, lightToggleBean); this.flareControl = new PlayerSpawnFlare(flareBean, this, controllerRumble); this.movementBean.DefaultDrag = Rigidbody.drag; this.isDead = false; this.isSafe = true; }
/// <summary> /// Initializes Player components /// </summary> protected override void Awake() { base.Awake(); // call parent LightSource Awake() first if (playerInstance != null && playerInstance != this) { GameObject.Destroy(this.gameObject); } else { DontDestroyOnLoad(this.gameObject); playerInstance = this; } this.movement = new PlayerMovement(massEjectionTransform, lightBallPrefab, thrustForce, changeDirectionBoost, thrustEnergyCost, brakeDrag, this.Transform, this.Rigidbody, this.LightEnergy, this.jetFuelEffect, this.rotationSpeed); this.lightToggle = new PlayerLightToggle(this.Transform.Find("LightsToToggle").gameObject, defaultLightStatus, this, minimalEnergyRestrictionToggleLights, propulsionLightRange); this.materials = new MaterialExtensions(); this.defaultDrag = Rigidbody.drag; this.isDead = false; this.isSafe = true; this.controllerRumble = GetComponent <ControllerRumble>(); playerSound = GetComponent <PlayerSound>(); this.currentLevel = SceneManager.GetActiveScene().buildIndex; ChangeColor(probeColorOff, false, 0); LoadGame(); ResetPlayerState(); gameOverCanvas = GameObject.FindWithTag("GameOverCanvas"); UI = GameObject.FindWithTag("UI"); if (gameOverCanvas == null) { Canvas[] canvases = UI.GetComponentsInChildren <Canvas>(); foreach (Canvas canvas in canvases) { if (canvas.name == "GameOverCanvas") { gameOverCanvas = canvas.gameObject; break; } } } #if UNITY_EDITOR this.ValidateInputs(); #endif }
/// <summary> /// Given a light smoothly increases its intensity until target is reached /// </summary> /// <param name="light"></param> /// <param name="targetIntensity"></param> /// <returns></returns> public IEnumerator ChangeLightIntensity(PlayerLightToggle light, float targetIntensity) { float intensityStep = 0.0125f; // validate input if (light != null & light.ProbeLight != null) { while (light.ProbeLight.intensity > targetIntensity) { light.ProbeLight.intensity -= intensityStep; yield return(null); } while (light.ProbeLight.intensity < targetIntensity) { light.ProbeLight.intensity += intensityStep; yield return(null); } } }
/// <summary> /// Given a light smoothly increases its intensity until target is reached /// </summary> /// <param name="light"></param> /// <param name="targetIntensity"></param> /// <returns></returns> public IEnumerator ChangeLightIntensity(PlayerLightToggle light, float targetIntensity) { float intensityStep = 0.0125f; // validate input if (light != null & light.ProbeLight != null) { while (light.ProbeLight.intensity > targetIntensity) { light.ProbeLight.intensity -= intensityStep; yield return null; } while (light.ProbeLight.intensity < targetIntensity) { light.ProbeLight.intensity += intensityStep; yield return null; } } }
/// <summary> /// Initializes Player components /// </summary> protected override void Awake() { base.Awake(); // call parent LightSource Awake() first if (playerInstance != null && playerInstance != this) { GameObject.Destroy(this.gameObject); } else { DontDestroyOnLoad(this.gameObject); playerInstance = this; } this.movement = new PlayerMovement(massEjectionTransform, lightBallPrefab, thrustForce, changeDirectionBoost, thrustEnergyCost, brakeDrag, this.Transform, this.Rigidbody, this.LightEnergy, this.jetFuelEffect, this.rotationSpeed); this.lightToggle = new PlayerLightToggle(this.Transform.Find("LightsToToggle").gameObject, defaultLightStatus, this, minimalEnergyRestrictionToggleLights, propulsionLightRange); this.materials = new MaterialExtensions(); this.defaultDrag = Rigidbody.drag; this.isDead = false; this.isSafe = true; this.controllerRumble = GetComponent<ControllerRumble>(); playerSound = GetComponent<PlayerSound>(); this.currentLevel = SceneManager.GetActiveScene().buildIndex; ChangeColor(probeColorOff, false, 0); LoadGame(); ResetPlayerState(); gameOverCanvas = GameObject.FindWithTag("GameOverCanvas"); UI = GameObject.FindWithTag("UI"); if (gameOverCanvas == null) { Canvas[] canvases = UI.GetComponentsInChildren<Canvas>(); foreach (Canvas canvas in canvases) { if (canvas.name == "GameOverCanvas") { gameOverCanvas = canvas.gameObject; break; } } } #if UNITY_EDITOR this.ValidateInputs(); #endif }