Example #1
0
 public EntryLane(TrafficPattern pattern)
 {
     EntryPosition = pattern.Position;
     Pattern       = pattern;
     CarsToSpawn   = new List <Car>();
     QueuedCars    = new List <Car>();
     PopulateCarsToSpawn();
 }
Example #2
0
 public EntryLane(TrafficPattern pattern)
 {
     EntryPosition = pattern.Position;
     Pattern = pattern;
     CarsToSpawn = new List<Car>();
     QueuedCars = new List<Car>();
     PopulateCarsToSpawn();
 }
Example #3
0
 public Car(int entryTime, EntryPosition from, EntryPosition to)
 {
     Id          = Tools.NexCarId;
     EntryTime   = entryTime;
     From        = from;
     To          = to;
     Color       = Tools.GetRandomBrush();
     TimeWaiting = 0;
 }
Example #4
0
 public Car(int entryTime, EntryPosition from, EntryPosition to)
 {
     Id = Tools.NexCarId;
     EntryTime = entryTime;
     From = from;
     To = to;
     Color = Tools.GetRandomBrush();
     TimeWaiting = 0;
 }
 public TrafficPattern(EntryPosition position, int carsPerMin, int toNorthPerc, int toEastPerc, int toSouthPerc, int toWestPerc)
 {
     Position = position;
     CarsPerMin = carsPerMin;
     ToNorthPerc = toNorthPerc;
     ToEastPerc = toEastPerc;
     ToSouthPerc = toSouthPerc;
     ToWestPerc = toWestPerc;
 }
Example #6
0
 public TrafficPattern(EntryPosition position, int carsPerMin, int toNorthPerc, int toEastPerc, int toSouthPerc, int toWestPerc)
 {
     Position    = position;
     CarsPerMin  = carsPerMin;
     ToNorthPerc = toNorthPerc;
     ToEastPerc  = toEastPerc;
     ToSouthPerc = toSouthPerc;
     ToWestPerc  = toWestPerc;
 }
Example #7
0
        public TrafficPattern(EntryPosition position)
        {
            CarsPerMin = 10;
            Position   = position;
            switch (Position)
            {
            case EntryPosition.North:
                ToNorthPerc = 10;
                ToEastPerc  = 30;
                ToSouthPerc = 30;
                ToWestPerc  = 30;
                break;

            case EntryPosition.West:
                ToNorthPerc = 30;
                ToEastPerc  = 30;
                ToSouthPerc = 30;
                ToWestPerc  = 10;
                break;

            case EntryPosition.South:
                ToNorthPerc = 30;
                ToEastPerc  = 30;
                ToSouthPerc = 10;
                ToWestPerc  = 30;
                break;

            case EntryPosition.East:
                ToNorthPerc = 30;
                ToEastPerc  = 10;
                ToSouthPerc = 30;
                ToWestPerc  = 30;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            ToWestPerc  += ToNorthPerc;
            ToSouthPerc += ToWestPerc;
            ToEastPerc  += ToSouthPerc;
            if (ToEastPerc != 100)
            {
                MessageBox.Show($"Percentages don't add up to 100 for {position}");
                throw new ArgumentOutOfRangeException($"Percentages don't add up to 100 for {position}");
            }
        }
Example #8
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.InsertSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(ChildStatesName, ChildStates.ExportYAML(container));
            node.Add(ChildStateMachinesName, ChildStateMachines.ExportYAML(container));
            node.Add(AnyStateTransitionsName, AnyStateTransitions.ExportYAML(container));
            node.Add(EntryTransitionsName, EntryTransitions.ExportYAML(container));
            node.Add(StateMachineTransitionsName, StateMachineTransitions.ExportYAML(container));
            node.Add(StateMachineBehavioursName, StateMachineBehaviours.ExportYAML(container));
            node.Add(AnyStatePositionName, AnyStatePosition.ExportYAML(container));
            node.Add(EntryPositionName, EntryPosition.ExportYAML(container));
            node.Add(ExitPositionName, ExitPosition.ExportYAML(container));
            node.Add(ParentStateMachinePositionName, ParentStateMachinePosition.ExportYAML(container));
            node.Add(DefaultStateName, DefaultState.ExportYAML(container));
            return(node);
        }
