Пример #1
0
        private void AddPlayerListViewElement(PhotonPlayer player)
        {
            ListViewElementPhotonPlayer element = null;

            if (null != ListViewElementPool)
            {
                element = ListViewElementPool.GetObject();
            }

            if (null == element)
            {
                element = GameObject.Instantiate <ListViewElementPhotonPlayer>(ListViewElementPrefab);
            }
            else
            {
                element.gameObject.SetActive(true);
            }

            ListViewPlayers.AddControl(element.gameObject);

            string buttonText = GetPlayerListViewElementText(player);

            element.Text.text = buttonText;
            element.Player    = player;

            if (false == PhotonNetwork.offlineMode)
            {
                RoomLobbyPlayerState playerState =
                    (RoomLobbyPlayerState)player.CustomProperties[PlayerCustomPropertiesKey.RoomLobbyPlayerState.ToString()];
                SetListViewElementImageColor(element, playerState);
            }
        }
Пример #2
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;
        }
        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);
        }
Пример #4
0
        private void AddLobbbyRoomsButtons()
        {
            foreach (RoomInfo room in PhotonNetwork.GetRoomList())
            {
                ListViewElementRoom element;

                if (null != ListViewElementPool && ListViewElementPool.Count > 0)
                {
                    element = ListViewElementPool.Dequeue();
                    element.gameObject.SetActive(true);
                }
                else
                {
                    element = GameObject.Instantiate <ListViewElementRoom>(ListViewElementPrefab);
                }

                element.Room = room;
                Button buttonComponent = element.GetComponent <Button>();

                string roomStatusText = room.IsOpen ? "In lobby" : "In progress";
                string buttonText     = string.Format("{0} Players: {1}/{2}\nStatus: {3}",
                                                      room.Name,
                                                      room.PlayerCount,
                                                      room.MaxPlayers,
                                                      roomStatusText);
                element.Text.text = buttonText;

                ListViewRooms.AddControl(element.gameObject);
                RoomButtonSelector.AddButton(buttonComponent);
            }
        }
Пример #5
0
        private void OnControlledCompanyProjectAdded(Scrum scrumObj)
        {
            ListViewElementProject newElement = CreateListViewElement(scrumObj.BindedProject);

            ButtonSelectorProjects.AddButton(newElement.GetComponent <Button>());
            ListViewCompanyProjects.AddControl(newElement.gameObject);
            newElement.Text.text = base.GetProjectListViewElementText(scrumObj.BindedProject);

            scrumObj.BindedProject.ProgressUpdated       += OnProjectProgressUpdated;
            scrumObj.BindedProject.Completed             += OnProjectCompleted;
            scrumObj.BindedProject.CompletionTimeUpdated += OnCompanyProjectCompletionTimeUpdated;

            SetListViewCompanyProjectsText();
        }
        private void OnControlledCompanyProjectAdded(Scrum scrumObj)
        {
            ListViewElementProject newElement = CreateListViewElement(scrumObj.BindedProject);

            newElement.Text.text         = GetProjectListViewElementText(scrumObj.BindedProject);
            newElement.FrontImage.sprite = scrumObj.BindedProject.Icon;
            ButtonSelectorProjects.AddButton(newElement.Button);

            ListViewCompanyProjects.AddControl(newElement.gameObject);

            scrumObj.BindedProject.ProgressUpdated += OnProjectProgressUpdated;
            scrumObj.BindedProject.Completed       += OnProjectCompleted;
            scrumObj.BindedProject.WorkerRemoved   += OnProjectWorkerRemoved;
            SetListViewCompanyProjectsText();
        }
        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);
        }
Пример #8
0
        private void OnProjectsMarketProjectAdded(SharedProject proj)
        {
            ListViewElementProject newElement   = CreateListViewElement(proj);
            MousePointerEvents     mousePtrEvts = newElement.GetComponent <MousePointerEvents>();

            mousePtrEvts.PointerDoubleClick += () =>
            {
                OnButtonTakeProjectClicked();
            };

            ButtonSelectorProjects.AddButton(newElement.Button);
            ListViewMarketProjects.AddControl(newElement.gameObject);
            newElement.Text.text         = GetProjectListViewElementText(proj);
            newElement.FrontImage.sprite = proj.Icon;
            SetListViewMarketProjectsText();

            proj.CompletionTimeUpdated += OnMarketProjectCompletionTimeUpdated;
        }