Advertisement
Guest User

Entity

a guest
May 27th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class Entity : MonoBehaviour {
  6. [SerializeField]
  7. private float health = 0f;
  8. private string className = "entity_base";
  9. private GameObject go;
  10. private SpriteRenderer sr;
  11. private int index;
  12. private static List<Entity> ents = new List<Entity>();
  13.  
  14. public Entity( string className ){
  15. this.className = className;
  16. }
  17.  
  18. public static Entity Create( string className ){
  19. GameObject obj = new GameObject( className );
  20. obj.AddComponent<SpriteRenderer>();
  21. obj.AddComponent( className );
  22. Entity ent = ((Entity)obj.GetComponent( className ));
  23. ent.SetSprite( obj.GetComponent<SpriteRenderer>() );
  24. ent.SetObject( obj );
  25. ent.SetIndex( Entity.GetAll().Count );
  26. ents.Add( ent );
  27. return ent;
  28. }
  29.  
  30. public static List<Entity> GetAll(){
  31. return ents;
  32. }
  33.  
  34. public static void Destroy( Entity ent ){
  35.  
  36. }
  37.  
  38. private void SetIndex( int index ){
  39. this.index = index;
  40. }
  41.  
  42. public int GetIndex( ){
  43. return index;
  44. }
  45.  
  46. public void SetSprite( SpriteRenderer sr ){
  47. this.sr = sr;
  48. }
  49.  
  50. public SpriteRenderer GetSprite( ){
  51. return sr;
  52. }
  53.  
  54. public void SetObject( GameObject obj ){
  55. go = obj;
  56. }
  57.  
  58. public void SetTexture( Sprite sp ){
  59. sr.sprite = sp;
  60. }
  61.  
  62. public Sprite GetTexture(){
  63. return sr.sprite;
  64. }
  65.  
  66. public GameObject GetObject(){
  67. return go;
  68. }
  69.  
  70. public void SetPos( Vector2 vec ){
  71.  
  72. }
  73.  
  74. public string GetClass(){
  75. return className;
  76. }
  77.  
  78. public void SetHealth( float health ){
  79. this.health = health;
  80. }
  81.  
  82. public float GetHealth( ){
  83. return health;
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement