Ejemplo n.º 1
0
    protected virtual T onCreate(T prefab, SpawnObjectHolder <T> holder)
    {
        T item = Instantiate(prefab);

        item.setReusable();
        item.transform.parent = holder.parent;
        holder.items++;
        return(item);
    }
Ejemplo n.º 2
0
    protected virtual T onReuse(SpawnObjectHolder <T> holder)
    {
        T item = holder.reusable[0];

        item.transform.position = Vector2.zero;
        holder.reusable.RemoveAt(0);
        item.gameObject.SetActive(true);
        item.resetObject();
        return(item);
    }
Ejemplo n.º 3
0
    protected SpawnObjectHolder <T> createHolder(T prefab)
    {
        Transform parent = new GameObject(getName(prefab)).transform;

        parent.parent           = transform;
        parent.localEulerAngles = Vector2.zero;
        parent.localPosition    = Vector2.right * 1000;

        SpawnObjectHolder <T> holder = new SpawnObjectHolder <T>(prefab, parent);

        holderByPrefab.Add(prefab, holder);
        holderByParent.Add(parent, holder);;
        return(holder);
    }
Ejemplo n.º 4
0
 public void Start()
 {
     cam          = Camera.main;
     meteorHolder = MissleSpawner.instance.getHolder(prefab);
     StartCoroutine(spawnLoop());
 }