// Take Damage public override void TakeDamage(DamageInfo damageInfo) { HudElements.HealthBar.SetDamageTargetPosition(damageInfo.source.position); int finalDamage = CalcDamage(damageInfo.damage); float shakeRange = finalDamage / 10f; if (finalDamage < damageToPain && HealthInPercent > percentToPain) { switch (damageInfo.type) { case EDamageType.Impact: case EDamageType.Melee: PlayerCamera.ShakeOneShot(Random.Range(shakeRange, shakeRange * 1.65f)); HudElements.ShowPainScreen(); break; default: break; } } else { PlayerCamera.ShakeOneShot(Random.Range(shakeRange, shakeRange * 1.65f)); HudElements.ShowPainScreen(); } DecrementHealth(finalDamage); }
// OnDie protected override void OnDie() { base.OnDie(); // this.enabled = false; PlayerCamera.PlayerDie(); HudElements.PlayerDie(); FirstPersonController.PlayerDie(); FirstPersonWeaponSway[] tmpFPWeapSways = this.GetComponentsInChildren <FirstPersonWeaponSway>(); foreach (FirstPersonWeaponSway fpWSway in tmpFPWeapSways) { fpWSway.enabled = false; } GameObject bAnimGO = this.GetComponentInChildren <BodyAnimation>().gameObject; if (bAnimGO != null) { bAnimGO.SetActive(false); } // Show menu after die. ASKInputManager.PlayerDie(); }
// Awake internal void AwakeHUD() { m_Instance = this; cameraObj = this.GetComponentInChildren <Camera>().gameObject; // healthBar.Awake(); crosshair.Awake(); weaponInformer.Awake(); // nativePosition = rotationElements.localPosition; nativeRotation = rotationElements.localEulerAngles; // SetActive(GameSettings.ShowHud); }
// Take Damage public virtual void TakeDamage(DamageInfo damageInfo) { if (GameSettings.DamageIndication == EDamageIndication.ForAll) { if (damageInfo.owner.isPlayer) { HudElements.ShowDamegeIndicator(); } } else if (GameSettings.DamageIndication == EDamageIndication.OnlyCharacters) { if (damageInfo.owner.isPlayer && isNPC) { HudElements.ShowDamegeIndicator(); } } lastDamage = damageInfo; }
// Pause public static void Pause() { if (!PlayerCharacter.Instance.isAlive) { return; } gameIsPaused = !gameIsPaused; Time.timeScale = gameIsPaused ? 0f : 1f; MenuElements.SetActive(gameIsPaused); // if (GameSettings.ShowHud) { HudElements.SetActive(!gameIsPaused); } #if TOUCH_CONTROLS_KIT TCKInput.SetActive(!gameIsPaused); #endif }
// OnDisable protected override void OnDisable() { base.OnDisable(); HudElements.SetActive(false); }
// OnEnable protected override void OnEnable() { base.OnEnable(); HudElements.SetActive(GameSettings.ShowHud); }