Ejemplo n.º 1
0
    void Prepare_EMBARK()
    {
        for (int i = 0; i < totalCarriages; i++)
        {
            TrainCarriage _CARRIAGE = carriages[i];

            if (nextPlatform.platformQueues[i].Count > 0)
            {
                Commuter[] carriageQueue = nextPlatform.platformQueues[i].ToArray();

                for (int queueIndex = 0; queueIndex < carriageQueue.Length; queueIndex++)
                {
                    Commuter _COMMUTER = carriageQueue[queueIndex];
                    if (_CARRIAGE.seats_FREE.Count > 0)
                    {
                        _COMMUTER.currentSeat = _CARRIAGE.AssignSeat();
                        passengers_to_EMBARK.Add(_COMMUTER);
                        nextPlatform.platformQueues[i].Dequeue();
                        _COMMUTER.BoardTrain(this, _CARRIAGE.door_RIGHT);
                    }
                    else
                    {
                        _COMMUTER.currentSeat = null;
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void Commuter_DISEMBARKED(Commuter _commuter, int _carriageIndex)
    {
        passengers.Remove(_commuter);
        TrainCarriage _CARRIAGE = carriages[_carriageIndex];

        _CARRIAGE.passengers.Remove(_commuter);
        passengers_to_DISEMBARK.Remove(_commuter);
    }
Ejemplo n.º 3
0
    public void Commuter_EMBARKED(Commuter _commuter, int _carriageIndex)
    {
        passengers.Add(_commuter);
        TrainCarriage _CARRIAGE = carriages[_carriageIndex];

        _CARRIAGE.passengers.Add(_commuter);
        passengers_to_EMBARK.Remove(_commuter);
        _commuter.transform.SetParent(_CARRIAGE.transform);
    }
Ejemplo n.º 4
0
    public void AddCommuter(Platform _start, Platform _end)
    {
        GameObject commuter_OBJ =
            (GameObject)Instantiate(Metro.INSTANCE.prefab_commuter,
                                    _start.transform.position + new Vector3(0f, 0f, 0f), transform.rotation);
        Commuter _C = commuter_OBJ.GetComponent <Commuter>();

        _C.Init(_start, _end);
        commuters.Add(_C);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialize graphics settings (screen size etc'), and call SetupGame.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            graphics.PreferredBackBufferWidth  = GAME_WIDTH;
            graphics.PreferredBackBufferHeight = GAME_HEIGHT;
            graphics.ApplyChanges();

            IsFixedTimeStep   = true;
            TargetElapsedTime = TimeSpan.FromMilliseconds(1000 / Util.ToTicks(1));

            IsMouseVisible = true;

            sideMenu = new StackPanel(GAME_WIDTH - 350, 0, 350, GAME_HEIGHT);

            CityBuilder builder = new CityBuilder();

            BuilderTrafficCircleNode i1 = new BuilderTrafficCircleNode(430, 415);
            BuilderAllWayStopNode    i2 = new BuilderAllWayStopNode(940, 415);

            BuilderDeadEndNode e1top    = new BuilderDeadEndNode(430, 50, 0);
            BuilderDeadEndNode e1left   = new BuilderDeadEndNode(65, 415, MathHelper.ToRadians(-90));
            BuilderDeadEndNode e1bottom = new BuilderDeadEndNode(430, 780, MathHelper.ToRadians(180));

            BuilderDeadEndNode e2top    = new BuilderDeadEndNode(940, 50, MathHelper.ToRadians(0));
            BuilderDeadEndNode e2right  = new BuilderDeadEndNode(1310, 415, MathHelper.ToRadians(90));
            BuilderDeadEndNode e2bottom = new BuilderDeadEndNode(940, 780, MathHelper.ToRadians(180));

            CityBuilderParkingTwoLanePath connection = new CityBuilderParkingTwoLanePath(i1, i2);

            i1.right = connection;
            i2.left  = connection;

            CityBuilderParkingTwoLanePath i1top = new CityBuilderParkingTwoLanePath(i1, e1top);

            i1.top = i1top;
            CityBuilderParkingTwoLanePath i1left = new CityBuilderParkingTwoLanePath(i1, e1left);

            i1.left = i1left;
            CityBuilderParkingTwoLanePath i1bottom = new CityBuilderParkingTwoLanePath(i1, e1bottom);

            i1.bottom = i1bottom;

            CityBuilderParkingTwoLanePath i2right = new CityBuilderParkingTwoLanePath(i2, e2right);

            i2.right = i2right;
            CityBuilderParkingTwoLanePath i2top = new CityBuilderParkingTwoLanePath(i2, e2top);

            i2.top = i2top;
            CityBuilderParkingTwoLanePath i2bottom = new CityBuilderParkingTwoLanePath(i2, e2bottom);

            i2.bottom = i2bottom;

            builder.nodes.Add(i1);
            builder.nodes.Add(i2);
            builder.nodes.Add(e1top);
            builder.nodes.Add(e1left);
            builder.nodes.Add(e1bottom);
            builder.nodes.Add(e2right);
            builder.nodes.Add(e2top);
            builder.nodes.Add(e2bottom);
            builder.paths.Add(connection);
            builder.paths.Add(i1top);
            builder.paths.Add(i1bottom);
            builder.paths.Add(i1left);
            builder.paths.Add(i2right);
            builder.paths.Add(i2top);
            builder.paths.Add(i2bottom);
            city = builder.Build();

            Random r = new Random();

            foreach (CityNode n in city.nodes)
            {
                if (n is ParkingNode)
                {
                    //vehicles.Add(new GasolineCar(n));
                }
            }

            CityNode work1 = new CityNode(1200, 300);
            CityNode work2 = new CityNode(1100, 600);

            city.nodes.Add(work1);
            city.nodes.Add(work2);

            CityNode n1 = city.NearestNode(1200, 300, CityPathType.pedestrians);

            work1.Connect(n1, CityPathType.pedestrians);
            n1.Connect(work1, CityPathType.pedestrians);
            CityNode n2 = city.NearestNode(1100, 600, CityPathType.pedestrians);

            work2.Connect(n2, CityPathType.pedestrians);
            n2.Connect(work2, CityPathType.pedestrians);


            CityNode[] homes = new CityNode[]
            {
                new CityNode(250, 200),
                new CityNode(270, 300),
                new CityNode(120, 300),
                new CityNode(570, 100),
                new CityNode(570, 210),
                new CityNode(220, 560),
                new CityNode(550, 560),
                new CityNode(580, 700),
                new CityNode(750, 560),
                new CityNode(780, 720),
                new CityNode(780, 310),
                new CityNode(1080, 720),
                new CityNode(1080, 100),
            };

            foreach (CityNode home in homes)
            {
                city.nodes.Add(home);
                CityNode n = city.NearestNode((int)home.x, (int)home.y, CityPathType.pedestrians);
                home.Connect(n, CityPathType.pedestrians);
                n.Connect(home, CityPathType.pedestrians);

                CityNode park = City.ClosestParking(n);

                GasolineCar c = new GasolineCar(park);
                vehicles.Add(c);

                Commuter guy = new Commuter(home, home, r.Next(2) == 0 ? work1 : work2, c);
                debugObjects.Add(guy);
            }
        }
Ejemplo n.º 6
0
        public void DriveBackwardCommuter()
        {
            Commuter commuter = new Commuter();

            Assert.True(commuter.DriveBackwards());
        }
Ejemplo n.º 7
0
        public void CauseTrafficCommuter()
        {
            Commuter commuter = new Commuter();

            Assert.True(commuter.CauseTraffic());
        }
Ejemplo n.º 8
0
        public void HonkCommuter()
        {
            Commuter commuter = new Commuter();

            Assert.True(commuter.Honk());
        }
Ejemplo n.º 9
0
        public void GoFastCommuter()
        {
            Commuter commuter = new Commuter();

            Assert.True(commuter.GoFast());
        }
Ejemplo n.º 10
0
        public void DriveCommuter()
        {
            Commuter commuter = new Commuter();

            Assert.True(commuter.Drive());
        }
Ejemplo n.º 11
0
        public void UseAllWheelsCommuter()
        {
            Commuter commuter = new Commuter();

            Assert.True(commuter.UseAllWheels());
        }
Ejemplo n.º 12
0
 public void Remove_Commuter(Commuter _commuter)
 {
     commuters.Remove(_commuter);
     Destroy(_commuter.gameObject);
     Debug.Log("COMMUTER ARRIVED, remaining: " + commuters.Count);
 }