Advertisement
Guest User

Wall

a guest
Apr 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Wall : MonoBehaviour {
  5.  
  6.     public Sprite dmgSprite;
  7.     public int hp = 4;
  8.     public AudioClip chopSound1;
  9.     public AudioClip chopSound2;
  10.  
  11.     private SpriteRenderer spriteRenderer;
  12.  
  13.     // Use this for initialization
  14.     void Awake ()
  15.     {
  16.         spriteRenderer = GetComponent<SpriteRenderer>();
  17.     }
  18.    
  19.     public void DamageWall (int loss)
  20.     {
  21.         SoundManager.instance.RandomizeSfx (chopSound1, chopSound2);
  22.         spriteRenderer.sprite = dmgSprite;
  23.         hp -= loss;
  24.         if (hp <=0)
  25.             gameObject.SetActive(false);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement