Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class Entity : MonoBehaviour {
- [SerializeField]
- private float health = 0f;
- private string className = "entity_base";
- private GameObject go;
- private SpriteRenderer sr;
- private int index;
- private static List<Entity> ents = new List<Entity>();
- public Entity( string className ){
- this.className = className;
- }
- public static Entity Create( string className ){
- GameObject obj = new GameObject( className );
- obj.AddComponent<SpriteRenderer>();
- obj.AddComponent( className );
- Entity ent = ((Entity)obj.GetComponent( className ));
- ent.SetSprite( obj.GetComponent<SpriteRenderer>() );
- ent.SetObject( obj );
- ent.SetIndex( Entity.GetAll().Count );
- ents.Add( ent );
- return ent;
- }
- public static List<Entity> GetAll(){
- return ents;
- }
- public static void Destroy( Entity ent ){
- }
- private void SetIndex( int index ){
- this.index = index;
- }
- public int GetIndex( ){
- return index;
- }
- public void SetSprite( SpriteRenderer sr ){
- this.sr = sr;
- }
- public SpriteRenderer GetSprite( ){
- return sr;
- }
- public void SetObject( GameObject obj ){
- go = obj;
- }
- public void SetTexture( Sprite sp ){
- sr.sprite = sp;
- }
- public Sprite GetTexture(){
- return sr.sprite;
- }
- public GameObject GetObject(){
- return go;
- }
- public void SetPos( Vector2 vec ){
- }
- public string GetClass(){
- return className;
- }
- public void SetHealth( float health ){
- this.health = health;
- }
- public float GetHealth( ){
- return health;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement