Advertisement
kanagara

Untitled

Mar 1st, 2024
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. public abstract class CreateWorker<T> : MonoBehaviour where T: WorkerBaseController
  2. {
  3.     [SerializeField]
  4.     protected T workerBaseObj;
  5.  
  6.     [SerializeField] protected Transform workerParent;
  7.    
  8.  
  9.     private void Start()
  10.     {
  11.         StartCoroutine(CreateWorkerObj());
  12.     }
  13.  
  14.     protected abstract IEnumerator CreateWorkerObj();
  15.  
  16. }
  17.  
  18. public class CreateKitchenWorker : CreateWorker<WorkerKitchenController>
  19. {
  20.     [SerializeField] private Transform plateLoaderTransform;
  21.     [SerializeField] private GatherIngredients gatherIngredients;
  22.     [SerializeField] private CollectAndCook collectAndCook;
  23.     protected override IEnumerator CreateWorkerObj()
  24.     {
  25.         yield return new WaitForSeconds(3f);
  26.  
  27.         var workerBaseController = Instantiate(workerBaseObj, workerParent);
  28.         workerBaseController.transform.localPosition = Vector3.zero;
  29.         workerBaseController.name = "worker";
  30.         workerBaseController.Initialize(2, 8, plateLoaderTransform, gatherIngredients, collectAndCook);
  31.  
  32.         yield return new WaitForSeconds(1f);
  33.  
  34.         workerBaseController = Instantiate(workerBaseObj, workerParent);
  35.         workerBaseController.transform.localPosition = Vector3.zero;
  36.         workerBaseController.name = "worker";
  37.         workerBaseController.Initialize(2, 8, plateLoaderTransform, gatherIngredients, collectAndCook);
  38.     }
  39. }
  40.  
  41.  
  42. public class CreateCustomerServiceWorker : CreateWorker<WorkerCustomerServiceController>
  43. {
  44.     protected override IEnumerator CreateWorkerObj()
  45.     {
  46.         yield return null;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement