Beispiel #1
0
        private void AddVehicleToLinearMap(Color lineColor, ushort vehicleId)
        {
            UILabel vehicleLabel = null;
            int     fill, cap;

            TLMLineUtils.GetVehicleCapacityAndFill(vehicleId, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId], out fill, out cap);

            TLMUtils.createUIElement <UILabel>(ref vehicleLabel, lineStationsPanel.transform);
            vehicleLabel.autoSize          = false;
            vehicleLabel.text              = string.Format("{0}/{1}", fill, cap);
            vehicleLabel.useOutline        = true;
            vehicleLabel.width             = 50;
            vehicleLabel.height            = 33;
            vehicleLabel.pivot             = UIPivotPoint.TopCenter;
            vehicleLabel.verticalAlignment = UIVerticalAlignment.Middle;
            vehicleLabel.atlas             = TLMController.taLineNumber;

            vehicleLabel.padding          = new RectOffset(0, 0, 2, 0);
            vehicleLabel.textScale        = 0.6f;
            vehicleLabel.backgroundSprite = "VehicleLinearMap";
            vehicleLabel.color            = lineColor;
            vehicleLabel.textAlignment    = UIHorizontalAlignment.Center;
            vehicleLabel.tooltip          = Singleton <VehicleManager> .instance.GetVehicleName(vehicleId);

            vehicleLabel.eventClick += (x, y) =>
            {
                InstanceID id = default(InstanceID);
                id.Vehicle = vehicleId;
                Camera.main.GetComponent <CameraController>().SetTarget(id, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId].GetLastFramePosition(), true);
            };
            updateVehiclePosition(vehicleId, vehicleLabel);

            lineVehicles.Add(vehicleId, vehicleLabel);
        }
        public void updateBidings()
        {
            if (showExtraStopInfo)
            {
                foreach (var resLabel in residentCounters)
                {
                    TLMLineUtils.GetQuantityPassengerWaiting(resLabel.Key, out int residents, out int tourists, out int ttb);
                    resLabel.Value.text = residents.ToString();
                    touristCounters[resLabel.Key].text = tourists.ToString();
                    ttbTimers[resLabel.Key].text       = ttb.ToString();
                    ttbTimers[resLabel.Key].color      = getColorForTTB(ttb);
                }
                ushort        lineID       = parent.CurrentSelectedId;
                TransportLine t            = TLMController.instance.tm.m_lines.m_buffer[(int)lineID];
                Color         lineColor    = TLMController.instance.tm.GetLineColor(lineID);
                int           vehicleCount = t.CountVehicles(lineID);
                List <ushort> oldItems     = lineVehicles.Keys.ToList();
                vehiclesOnStation.Clear();
                for (int v = 0; v < vehicleCount; v++)
                {
                    ushort  vehicleId    = t.GetVehicle(v);
                    UILabel vehicleLabel = null;

                    if (oldItems.Contains(vehicleId))
                    {
                        vehicleLabel = lineVehicles[vehicleId];
                        TLMLineUtils.GetVehicleCapacityAndFill(vehicleId, Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId], out int fill, out int cap);
                        vehicleLabel.text = string.Format("{0}/{1}", fill, cap);
                        var labelStation = residentCounters[Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId].m_targetBuilding];
                        updateVehiclePosition(vehicleLabel);
                        oldItems.Remove(vehicleId);
                    }
                    else
                    {
                        AddVehicleToLinearMap(lineColor, vehicleId);
                    }
                }
                foreach (ushort dead in oldItems)
                {
                    GameObject.Destroy(lineVehicles[dead].gameObject);
                    lineVehicles.Remove(dead);
                }
            }
        }