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; }
public bool CreateUserEvent(int ticketsAvailable, float entryCost, List <IncentiveOptionItem> incentives, DateTime startTime) { bool created = false; if (!CityEventManager.instance.EventStartsBetween(startTime, startTime.AddHours(GetEventLength()) - startTime)) { LoggingWrapper.Log("Creating user event"); m_eventData.m_eventStartTime = startTime; m_eventData.m_eventFinishTime = startTime.AddHours(GetEventLength()); m_eventData.m_entryCost = entryCost; m_eventData.m_userTickets = ticketsAvailable; m_eventData.m_userEvent = true; LoggingWrapper.Log("Adding incentives"); if (m_eventData.m_incentives != null) { foreach (CityEventDataIncentives dataIncentive in m_eventData.m_incentives) { LoggingWrapper.Log("Adding incentive " + dataIncentive.name); IncentiveOptionItem foundIncentive = incentives.Find(match => match.title == dataIncentive.name); if (foundIncentive != null) { LoggingWrapper.Log("Setting up incentive " + dataIncentive.name); dataIncentive.itemCount = Mathf.RoundToInt(foundIncentive.sliderValue); dataIncentive.returnCost = foundIncentive.returnCost; } else { LoggingWrapper.LogWarning("Couldn't find the IncentiveOptionItem that matches " + dataIncentive.name); } } TakeInitialAmount(); created = true; } else { LoggingWrapper.LogWarning("There are no incentives for " + m_eventData.m_eventName + ". Skipping"); } } else { LoggingWrapper.LogWarning("Event clashes with another event."); } return(created); }
public void Display(object data, bool isRowOdd) { if (data != null) { IncentiveOptionItem option = data as IncentiveOptionItem; Initialise(); if (option != null && option.title != null && option.title != "" && background != null) { currentOption = option; background.width = width; background.height = height; background.relativePosition = Vector2.zero; background.zOrder = 0; amount.isInteractive = true; amount.value = option.sliderValue; amount.maxValue = option.ticketCount; amount.width = width - ((width * 40f) / 100f); UIPanel sliderPanel = amount.parent as UIPanel; sliderPanel.relativePosition = new Vector2(5, 5); sliderPanel.width = amount.width; UILabel sliderLabel = sliderPanel.Find <UILabel>("Label"); sliderLabel.tooltip = option.description; sliderLabel.textScale = 0.8f; sliderLabel.processMarkup = true; totalsPanel.relativePosition = new Vector3(sliderPanel.relativePosition.x + sliderPanel.width + 5, 5); totalsPanel.width = width - totalsPanel.relativePosition.x - 15; totalsPanel.height = height - 10; totalsPanel.atlas = CimTools.CimToolsHandler.CimToolBase.SpriteUtilities.GetAtlas("Ingame"); totalsPanel.backgroundSprite = "GenericPanel"; totalsPanel.color = new Color32(91, 97, 106, 255); effects.autoSize = false; effects.autoHeight = false; effects.width = totalsPanel.width; effects.height = 20; effects.relativePosition = new Vector2(0, totalsPanel.height - effects.height); effects.textScale = 0.6f; effects.padding = new RectOffset(5, 5, 5, 5); effects.name = "Effects"; effects.processMarkup = true; effects.text = string.Format("<sprite NotificationIconHappy> {0}% <sprite NotificationIconNotHappy> {1}%", option.positiveEffect, option.negativeEffect); effects.textAlignment = UIHorizontalAlignment.Center; effects.verticalAlignment = UIVerticalAlignment.Middle; costsLabel.relativePosition = Vector3.zero; costsLabel.autoSize = false; costsLabel.autoHeight = false; costsLabel.width = 40; costsLabel.height = (totalsPanel.height / 2f) - (effects.height / 2f); costsLabel.name = "CostsLabel"; costsLabel.textScale = 0.6f; costsLabel.padding = new RectOffset(4, 4, 4, 4); costsLabel.textAlignment = UIHorizontalAlignment.Left; costsLabel.verticalAlignment = UIVerticalAlignment.Middle; costsLabel.textColor = new Color32(255, 100, 100, 255); costsLabel.color = new Color32(91, 97, 106, 255); returnsLabel.relativePosition = new Vector3(0, (totalsPanel.height / 2f) - (effects.height / 2f)); returnsLabel.autoSize = false; returnsLabel.autoHeight = false; returnsLabel.width = 40; returnsLabel.height = (totalsPanel.height / 2f) - (effects.height / 2f); returnsLabel.name = "ReturnsLabel"; returnsLabel.textScale = 0.6f; returnsLabel.padding = new RectOffset(4, 4, 4, 4); returnsLabel.textAlignment = UIHorizontalAlignment.Left; returnsLabel.verticalAlignment = UIVerticalAlignment.Middle; returnsLabel.textColor = new Color32(206, 248, 0, 255); returnsLabel.color = new Color32(91, 97, 106, 255); costsReadout.relativePosition = costsLabel.relativePosition + new Vector3(costsLabel.width + 5, 1); costsReadout.autoSize = false; costsReadout.autoHeight = false; costsReadout.width = totalsPanel.width - costsReadout.relativePosition.x - 5; costsReadout.height = costsLabel.height - 2; costsReadout.atlas = CimTools.CimToolsHandler.CimToolBase.SpriteUtilities.GetAtlas("Ingame"); costsReadout.backgroundSprite = "TextFieldPanel"; costsReadout.name = "Cost"; costsReadout.textScale = 0.6f; costsReadout.textAlignment = UIHorizontalAlignment.Right; costsReadout.verticalAlignment = UIVerticalAlignment.Middle; costsReadout.textColor = new Color32(238, 95, 0, 255); costsReadout.color = new Color32(45, 52, 61, 255); returnsReadout.relativePosition = returnsLabel.relativePosition + new Vector3(returnsLabel.width + 5, 1); returnsReadout.autoSize = false; returnsReadout.autoHeight = false; returnsReadout.width = totalsPanel.width - returnsReadout.relativePosition.x - 5; returnsReadout.height = returnsLabel.height - 2; returnsReadout.atlas = CimTools.CimToolsHandler.CimToolBase.SpriteUtilities.GetAtlas("Ingame"); returnsReadout.backgroundSprite = "TextFieldPanel"; returnsReadout.name = "Returns"; returnsReadout.textScale = 0.6f; returnsReadout.textAlignment = UIHorizontalAlignment.Right; returnsReadout.verticalAlignment = UIVerticalAlignment.Middle; returnsReadout.textColor = new Color32(151, 238, 0, 255); returnsReadout.color = new Color32(45, 52, 61, 255); option.OnTicketSizeChanged += Option_OnTicketSizeChanged; /*title.name = option.title; * title.text = option.title; * title.autoSize = false; * title.relativePosition = new Vector2(0, 0); * title.width = width - ((width * 40) / 100); * title.height = sliderPanel.relativePosition.y; * title.textScale = 1f; * title.padding = new RectOffset(5, 5, 5, 5); * title.tooltip = option.description;*/ Deselect(isRowOdd); UpdateTotals(); UpdateVariableStrings(); Translation_OnLanguageChanged("Manual Call!"); } } }