private void OnEnable() { MaxHeight.Subscribe(ComputeScore); SparksCollected.Subscribe(ComputeScore); Score.SetValue(0); }
private void Awake() { healthTickList.Clear(); InitMaxHealth(); currentHungerLevel.Subscribe(UpdateHealthBar); //Trigger update to get latest. currentHungerLevel.Value = currentHungerLevel.Value; }
void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } InputManager.Instance.onRestartScene += () => { RestartScene(); }; InputManager.Instance.onStart += () => { if (_isPlayerDead.Value) { _deathText.SetActive(false); RestartScene(); } }; _isPlayerDead.Subscribe(TryEnableDeathText); DistanceText = DistanceTextTransform.Value.GetComponent <TMP_Text>(); distanceTextPrefix = DistanceText.text; shrineText = ShrineTextTransform.Value.GetComponent <TMP_Text>(); shrineTextPrefix = shrineText.text; TrySpawnBoss(); _playerShrinesVisited.Subscribe(TrySpawnBoss); if (UseRandomSeed) { UnityRandomSeed = Random.state.GetHashCode(); } Random.InitState(UnityRandomSeed); MapMagicObject mapMagic = MapMagicSceneReference.Value.GetComponent <MapMagicObject>(); if (GenerateRandomSeed || mapMagic.graph.random.Seed == 0) { mapMagic.graph.random.Seed = Random.Range(10000, 9999999); mapMagic.Refresh(); } if (UseSetSeed) { mapMagic.graph.random.Seed = int.Parse(Seed); mapMagic.Refresh(); } }
private void Start() { charMotor.CharacterController = this; MaxStableDenivelationAngle.Subscribe(OnUpdateMaxStableDenivelationAngle); HungerDecayTimer?.RestartTimer(); FrenzyOut.Subscribe(OnUpdateFrenzy); GroundSlamCooldownTimer.StartTimer(); capsuleStartHeight = charMotor.Capsule.height; capsuleStartCenter = charMotor.Capsule.center; capsuleStartRadius = charMotor.Capsule.radius; UpdateScale(Scale.Value, Scale.Value); Scale.Subscribe(UpdateScale); IsPlayerDead.Value = false; }
public void Setup() { ControlledUpdatePropertiesCallbacks = new List <Action>(); ControlledLateUpdatePropertiesCallbacks = new List <Action>(); ControlledFixedUpdatePropertiesCallbacks = new List <Action>(); ControlCurrent.Subscribe(() => { ControlledUpdateProperties?.ForEach((property) => { ControlledUpdatePropertiesCallbacks.Add(() => property.Update((float)ControlCurrent.Value / ControlMax.Value)); }); ControlledLateUpdateProperties?.ForEach((property) => { ControlledLateUpdatePropertiesCallbacks.Add(() => property.Update((float)ControlCurrent.Value / ControlMax.Value)); }); ControlledFixedUpdateProperties?.ForEach((property) => { ControlledFixedUpdatePropertiesCallbacks.Add(() => property.Update((float)ControlCurrent.Value / ControlMax.Value)); }); }); ControlCurrent.Value = ControlCurrent.Value; }
private void OnEnable() { CurrentDifficulty.Subscribe(SetupSegments); }