init
This commit is contained in:
28
Assets/Scripts/Wall.cs
Normal file
28
Assets/Scripts/Wall.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Wall : MonoBehaviour
|
||||
{
|
||||
public Sprite dmgSprite;
|
||||
public int Hp = 4;
|
||||
private SpriteRenderer spriteRenderer;
|
||||
public AudioClip chopSound1;
|
||||
public AudioClip chopSound2;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
public void DamageWall(int loss)
|
||||
{
|
||||
SoundManager.instance.RandomizeSfx(chopSound1, chopSound2);
|
||||
spriteRenderer.sprite = dmgSprite;
|
||||
Hp -= loss;
|
||||
if (Hp <= 0)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user