/// <summary>
 /// Returns list view element associated with given photon player
 /// </summary>
 /// <param name="listView">List view element will be searched in this list view</param>
 private ListViewElementPhotonPlayer GetPhotonPlayerListViewElement(ControlListView listView, PhotonPlayer player)
 {
     return(listView.Controls.Find((x) =>
     {
         return x.GetComponent <ListViewElementPhotonPlayer>().Player.ID == player.ID;
     }).GetComponent <ListViewElementPhotonPlayer>());
 }
        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);
        }
示例#3
0
        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;
        }
示例#4
0
        /*Public consts fields*/

        /*Public fields*/

        /*Private methods*/

        private void InitializeWorkersListView(ControlListView listView, List <SharedWorker> workers)
        {
            foreach (SharedWorker singleWorker in workers)
            {
                AddWorkerListViewElement(singleWorker, listView);
            }
        }
        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;
        }
示例#6
0
        private void RemoveWorkerListViewElement(SharedWorker worker, ControlListView listView)
        {
            ListViewElementWorker element = WorkerListViewMap.First(x => x.Key == worker).Value;
            Button buttonComponent        = element.GetComponent <Button>();

            listView.RemoveControl(element.gameObject);
            WorkerListViewMap.Remove(worker);
            WorkersButtonSelector.RemoveButton(buttonComponent);
            worker.SalaryChanged -= OnWorkerSalaryChanged;
        }
        private void RemoveWorkerListViewElement(SharedWorker worker, ControlListView listView)
        {
            if (null != WorkerListViewMap)
            {
                ListViewElementWorker element = WorkerListViewMap[worker];
                Button buttonComponent        = element.Button;

                WorkerListViewMap.Remove(worker);
                WorkersButtonSelector.RemoveButton(buttonComponent);
                listView.RemoveControl(element.gameObject);
            }
        }
        private void RemoveWorkerListViewElement(ListViewElementWorker element, ControlListView listView)
        {
            listView.RemoveControl(element.gameObject, false);
            element.gameObject.SetActive(false);

            if (null == WorkerListViewElementsPool)
            {
                WorkerListViewElementsPool = new ObjectPool <ListViewElementWorker>();
            }

            WorkerListViewElementsPool.AddObject(element);
        }
        /// <summary>
        /// Returns list view element associated with given project
        /// </summary>
        /// <param name="listView">List view element will be searched in this list view</param>
        protected ListViewElementProject GetProjectListViewElement(ControlListView listView, SharedProject proj)
        {
            GameObject             elementObject = null;
            ListViewElementProject element       = null;

            elementObject = listView.Controls.Find(x =>
            {
                return(x.GetComponent <ListViewElementProject>().Project == proj);
            });

            if (null != elementObject)
            {
                element = elementObject.GetComponent <ListViewElementProject>();
            }

            return(element);
        }
示例#10
0
        /// <summary>
        /// Returns list view element representing worker
        /// </summary>
        public static ListViewElementWorker GetWorkerListViewElement(SharedWorker worker, ControlListView listView)
        {
            GameObject elementGameObject = listView.Controls.Find(
                x => x.GetComponent <ListViewElementWorker>().Worker == worker);
            ListViewElementWorker element = null;

            if (null != elementGameObject)
            {
                element = elementGameObject.GetComponent <ListViewElementWorker>();
            }

            return(element);
        }