public void Init(DishClientCore _core, bool _canControl) { core = _core; canControl = _canControl; trashContainer.Init(core); for (int i = 0; i < CookConst.RESULT_STATE.Length; i++) { GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/resultContainer.prefab", null); go.transform.SetParent(dishResultContainer, false); (go.transform as RectTransform).anchoredPosition = new Vector2(i * dishResultGap, 0); DishResultContainer drc = go.GetComponent <DishResultContainer>(); drc.Init(core, i, canControl); dishResultContainerArr[i] = drc; } for (int i = 0; i < CookConst.WORKER_NUM; i++) { GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/workerUnit.prefab", null); WorkerUnit workerUnit = go.GetComponent <WorkerUnit>(); workerArr[i] = workerUnit; workerUnit.Init(core, i); go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/seat.prefab", null); go.transform.SetParent(seatContainer, false); (go.transform as RectTransform).anchoredPosition = new Vector2(i * seatGap, 0); SeatUnit seatUnit = go.GetComponent <SeatUnit>(); seatUnit.Init(core, -i - 1, canControl); seatArr[i] = seatUnit; seatUnit.SetWorker(workerArr[i]); } }
public void RefreshData(PlayerData _playerData) { Clear(); playerData = _playerData; money.text = playerData.money.ToString(); List <DishData> dishDataList = playerData.dish; for (int i = 0; i < dishDataList.Count; i++) { DishData dishData = dishDataList[i]; GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/dish.prefab", null); go.transform.SetParent(dishContainer, false); (go.transform as RectTransform).anchoredPosition = new Vector2(0, -i * dishGap); Dish dish = go.GetComponent <Dish>(); dish.Init(core, dishData, i, canControl); dishList.Add(dish); } DishResult[] dishResultArr = playerData.result; for (int i = 0; i < CookConst.RESULT_STATE.Length; i++) { DishResultContainer dishResultContainer = dishResultContainerArr[i]; dishResultContainer.SetData(dishResultArr); DishResult dishResult = dishResultArr[i]; if (dishResult != null) { GameObject go = GameObjectFactory.Instance.GetGameObject("Assets/Resource/prefab/dishResult.prefab", null); DishResultUnit dishResultUnit = go.GetComponent <DishResultUnit>(); dishResultUnit.Init(core, dishResult); dishResultContainer.SetResult(dishResultUnit); } } for (int i = 0; i < CookConst.WORKER_NUM; i++) { Worker worker = playerData.workers[i]; WorkerUnit workerUnit = workerArr[i]; if (worker.pos < 0) { SeatUnit seat = seatArr[-worker.pos - 1]; seat.SetWorker(workerUnit); } else { dishList[worker.pos].SetWorker(workerUnit); } } }
public void SetWorker(WorkerUnit _workerUnit) { dishWorkerBt.SetWorker(_workerUnit); }