コード例 #1
0
        public string ExhaustingLocos(MSGExhaust exhaust)
        {
            string tmp = "";

            if (exhaust == null)
            {
                exhaust = new MSGExhaust();
            }
            foreach (OnlineLocomotive l in OnlineLocomotives)
            {
                if (l.userName != MPManager.GetUserName())
                {
                    Train t = MPManager.FindPlayerTrain(l.userName);
                    if (t != null && l.trainCarPosition < t.Cars.Count && (Math.Abs(t.SpeedMpS) > 0.001 || Math.Abs(t.LastReportedSpeed) > 0))
                    {
                        if (t.Cars[l.trainCarPosition] is MSTSDieselLocomotive)
                        {
                            exhaust.AddNewItem(l.userName, t, l.trainCarPosition);
                        }
                    }
                }
            }
            if (exhaust != null)
            {
                tmp += exhaust.ToString();
            }
            return(tmp);
        }
コード例 #2
0
        public void AddPlayer()
        {
            if (!MPManager.IsServer())
            {
                return;
            }
            if (PlayerAdded == true)
            {
                PlayerAdded = false;
                MPManager.Instance().lastPlayerAddedTime = Simulator.GameTime;
                MPManager.Instance().lastSwitchTime      = Simulator.GameTime;

                MSGPlayer host = new  MSGPlayer(MPManager.GetUserName(), "1234", Simulator.conFileName, Simulator.patFileName, Simulator.PlayerLocomotive.Train,
                                                Simulator.PlayerLocomotive.Train.Number, Simulator.Settings.AvatarURL);
                MPManager.BroadCast(host.ToString() + MPManager.OnlineTrains.AddAllPlayerTrain());
                foreach (Train t in Simulator.Trains)
                {
                    if (Simulator.PlayerLocomotive != null && t == Simulator.PlayerLocomotive.Train)
                    {
                        continue;                                                                              //avoid broadcast player train
                    }
                    if (MPManager.FindPlayerTrain(t))
                    {
                        continue;
                    }
                    if (removedTrains.Contains(t))
                    {
                        continue;                           //this train is going to be removed, should avoid it.
                    }
                    MPManager.BroadCast((new MSGTrain(t, t.Number)).ToString());
                }
                if (CheckSpad == false)
                {
                    MultiPlayer.MPManager.BroadCast((new MultiPlayer.MSGMessage("All", "OverSpeedOK", "OK to go overspeed and pass stop light")).ToString());
                }
                else
                {
                    MultiPlayer.MPManager.BroadCast((new MultiPlayer.MSGMessage("All", "NoOverSpeed", "Penalty for overspeed and passing stop light")).ToString());
                }
                MPManager.BroadCast(GetEnvInfo());
            }
        }