Screenshake
This commit is contained in:
parent
3fefb5278f
commit
46e1d0e05b
@ -18,12 +18,14 @@ public class BloodSucker : MonoBehaviour {
|
||||
VampireEntity vampireEntity;
|
||||
bool isSucking;
|
||||
float currentSuckTimer;
|
||||
[HideInInspector] public ScreenShaker screenShaker;
|
||||
[HideInInspector] public SoundManager soundManager;
|
||||
|
||||
void Awake() {
|
||||
vampireEntity = GetComponent<VampireEntity>();
|
||||
bloodParticles.Stop(true, ParticleSystemStopBehavior.StopEmitting);
|
||||
soundManager = FindObjectOfType<SoundManager>();
|
||||
screenShaker = FindObjectOfType<ScreenShaker>();
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
@ -101,6 +103,7 @@ public class BloodSucker : MonoBehaviour {
|
||||
currentTarget.bloodTokens -= 1;
|
||||
vampireEntity.HealDamage(healthGainFromSuck);
|
||||
// print("One token sucked");
|
||||
screenShaker.Shake();
|
||||
soundManager.PlaySound(suckSource, suckSounds, randomPitch:true, createTempSourceIfBusy:true);
|
||||
if (currentTarget.bloodTokens == 0) {
|
||||
SetIsSucking(false);
|
||||
|
||||
@ -21,6 +21,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
VampireEntity vampireEntity = null!;
|
||||
Animator animator = null!;
|
||||
public bool facingRight { get; private set; } = true;
|
||||
[HideInInspector] public ScreenShaker screenShaker;
|
||||
|
||||
[SerializeField] AudioSource jumpSource;
|
||||
[SerializeField] AudioClip[] jumpSounds;
|
||||
@ -40,6 +41,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
currentState = new ImmobileMovementState(this);
|
||||
soundManager = FindObjectOfType<SoundManager>();
|
||||
screenShaker = FindObjectOfType<ScreenShaker>();
|
||||
}
|
||||
|
||||
void Start() {
|
||||
@ -193,11 +195,13 @@ public class PlayerMovement : MonoBehaviour {
|
||||
// playerMovement.animator.SetBool("Jumping", true);
|
||||
playerMovement.animator.Play("Player_Jump");
|
||||
playerMovement.soundManager.PlaySound(playerMovement.jumpSource, playerMovement.jumpSounds, randomPitch: true, createTempSourceIfBusy: true);
|
||||
playerMovement.screenShaker.Shake();
|
||||
}
|
||||
public override void LeaveState() {
|
||||
// playerMovement.animator.SetBool("Jumping", false);
|
||||
playerMovement.animator.Play("Player_Idle");
|
||||
playerMovement.soundManager.PlaySound(playerMovement.landSource, playerMovement.landSounds, randomPitch: true, createTempSourceIfBusy: true);
|
||||
playerMovement.screenShaker.Shake();
|
||||
}
|
||||
|
||||
public override BaseState? FixedUpdateState() {
|
||||
|
||||
@ -2,16 +2,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class VampireEntity : Entity {
|
||||
[SerializeField] [field: Required]
|
||||
[SerializeField]
|
||||
[field: Required]
|
||||
PlayerStats playerStats = null!;
|
||||
|
||||
// [SerializeField] [Required]
|
||||
// HealthBar healthBar;
|
||||
[HideInInspector] public PlayerMovement playerMovement;
|
||||
[HideInInspector] public ScreenShaker screenShaker;
|
||||
|
||||
protected override void Awake() {
|
||||
base.Awake();
|
||||
transform.SetParent(arena.minionParent);
|
||||
screenShaker = FindObjectOfType<ScreenShaker>();
|
||||
}
|
||||
|
||||
protected override void Start() {
|
||||
@ -27,10 +30,13 @@ public class VampireEntity : Entity {
|
||||
TakeDamage(playerStats.bloodLossRate * Time.deltaTime, this, sound: false);
|
||||
}
|
||||
|
||||
// public override void TakeDamage(float amount) {
|
||||
// base.TakeDamage(amount);
|
||||
// healthBar.SetHealthFraction(Health / initialHealth);
|
||||
// }
|
||||
public override bool TakeDamage(float amount, Entity other, bool sound = true) {
|
||||
if (sound) {
|
||||
screenShaker.Shake();
|
||||
}
|
||||
|
||||
return base.TakeDamage(amount, other, sound);
|
||||
}
|
||||
|
||||
public bool IsInSafeZone() => playerMovement.IsInSafeZone;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user