public void TakeDamage(int damage) { currentHP -= damage; float vol = Random.Range(volMin, volMax); if (currentHP <= 0) { audioSource.PlayOneShot(breakSound, 1f); gameObject.SetActive(false); GameObjectActivator activator = GetComponent <GameObjectActivator>(); if (activator) { activator.Execute(); } } else if (currentHP <= damageHP) { this.GetComponent <SpriteRenderer>().sprite = damagedSprite; audioSource.PlayOneShot(hitSound[0], vol); } else { audioSource.PlayOneShot(hitSound[1], vol); } }
void OnEnable() { activator = base.target as GameObjectActivator; this.settingsFallback = serializedObject.FindProperty("settingsFallback"); this.settingsList = serializedObject.FindProperty("customSettings"); }
private void Awake() { _bulletPoolManager = FindObjectOfType <BulletsManager>(); _activator = GetComponent <GameObjectActivator>(); _activator.Disactivate(); }