public Entity(Transform transformTemp, bool infected, float recoveryRate, float transferChance, float moveSpeed) { /* * The constructor for entity where five parameters are defined. * Creates an ID, sets the object's transform (the unity sprite which it is associated to) * and initialises its sprite, movement class (compositionally aggregated) and * infection class (also compositionally aggregated). */ transform = transformTemp; //Creates a unique ID for each entity ID = tempID; tempID++; //Sets up movement composite object movement = transform.gameObject.GetComponent <Movement> (); movement.Initialise(this, moveSpeed); //Sets up infection composite object infection = transform.gameObject.GetComponent <Infection> (); infection.Initialise(transferChance, recoveryRate, infected); infection.ID = ID; sprite = transform.gameObject.GetComponent <SpriteRenderer> (); }
public Entity(Transform transformTemp) { /* * An alternative constructor for when additional parameters are not defined. * Creates an entity with default parameters. */ transform = transformTemp; //Creates an ID for the entity ID = tempID; tempID++; //Sets up movement composite object movement = transform.gameObject.GetComponent <Movement> (); movement.Initialise(this, 0); //Sets up infection composite object infection = transform.gameObject.GetComponent <Infection> (); infection.Initialise(1, 0, false); infection.ID = ID; sprite = transform.gameObject.GetComponent <SpriteRenderer> (); }