コード例 #1
0
        public RoadManager.VehicleType GetCurrentVehicleRestrictions()
        {
            if (!AnyLaneSelected)
            {
                return(RoadManager.VehicleType.None);
            }

            return(RoadManager.GetVehicleRestrictions(m_selectedLaneMarkers[0].m_lane));
        }
コード例 #2
0
        public RoadManager.VehicleType ToggleRestriction(RoadManager.VehicleType vehicleType)
        {
            if (!AnyLaneSelected)
            {
                return(RoadManager.VehicleType.None);
            }

            RoadManager.VehicleType vehicleRestrictions = RoadManager.GetVehicleRestrictions(m_selectedLaneMarkers[0].m_lane);
            vehicleRestrictions ^= vehicleType;

            foreach (SegmentLaneMarker lane in m_selectedLaneMarkers)
            {
                RoadManager.SetVehicleRestrictions(lane.m_lane, vehicleRestrictions);
            }

            return(vehicleRestrictions);
        }
コード例 #3
0
        protected override void OnToolGUI()
        {
            base.OnToolGUI();

            if (m_toolButton == null)
            {
                m_toolButton = TryCreateToolButton();
            }

            if (m_selectedLaneMarkers.Count == 0)
            {
                return;
            }

            if (screenWidth != Screen.width || screenHeight != Screen.height)
            {
                screenWidth        = Screen.width;
                screenHeight       = Screen.height;
                laneButtonsStart   = (700 * screenHeight) / 1080;
                laneButtonsWidth   = 150;                        // font doesn't scale, so width must remain the same for every resolution
                laneButtonsHeight  = (20 * screenHeight) / 1080; // only causes problems in very low resolutions
                laneButtonsSpacing = (5 * screenHeight) / 1080;
            }

            RoadManager.VehicleType vehicleRestrictions = RoadManager.GetVehicleRestrictions(m_selectedLaneMarkers[0].m_lane);
            bool apply = false;
            int  i     = 1;

            if (GUI.Button(new Rect(10, laneButtonsStart, laneButtonsWidth, laneButtonsHeight), "Ambulances: " + ((vehicleRestrictions & RoadManager.VehicleType.Ambulance) == RoadManager.VehicleType.Ambulance ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.Ambulance;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Bus: " + ((vehicleRestrictions & RoadManager.VehicleType.Bus) == RoadManager.VehicleType.Bus ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.Bus;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Cargo Trucks: " + ((vehicleRestrictions & RoadManager.VehicleType.CargoTruck) == RoadManager.VehicleType.CargoTruck ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.CargoTruck;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Fire Trucks: " + ((vehicleRestrictions & RoadManager.VehicleType.FireTruck) == RoadManager.VehicleType.FireTruck ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.FireTruck;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Garbage Trucks: " + ((vehicleRestrictions & RoadManager.VehicleType.GarbageTruck) == RoadManager.VehicleType.GarbageTruck ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.GarbageTruck;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Hearses: " + ((vehicleRestrictions & RoadManager.VehicleType.Hearse) == RoadManager.VehicleType.Hearse ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.Hearse;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Citizens: " + ((vehicleRestrictions & RoadManager.VehicleType.PassengerCar) == RoadManager.VehicleType.PassengerCar ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.PassengerCar;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Police: " + ((vehicleRestrictions & RoadManager.VehicleType.PoliceCar) == RoadManager.VehicleType.PoliceCar ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.PoliceCar;
                apply = true;
            }
            if (GUI.Button(new Rect(10, laneButtonsStart + (laneButtonsHeight + laneButtonsSpacing) * i++, laneButtonsWidth, laneButtonsHeight), "Emergency: " + ((vehicleRestrictions & RoadManager.VehicleType.Emergency) == RoadManager.VehicleType.Emergency ? "On" : "Off")))
            {
                vehicleRestrictions ^= RoadManager.VehicleType.Emergency;
                apply = true;
            }

            if (apply)
            {
                foreach (SegmentLaneMarker lane in m_selectedLaneMarkers)
                {
                    RoadManager.SetVehicleRestrictions(lane.m_lane, vehicleRestrictions);
                }
            }
        }