Пример #1
0
        public static void RequestControl()
        {
            try
            {
                Train train = Simulator.PlayerLocomotive.Train;

                MSGControl msgctl;
                //I am the server, I have control
                if (IsServer())
                {
                    train.TrainType = Train.TRAINTYPE.PLAYER; train.LeadLocomotive = Simulator.PlayerLocomotive;
                    InitializeBrakesCommand.Receiver = MPManager.Simulator.PlayerLocomotive.Train;
                    train.InitializeSignals(false);
                    if (Simulator.Confirmer != null)
                    {
                        Simulator.Confirmer.Information(MPManager.Catalog.GetString("You gained back the control of your train"));
                    }
                    msgctl = new MSGControl(GetUserName(), "Confirm", train);
                    BroadCast(msgctl.ToString());
                }
                else //client, send request
                {
                    msgctl = new MSGControl(GetUserName(), "Request", train);
                    SendToServer(msgctl.ToString());
                }
            }
            catch (Exception)
            { }
        }
Пример #2
0
        public static void RequestControl()
        {
            try
            {
                Train train = Simulator.Instance.PlayerLocomotive.Train;

                MSGControl msgctl;
                //I am the server, I have control
                if (IsServer())
                {
                    train.TrainType = TrainType.Player; train.LeadLocomotive = Simulator.Instance.PlayerLocomotive;
                    InitializeBrakesCommand.Receiver = Simulator.Instance.PlayerLocomotive.Train;
                    train.InitializeSignals(false);
                    Simulator.Instance.Confirmer?.Information(Catalog.GetString("You gained back the control of your train"));
                    msgctl = new MSGControl(GetUserName(), "Confirm", train);
                    Notify(msgctl.ToString());
                }
                else //client, send request
                {
                    msgctl = new MSGControl(GetUserName(), "Request", train);
                    Notify(msgctl.ToString());
                }
            }
            catch (Exception)
            { }
        }