예제 #1
0
        private void updateNearLines(UIPanel parent, bool force = false)
        {
            if (parent != null)
            {
                Transform linesPanelObj = parent.transform.Find("TLMLinesNear");
                if (!linesPanelObj)
                {
                    linesPanelObj = initPanelNearLinesOnWorldInfoPanel(parent);
                }
                var prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic
                                                           | System.Reflection.BindingFlags.Instance);
                ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building;
                if (lastBuildingSelected == buildingId && !force)
                {
                    return;
                }
                else
                {
                    lastBuildingSelected = buildingId;
                }
                Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId];

                List <ushort> nearLines = new List <ushort>();

                TLMLineUtils.GetNearLines(b.CalculateSidewalkPosition(), 120f, ref nearLines);
                bool showPanel = nearLines.Count > 0;
                //				DebugOutputPanel.AddMessage (PluginManager.MessageType.Warning, "nearLines.Count = " + nearLines.Count);
                if (showPanel)
                {
                    foreach (Transform t in linesPanelObj)
                    {
                        if (t.GetComponent <UILabel>() == null)
                        {
                            GameObject.Destroy(t.gameObject);
                        }
                    }
                    Dictionary <string, ushort> lines = TLMLineUtils.SortLines(nearLines);
                    TLMLineUtils.PrintIntersections("", "", "", "", linesPanelObj.GetComponent <UIPanel>(), lines, scale, perLine);
                }
                linesPanelObj.GetComponent <UIPanel>().isVisible = showPanel;
            }
            else
            {
                var go = GameObject.Find("TLMLinesNear");
                if (!go)
                {
                    return;
                }
                Transform linesPanelObj = go.transform;
                linesPanelObj.GetComponent <UIPanel>().isVisible = false;
            }
        }
예제 #2
0
                                : "";// KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_CircleIcon, true);

        private void CreateConnectionPanel(NetManager instance, UIPanel basePanel, ushort currentStop)
        {
            ushort lineID     = GetLineID();
            var    linesFound = new List <ushort>();

            TLMLineUtils.GetNearLines(instance.m_nodes.m_buffer[currentStop].m_position, 150f, ref linesFound);
            linesFound.Remove(lineID);
            UIPanel connectionPanel = basePanel.Find <UIPanel>("ConnectionPanel");

            while (connectionPanel.childCount < linesFound.Count)
            {
                KlyteMonoUtils.CreateUIElement(out UILabel lineLabel, connectionPanel.transform, "", new Vector4(0, 0, 17, 17));
                lineLabel.processMarkup     = true;
                lineLabel.textScale         = 0.5f;
                lineLabel.eventClicked     += OpenLineLabel;
                lineLabel.verticalAlignment = UIVerticalAlignment.Middle;
            }
            while (connectionPanel.childCount > linesFound.Count)
            {
                UIComponent comp = connectionPanel.components[linesFound.Count];
                connectionPanel.components.RemoveAt(linesFound.Count);
                GameObject.Destroy(comp);
                connectionPanel.Invalidate();
            }
            int multiplier = linesFound.Count > m_kMaxConnectionsLine ? 1 : 2;

            for (int i = 0; i < linesFound.Count; i++)
            {
                ushort  line      = linesFound[i];
                UILabel lineLabel = connectionPanel.components[i].GetComponent <UILabel>();
                lineLabel.name    = $"L{line}";
                lineLabel.tooltip = Singleton <TransportManager> .instance.GetLineName(line);

                lineLabel.text           = TLMLineUtils.GetIconString(line);
                lineLabel.stringUserData = line.ToString();
                lineLabel.size           = m_kBasicConnectionLogoSize * multiplier;
                lineLabel.textScale      = m_kBasicConnectionLogoFontSize * multiplier;
            }

            connectionPanel.isVisible = m_currentMode == MapMode.CONNECTIONS;
        }
예제 #3
0
        Vector3 getStation(ushort lineId, ushort stopId, ItemClass.SubService ss, out string stationName, out List <ushort> linhas, out string airport, out string harbor, out string taxiStand, out string regionalTrainStation, out string cableCarStation, out string prefix)
        {
            NetManager      nm = Singleton <NetManager> .instance;
            BuildingManager bm = Singleton <BuildingManager> .instance;
            NetNode         nn = nm.m_nodes.m_buffer[(int)stopId];

            stationName = TLMLineUtils.getStationName(stopId, lineId, ss, out ItemClass.Service servFound, out ItemClass.SubService subServFound, out prefix, out ushort buildingId);

            //paradas proximas (metro e trem)
            TransportManager tm           = Singleton <TransportManager> .instance;
            TransportInfo    thisLineInfo = tm.m_lines.m_buffer[(int)nn.m_transportLine].Info;
            TransportLine    thisLine     = tm.m_lines.m_buffer[(int)nn.m_transportLine];

            linhas = new List <ushort>();
            Vector3 location = nn.m_position;

            if (buildingId > 0 && ss == subServFound)
            {
                location = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].CalculateSidewalkPosition();
            }
            TLMLineUtils.GetNearLines(location, 120f, ref linhas);

            airport              = String.Empty;
            taxiStand            = String.Empty;
            harbor               = String.Empty;
            regionalTrainStation = String.Empty;
            cableCarStation      = string.Empty;

            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.TRAIN_SHOW_IN_LINEAR_MAP))
            {
                ushort trainStation = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrain, null, Building.Flags.None, Building.Flags.Untouchable | Building.Flags.Downgrading);

                if (trainStation > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building         = trainStation;
                    regionalTrainStation = bm.GetBuildingName(trainStation, iid);
                }
            }

            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.PLANE_SHOW_IN_LINEAR_MAP))
            {
                ushort airportId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane, new TransferManager.TransferReason[] { TransferManager.TransferReason.PassengerPlane }, Building.Flags.None, Building.Flags.Untouchable);

                if (airportId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building = airportId;
                    airport      = bm.GetBuildingName(airportId, iid);
                }
            }

            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.SHIP_SHOW_IN_LINEAR_MAP))
            {
                ushort harborId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip, new TransferManager.TransferReason[] { TransferManager.TransferReason.PassengerShip }, Building.Flags.None, Building.Flags.Untouchable);

                if (harborId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building = harborId;
                    harbor       = bm.GetBuildingName(harborId, iid);
                }
            }
            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.TAXI_SHOW_IN_LINEAR_MAP))
            {
                ushort taxiId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 50f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTaxi, null, Building.Flags.None, Building.Flags.Untouchable);

                if (taxiId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building = taxiId;
                    taxiStand    = bm.GetBuildingName(taxiId, iid);
                }
            }
            if (TLMCW.getCurrentConfigBool(TLMCW.ConfigIndex.CABLE_CAR_SHOW_IN_LINEAR_MAP))
            {
                ushort cableCarId = TLMUtils.FindBuilding(location != Vector3.zero ? location : nn.m_position, 120f, ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportCableCar, null, Building.Flags.None, Building.Flags.Untouchable);

                if (cableCarId > 0)
                {
                    InstanceID iid = default(InstanceID);
                    iid.Building    = cableCarId;
                    cableCarStation = bm.GetBuildingName(cableCarId, iid);
                }
            }


            return(location);
        }