SHARE
TWEET

Untitled

a guest Jan 18th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void OnTriggerEnter2D (Collider2D other)
  2. {
  3.         other.gameObject.GetComponent<Solder> ().HP -= damage;
  4.         Destroy (gameObject);
  5. }
  6.    
  7. public class BaseUnit: MonoBehaviour
  8. {
  9.     public int HP;
  10. }
  11.    
  12. void OnTriggerEnter2D (Collider2D other)
  13. {
  14.     other.gameObject.GetComponent<BaseUnit>().HP -= damage;
  15.     Destroy (gameObject);
  16. }
  17.    
  18. public interface IBaseUnit
  19. {
  20.     int HP { get; set; }
  21. }
  22.    
  23. public class Solder: MonoBehaviour, IBaseUnit
  24. {
  25.     public int HP { get; set; }
  26.  
  27.     //остальной код класса...
  28. }
  29.    
  30. void OnTriggerEnter2D (Collider2D other)
  31. {
  32.     other.gameObject.GetComponent<IBaseUnit>().HP -= damage;
  33.     Destroy (gameObject);
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top