private void AddWorkerListViewElement(SharedWorker playerWorker, ControlListView listView) { ListViewElementWorker element = UIWorkers.CreateWorkerListViewElement(playerWorker, WorkerListViewElementPrefab, TooltipComponent); Button buttonComponent = element.GetComponent <Button>(); if (null == WorkerListViewMap) { WorkerListViewMap = new Dictionary <SharedWorker, ListViewElementWorker>(); } if (listView == ListViewOtherPlayersWorkers) { MousePointerEvents mouseEvts = element.GetComponent <MousePointerEvents>(); mouseEvts.PointerDoubleClick += () => { if (true == SimulationManagerComponent.ControlledCompany.CanHireWorker) { OnButtonHireWorkerClick(); } }; } WorkerListViewMap.Add(playerWorker, element); listView.AddControl(element.gameObject); WorkersButtonSelector.AddButton(buttonComponent); }
private void AddWorkerListViewElement(SharedWorker worker, ControlListView listView) { ListViewElementWorker element = UIWorkers.CreateWorkerListViewElement(worker, WorkerListViewElementPrefab, TooltipComponent); Button buttonComponent = element.GetComponent <Button>(); MousePointerEvents mousePtrEvts = element.GetComponent <MousePointerEvents>(); mousePtrEvts.PointerDoubleClick += () => { if (listView == ListViewMarketWorkers && true == SimulationManagerComponent.ControlledCompany.CanHireWorker) { OnHireWorkerButtonClicked(); } }; if (null == WorkerListViewMap) { WorkerListViewMap = new Dictionary <SharedWorker, ListViewElementWorker>(); } listView.AddControl(element.gameObject); WorkerListViewMap.Add(worker, element); WorkersButtonSelector.AddButton(buttonComponent); worker.SalaryChanged += OnWorkerSalaryChanged; }
private void SetWorkerAbilitiesText() { TextAbilities.text = UIWorkers.GetWorkerAbilitiesString(SelectedWorker); RectTransform transform = TextAbilities.transform.parent.GetComponent <RectTransform>(); Vector2 newSize = new Vector2(transform.rect.width, TextAbilities.preferredHeight); transform.sizeDelta = newSize; }
private void RemoveWorkerListViewElement(SharedWorker companyWorker) { LocalWorker worker = (LocalWorker)companyWorker; ControlListViewDrop workerListView = (null == worker.AssignedProject) ? ListViewAvailableWorkers : ListViewAssignedWorkers; ListViewElementWorker listViewElement = UIWorkers.GetWorkerListViewElement(companyWorker, workerListView); RemoveWorkerListViewElement(listViewElement, workerListView); }
private void RemoveWorkerListViewElement(LocalWorker worker, ControlListView listView) { ListViewElementWorker element = UIWorkers.GetWorkerListViewElement(worker, listView); Button buttonComponent = element.GetComponent <Button>(); WorkersButtonsSelector.RemoveButton(buttonComponent); ListViewWorkers.RemoveControl(element.gameObject); worker.SatisfactionChanged -= OnWorkerSatisfactionChanged; }
/*Public consts fields*/ /*Public fields*/ /*Private methods*/ /// <summary> /// Set values of text component with information about worker /// </summary> private void SetWorkerText() { TextName.text = UIWorkers.GetWorkerNameString(SelectedWorker); SetWorkerAbilitiesText(); TextSalary.text = UIWorkers.GetWorkerSalaryString(SelectedWorker); TextExpierience.text = UIWorkers.GetWorkerExpierienceString(SelectedWorker); TextDaysInCompany.text = UIWorkers.GetWorkerDaysInCompanyString(SelectedWorker); TextSatisfaction.text = UIWorkers.GetWorkerSatisfactionString(SelectedWorker); }
private void OnGameTimeDayChanged() { if (null != WorkerListViewMap) { foreach (KeyValuePair <SharedWorker, ListViewElementWorker> pair in WorkerListViewMap) { pair.Value.Text.text = UIWorkers.GetWorkerListViewElementText(pair.Key); } } }
private void OnProjectWorkerRemoved(SharedWorker companyWorker) { ListViewElementWorker element = UIWorkers.GetWorkerListViewElement(companyWorker, ListViewAssignedWorkers); //Check if list view element was dragged to other list view if (null != element) { RemoveWorkerListViewElement(element, ListViewAssignedWorkers); ListViewElementWorker newElement = CreateWorkerListViewElement((LocalWorker)companyWorker); ListViewAvailableWorkers.AddControl(newElement.gameObject); } SetListViewAssignedWorkersText(); SetListViewAvailableWorkersText(); SetProjectInfo(); }
private ListViewElementWorker CreateWorkerListViewElement(LocalWorker companyWorker) { ListViewElementWorker element = UIWorkers.CreateWorkerListViewElement(companyWorker, WorkerListViewElementPrefab, TooltipComponent); element.Text.text = GetWorkerListViewElementText(companyWorker); Button buttonComponent = element.GetComponent <Button>(); WorkersButtonsSelector.AddButton(buttonComponent); ListViewWorkers.AddControl(element.gameObject); //List view element contains information about satisfaction so it should be updated whenever it changes companyWorker.SatisfactionChanged += OnWorkerSatisfactionChanged; return(element); }
private void SetWorkerInfoText(SharedWorker selectedWorker) { if (null != selectedWorker) { TextName.text = UIWorkers.GetWorkerNameString(selectedWorker); TextSalary.text = UIWorkers.GetWorkerSalaryString(selectedWorker); TextExpierience.text = UIWorkers.GetWorkerExpierienceString(selectedWorker); TextAbilities.text = UIWorkers.GetWorkerAbilitiesString(selectedWorker); RectTransform textTransform = TextAbilities.rectTransform.parent.GetComponent <RectTransform>(); textTransform.sizeDelta = new Vector2(textTransform.sizeDelta.x, TextAbilities.preferredHeight); } else { TextName.text = string.Empty; TextSalary.text = string.Empty; TextAbilities.text = string.Empty; TextExpierience.text = string.Empty; } }
private void OnWorkerSalaryChanged(SharedWorker companyWorker) { if (null != SelectedWorker && companyWorker.ID == SelectedWorker.ID) { TextSalary.text = UIWorkers.GetWorkerSalaryString(companyWorker); } ListViewElementWorker elem = null; if (companyWorker is LocalWorker) { elem = UIWorkers.GetWorkerListViewElement(companyWorker, ListViewCompanyWorkers); } else { elem = UIWorkers.GetWorkerListViewElement(companyWorker, ListViewOtherPlayersWorkers); } elem.Text.text = UIWorkers.GetWorkerListViewElementText(companyWorker); }
private ListViewElementWorker CreateWorkerListViewElement(LocalWorker companyWorker) { ListViewElementWorker newElement = null; if (null != WorkerListViewElementsPool) { newElement = WorkerListViewElementsPool.GetObject(); } if (null == newElement) { newElement = UIWorkers.CreateWorkerListViewElement(companyWorker, ListViewWorkerElementPrefab, TooltipComponent); UIElementDrag drag = newElement.GetComponent <UIElementDrag>(); drag.DragParentTransform = gameObject.GetComponent <RectTransform>(); } newElement.gameObject.SetActive(true); newElement.Text.text = GetWorkerListViewElementText(companyWorker); newElement.Worker = companyWorker; return(newElement); }
private void OnProjectListViewSelectedElementChanged(Button btn) { if (null != SelectedScrum) { UnsubscribeProjectEvents(); foreach (LocalWorker worker in SelectedScrum.BindedProject.Workers) { ListViewElementWorker element = UIWorkers.GetWorkerListViewElement(worker, ListViewAssignedWorkers); element.gameObject.SetActive(false); } } if (null != btn) { ListViewElementProject element = btn.GetComponent <ListViewElementProject>(); SelectedScrum = SimulationManagerComponent.ControlledCompany.ScrumProcesses.Find(x => { return(element.Project == x.BindedProject); }); SetProjectInfo(); SubscribeProjectEvents(); SetListViewAssignedWorkersText(); ListViewAssignedWorkers.transform.parent.gameObject.SetActive(true); foreach (LocalWorker worker in SelectedScrum.BindedProject.Workers) { ListViewElementWorker elem = UIWorkers.GetWorkerListViewElement(worker, ListViewAssignedWorkers); elem.gameObject.SetActive(true); } } else { SelectedScrum = null; SetProjectInfo(); ListViewAssignedWorkers.transform.parent.gameObject.SetActive(false); } }
private void SetWorkerInfoText(SharedWorker selectedWorker) { if (null != selectedWorker) { TextName.gameObject.SetActive(true); TextSalary.gameObject.SetActive(true); TextAbilities.gameObject.SetActive(true); TextExpierience.gameObject.SetActive(true); TextName.text = UIWorkers.GetWorkerNameString(selectedWorker); SetWorkerSalaryText(selectedWorker); TextExpierience.text = UIWorkers.GetWorkerExpierienceString(selectedWorker); TextAbilities.text = UIWorkers.GetWorkerAbilitiesString(selectedWorker); RectTransform textObjectTransform = TextAbilities.transform.parent.GetComponent <RectTransform>(); textObjectTransform.sizeDelta = new Vector2(textObjectTransform.sizeDelta.x, TextAbilities.preferredHeight); } else { TextName.gameObject.SetActive(false); TextSalary.gameObject.SetActive(false); TextAbilities.gameObject.SetActive(false); TextExpierience.gameObject.SetActive(false); } }
private void OnWorkerSatisfactionChanged(SharedWorker companyWorker) { ListViewElementWorker element = UIWorkers.GetWorkerListViewElement(companyWorker, ListViewWorkers); element.Text.text = GetWorkerListViewElementText((LocalWorker)companyWorker); }
private void OnSelectedWorkerExpierienceTimeChanged(SharedWorker companyWorker) { TextExpierience.text = UIWorkers.GetWorkerExpierienceString(companyWorker); }
private void SetWorkerSalaryText(SharedWorker selectedWorker) { TextSalary.text = UIWorkers.GetWorkerSalaryString(selectedWorker); }
private void OnCompanyWorkerSatisfactionChanged(SharedWorker worker) { TextSatisfaction.text = UIWorkers.GetWorkerSatisfactionString((LocalWorker)worker); }
private void SetCompanyWorkersListViewText() { TextCompanyWorkerListView.text = UIWorkers.GetCompanyWorkersListViewString(SimulationManagerComponent.ControlledCompany); }
private void OnCompanyWorkerDaysInCompanyChanged(SharedWorker companyWorker) { TextDaysInCompany.text = UIWorkers.GetWorkerDaysInCompanyString((LocalWorker)companyWorker); }
private void OnWorkerSalaryChanged(SharedWorker companyWorker) { ListViewElementWorker el = WorkerListViewMap[companyWorker]; el.Text.text = UIWorkers.GetWorkerListViewElementText(companyWorker); }
private void OnCompanyWorkerSalaryChanged(SharedWorker companyWorker) { TextSalary.text = UIWorkers.GetWorkerSalaryString(companyWorker); }