Example #9
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.InsertSerializedVersion(GetSerializedVersion(container.Version));
            node.Add("m_ChildStates", ChildStates.ExportYAML(container));
            node.Add("m_ChildStateMachines", ChildStateMachines.ExportYAML(container));
            node.Add("m_AnyStateTransitions", AnyStateTransitions.ExportYAML(container));
            node.Add("m_EntryTransitions", EntryTransitions.ExportYAML(container));
            node.Add("m_StateMachineTransitions", StateMachineTransitions.ExportYAMLArrayPPtr(container));
            node.Add("m_StateMachineBehaviours", StateMachineBehaviours.ExportYAML(container));
            node.Add("m_AnyStatePosition", AnyStatePosition.ExportYAML(container));
            node.Add("m_EntryPosition", EntryPosition.ExportYAML(container));
            node.Add("m_ExitPosition", ExitPosition.ExportYAML(container));
            node.Add("m_ParentStateMachinePosition", ParentStateMachinePosition.ExportYAML(container));
            node.Add("m_DefaultState", DefaultState.ExportYAML(container));
            return(node);
        }
Example #10
0
        protected override YAMLMappingNode ExportYAMLRoot()
        {
            YAMLMappingNode node = base.ExportYAMLRoot();

            node.AddSerializedVersion(SerializedVersion);
            node.Add("m_СhildStates", ChildStates.ExportYAML());
            node.Add("m_ChildStateMachines", ChildStateMachines.ExportYAML());
            node.Add("m_AnyStateTransitions", AnyStateTransitions.ExportYAML());
            node.Add("m_EntryTransitions", EntryTransitions.ExportYAML());
            node.Add("m_StateMachineTransitions", StateMachineTransitions.ExportYAMLEnum());
            node.Add("m_StateMachineBehaviours", StateMachineBehaviours.ExportYAML());
            node.Add("m_AnyStatePosition", AnyStatePosition.ExportYAML());
            node.Add("m_EntryPosition", EntryPosition.ExportYAML());
            node.Add("m_ExitPosition", ExitPosition.ExportYAML());
            node.Add("m_ParentStateMachinePosition", ParentStateMachinePosition.ExportYAML());
            node.Add("m_DefaultState", DefaultState.ExportYAML());
            return(node);
        }
Example #11
0
        public TrafficPattern(EntryPosition position)
        {
            CarsPerMin = 10;
            Position = position;
            switch (Position)
            {
                case EntryPosition.North:
                    ToNorthPerc = 10;
                    ToEastPerc = 30;
                    ToSouthPerc = 30;
                    ToWestPerc = 30;
                    break;
                case EntryPosition.West:
                    ToNorthPerc = 30;
                    ToEastPerc = 30;
                    ToSouthPerc = 30;
                    ToWestPerc = 10;
                    break;
                case EntryPosition.South:
                    ToNorthPerc = 30;
                    ToEastPerc = 30;
                    ToSouthPerc = 10;
                    ToWestPerc = 30;
                    break;
                case EntryPosition.East:
                    ToNorthPerc = 30;
                    ToEastPerc = 10;
                    ToSouthPerc = 30;
                    ToWestPerc = 30;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            ToWestPerc += ToNorthPerc;
            ToSouthPerc += ToWestPerc;
            ToEastPerc += ToSouthPerc;
            if (ToEastPerc != 100)
            {
                MessageBox.Show($"Percentages don't add up to 100 for {position}");
                throw new ArgumentOutOfRangeException($"Percentages don't add up to 100 for {position}");
            }
        }