예제 #1
0
    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);
        }
    }
예제 #2
0
 void OnEnable()
 {
     activator             = base.target as GameObjectActivator;
     this.settingsFallback = serializedObject.FindProperty("settingsFallback");
     this.settingsList     = serializedObject.FindProperty("customSettings");
 }
예제 #3
0
 private void Awake()
 {
     _bulletPoolManager = FindObjectOfType <BulletsManager>();
     _activator         = GetComponent <GameObjectActivator>();
     _activator.Disactivate();
 }