예제 #1
0
        public void SetUp(LabelOptionItem selectedData, ushort buildingID)
        {
            _linkedEvent = selectedData.linkedEvent;

            if (_linkedEvent != null && buildingID != 0 && _ticketSlider != null)
            {
                List <CityEventXmlIncentive> incentives = _linkedEvent.GetIncentives();

                title = _linkedEvent.GetReadableName();

                _ticketSlider.maxValue = _linkedEvent.GetCapacity();
                _ticketSlider.minValue = Mathf.Min(_linkedEvent.GetCapacity(), 100);
                _ticketSlider.value    = _ticketSlider.minValue;

                _incentiveList.rowsData.Clear();

                foreach (CityEventXmlIncentive incentive in incentives)
                {
                    IncentiveOptionItem optionItem = new IncentiveOptionItem()
                    {
                        cost           = incentive._cost,
                        description    = incentive._description,
                        negativeEffect = incentive._negativeEffect,
                        positiveEffect = incentive._positiveEffect,
                        returnCost     = incentive._returnCost,
                        title          = incentive._name,
                        ticketCount    = _ticketSlider.value
                    };
                    optionItem.OnOptionItemChanged += OptionItem_OnOptionItemChanged;

                    _incentiveList.rowsData.Add(optionItem);
                }

                try
                {
                    _incentiveList.DisplayAt(0);
                    _incentiveList.selectedIndex = 0;
                    _incentiveList.Show();
                }
                catch
                {
                    LoggingWrapper.LogError("IncentiveList DisplayAt hit an error. Probably too few items in the list.");
                }

                _incentiveList.Refresh();

                CalculateTotal();
                TranslateInfoString();
                PerformLayout();

                LoggingWrapper.Log("Event capacity is " + _linkedEvent.GetCapacity().ToString() + ".");
                LoggingWrapper.Log("Successfully set up the UserEventCreationWindow.");
            }
            else
            {
                LoggingWrapper.LogError("Linked event was invalid, or the building was 0!");
            }

            relativePosition = Vector3.zero;
        }
예제 #2
0
        private static void CreateEventButton_eventClicked(UIComponent component, UIMouseEventParameter eventParam)
        {
            UIFastList eventSelection = component.parent.Find <UIFastList>("EventSelectionList");
            ushort     buildingID     = lastInstanceID.Value.Building;

            if (lastInstanceID != null && buildingID != 0)
            {
                BuildingManager _buildingManager = Singleton <BuildingManager> .instance;
                Building        _currentBuilding = _buildingManager.m_buildings.m_buffer[buildingID];

                if ((_currentBuilding.m_flags & Building.Flags.Active) != Building.Flags.None)
                {
                    List <CityEvent> userEvents = CityEventBuildings.instance.GetUserEventsForBuilding(ref _currentBuilding);

                    BuildDropdownList(component);

                    if (eventSelection.isVisible)
                    {
                        eventSelection.Hide();
                    }
                    else
                    {
                        eventSelection.selectedIndex = -1;
                        eventSelection.Show();
                        eventSelection.rowsData.Clear();

                        foreach (CityEvent userEvent in userEvents)
                        {
                            XmlEvent xmlUserEvent = userEvent as XmlEvent;

                            if (xmlUserEvent != null)
                            {
                                xmlUserEvent.SetUp(ref buildingID);
                                LabelOptionItem eventToInsert = new LabelOptionItem()
                                {
                                    linkedEvent = xmlUserEvent, readableLabel = xmlUserEvent.GetReadableName()
                                };
                                eventSelection.rowsData.Add(eventToInsert);

                                LoggingWrapper.Log(xmlUserEvent.GetReadableName());
                            }
                        }

                        eventSelection.DisplayAt(0);
                    }
                }
            }
        }