//Feeds a random OType to Create() resulting in a random obstacle. public Obstacle getRandom() { //gets a random number in range of the enum OTypes. int num = rand.Next(Enum.GetNames(typeof(OTypes)).Length); Type = (OTypes)num; //returns the object needed return(Create(Type)); }
//============================================================================================= //Returns the obstacle that corresponds with T. Obstacle Create(OTypes T) { switch (T) { case OTypes.Slug: OFactory = new SlugFactory(User, Speed); break; case OTypes.Beetle: OFactory = new BeetleFactory(User, Speed); break; case OTypes.BrokenWindow: OFactory = new WindowFactory(User, Speed); break; default: break; } return(OFactory.Create()); }