Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Factory<T> where T : PoolingObject
- {
- public List<T> GetItems(int count)
- {
- List<T> lineItems = new List<T>();
- for (int i = 0; i < count; i++)
- {
- lineItems.Add(CreateItem());
- }
- return lineItems;
- }
- public abstract T CreateItem();
- }
- public class PlatformsFactory : Factory<LineItem>
- {
- private VerticalLine parent;
- private LineItem prefab;
- public PlatformsFactory(VerticalLine parent, LineItem prefab)
- {
- this.parent = parent;
- this.prefab = prefab;
- }
- public override LineItem CreateItem()
- {
- LineItem lineItem = GameObject.Instantiate(prefab, parent.transform);
- lineItem.Initialize(parent, GetRandomParametrs());
- return lineItem;
- }
- public LineItemParametrs GetRandomParametrs()
- {
- float lenght = Random.Range(4F, 8F);
- int colorId = Random.Range(1, 5);
- LineItemParametrs lineItem = new LineItemParametrs(lenght, colorId);
- return lineItem;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement