public void StartDriving(bool isReentering = false)
        {
            if (trainHandler != null && trainHandler.Exists && isReentering)
            {
                trainHandler.SpeedMPH = 88;
                _isReentryOn          = true;
                return;
            }

            trainHandler = TrainManager.CreateInvisibleTrain(Vehicle, _direction);

            if (!(trainHandler.Train.Heading >= Vehicle.Heading - 45 && trainHandler.Train.Heading <= Vehicle.Heading + 45))
            {
                _direction = !_direction;
                trainHandler.DeleteTrain();
                trainHandler = TrainManager.CreateInvisibleTrain(Vehicle, _direction);
            }

            trainHandler.IsAccelerationOn   = true;
            trainHandler.IsAutomaticBrakeOn = true;

            trainHandler.SetCollision(false);

            trainHandler.SetToAttach(Vehicle, new Vector3(0, 4.28f, 0), 1, 0); //new Vector3(0, 4.48f, 0)

            //trainHandler.CruiseSpeedMPH = 1;

            trainHandler.SetPosition(Vehicle.Position);

            trainHandler.OnVehicleAttached += TrainHandler_OnVehicleAttached;
            trainHandler.OnTrainDeleted    += TrainHandler_OnTrainDeleted;

            _isReentryOn = isReentering;
        }
    void Awake()
    {
        circuitSignals = FindObjectOfType <TrackCircuitSignals> ();
        carsHolder     = FindObjectOfType <CarsHolder> ();
        trainManager   = FindObjectOfType <TrainManager> ();
        switchManager  = FindObjectOfType <SwitchManager> ();
        scenario       = FindObjectOfType <Scenario> ();


        IndicationManager.Instance.Init();

        TrackPath.Instance.Init();

        TrackCircuitManager.Instance.Init();

        switchManager.Init();

        TrafficLightsManager.Instance.Init();

        RouteDictionary.Instance.Init();

        carsHolder.Init();

        CompositionManager.Instance.Init();

        trainManager.OnAwake();

        CouplerManager.Instance.Init();


        scenario.OnAwake();
    }
Exemple #3
0
    public void Initialize()
    {
        Vector3 offset = new Vector3(0, 0, 0);

        peopleManager = PeopleManager.Instance;
        trainManager  = TrainManager.Instance;

        for (int i = 0; i < numberOfCars; i++)
        {
            TrainCar prefab  = carPrefab;
            float    xoffset = carWidth;

            if (i == 0)
            {
                prefab  = frontCarPrefab;
                xoffset = frontCarWidth;
            }

            TrainCar car = Instantiate(prefab, transform);
            car.train = this;
            car.transform.localPosition = offset;
            offset -= new Vector3(xoffset, 0, 0);

            cars.Add(car);
        }
    }
    // Use this for initialization
    void Start()
    {
        manager = gameObject.GetComponent<AudioManager>();
        gameManager = GameObject.Find("TrainManager").GetComponent<TrainManager>();
        hand = gameObject.GetComponentInChildren<TutorialHand>();
        tutorialCow = GameObject.Find("TutorialCow");

        tutorialCow.SetActive(false);

        if(GameObject.Find("SelectedTrain") != null)
        {
            SelectedTrain selectedTrain = GameObject.Find("SelectedTrain").GetComponent<SelectedTrain>();

            if (selectedTrain.showTutorial)
            {
                //Debug.Log("SHOWING TUTORIAL");
                StartCoroutine("runTutorial");
            }
            else
            {
                //Debug.Log("NOT SHOWING TUTORIAL");
                gameManager.startTrain();
                Destroy(this.gameObject);
            }
        }
        else
        {
            //Debug.Log("NOT SHOWING TUTORIAL - selected train not found");
            gameManager.startTrain();
            Destroy(this.gameObject);
        }
    }
Exemple #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvcWithDefaultRoute();

            TrainSeeder trainSeeder = new TrainSeeder(); trainSeeder.Seed(serviceProvider);

            RouteSeeder.AddRoutes(serviceProvider);
            TrainSeeder.AddTrains(serviceProvider);
            RolesSeeder.AddRoles(serviceProvider);
            RolesSeeder.AddSuperUser(serviceProvider);

            TrainManager tm = new TrainManager(Configuration); tm.Start();
        }
Exemple #6
0
    // Start is called before the first frame update
    void Start()
    {
        trainManager = GameObject.Find("TrainManager").GetComponent <TrainManager>();
        trackManager = TrackManager.Instance;

        progressBarProgress.enabled = false;
    }
    private void Awake()
    {
        trainManager = TrainManager.Instance;
        Tracks       = new List <Track>();

        unlockedTracksMap.Add(TrackType.Straight, true);
        unlockedTracksMap.Add(TrackType.Loop, true);
    }
Exemple #8
0
    public void BuildWagon(TrainManager trainManager, WagonType type)
    {
        GameObject wagonToCreate = GetWagonOfType(type);

        if (wagonToCreate)
        {
            trainManager.CreateWagon(wagonToCreate);
        }
    }
Exemple #9
0
 public void BuildBasicTrain(TrainManager trainManager)
 {
     foreach (WagonType wagonType in TrainDataContainer.Instance.wagonsInTrain)
     {
         GameObject wagonToCreate = GetWagonOfType(wagonType);
         if (wagonToCreate)
         {
             trainManager.CreateWagon(wagonToCreate);
         }
     }
 }
 public override void OnLoad()
 {
     try
     {
         ReAddItem();
         txtName.Text = TrainManager.SetTrainNameAuto(TrainManager.TrainDatas[cbType.SelectedIndex]);
     }
     catch (Exception ex)
     {
         RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
     }
 }
Exemple #11
0
        private void StartWorkout()
        {
            _manager = new TrainManager(_trainingInfo);
            _manager.TrainChangeEvent += Manager_TrainChangeEvent;
            _manager.TickEvent        += _manager_TickEvent;

            _timer           = new Timer(1000);
            _timer.Elapsed  += Timer_Elapsed;
            _timer.Enabled   = true;
            _timer.AutoReset = true;
            _timer.Start();
        }
Exemple #12
0
    bool static_border;     //静态边界是否已构建

    // Use this for initialization
    void Start()
    {
        //  DontDestroyOnLoad(transform.gameObject);
        //PhotonNetwork.OfflineMode = true;
        if (PhotonNetwork.IsMasterClient)
        {
            GameObject item = PhotonNetwork.Instantiate("Axe", new Vector3(15, 1f, 6), Quaternion.identity);
            item.name = "Axe";
            item.transform.SetParent(GameObject.Find("MovableStuff").transform);
        }


        Environment = GameObject.Find("Environment").transform;

        Rail_preview   = GameObject.Find("Environment").transform.Find("Rail_preview");
        Bridge_preview = GameObject.Find("Environment").transform.Find("Bridge_preview");

        GameObject player = PhotonNetwork.Instantiate("Player3", new Vector3(14, 2.2f, 14), Quaternion.identity);

        player.name = "Player";
        Player      = player.transform;

        toolManager = Player.GetComponent <ToolManager>();

        //GameObject train = PhotonNetwork.Instantiate("Train", new Vector3(13, 1, 4), Quaternion.identity);
        //train.name = "Train";
        //Train = train.transform;
        Train        = GameObject.Find("Train").transform;
        trainManager = Train.GetComponent <TrainManager>();

        Rails        = GameObject.Find("Rails").transform;
        railsManager = Rails.GetComponent <RailsManager>();

        PanelManager = GameObject.Find("Panel").transform.Find("Canvas").GetComponent <Panel>();

        SetObstacleArray();
        SetBorderArray();
        railsManager.InitRails();
        trainManager.InitTrain();

        Pass          = false;
        ReachTerminal = false;
        BridgeBuild   = false;
        RailPut       = false;
        TrainMove     = false;

        static_border = false;
        testflag      = false;

        // 倒计时3秒出发
        //Invoke("TrainSetOut", 3.0f);
    }
Exemple #13
0
    private void Awake()
    {
        rb       = GetComponent <Rigidbody>();
        collider = GetComponent <BoxCollider>();

        rb.maxAngularVelocity = maxAngularVelocity;

        trainManager = GetComponent <TrainManager>();

        snowRide             = GetComponentInChildren <SnowRide>();
        cauldron             = GetComponent <Cauldron>();
        trainSoundController = GetComponentInChildren <TrainSoundController>();
    }
Exemple #14
0
    public void Start()
    {
        if (Serializer.IsDeserializing)
        {
            return;
        }
        if (Serializer.IsLoading)
        {
            return;
        }
        if (instance == null)
        {
            instance = this;
        }
        islandLerp        = 0f;
        airportBought     = false;
        trainBought       = false;
        airport           = GameObject.Find("Airport");
        train             = GameObject.Find("Train");
        popupManager      = GameObject.Find("Managers").GetComponent <PopupManager>();
        airportManager    = GameObject.Find("Managers").GetComponent <AirportManager>();
        trainManager      = GameObject.Find("Managers").GetComponent <TrainManager>();
        displayMenu       = GameObject.Find("LeftController").GetComponent <DisplayMenu>();
        firstIsland       = GameObject.Find("Island");
        secondIsland      = GameObject.Find("SecondIsland");
        setPosition       = new Vector3(1.9f, 0f, -58.8f);
        populationManager = GameObject.Find("Managers").GetComponent <PopulationManager>();
        AddIsland();
        levelReq = new Dictionary <int, int>();
        levelReq.Add(1, 10);
        levelReq.Add(2, 25);
        levelReq.Add(3, 50);
        levelReq.Add(4, 100);
        levelReq.Add(5, 175);
        levelReq.Add(6, 225);
        levelReq.Add(7, 300);
        levelReq.Add(8, 500);
        levelReq.Add(9, 750);
        levelReq.Add(10, 1000);
        levelReq.Add(11, 1500);
        levelReq.Add(12, 2000);
        levelReq.Add(13, 3000);
        levelReq.Add(14, 5000);
        levelReq.Add(15, 7500);
        levelReq.Add(16, 100000);



        Autelia.Coroutines.CoroutineController.StartCoroutine(this, "SlowUpdate");
    }
Exemple #15
0
	void initialize(){
		//		Screen.SetResolution (500, 500, true); // for John's weird screen
		board = gameObject.AddComponent<Board> ();
		board.init (num_tiles_w, num_tiles_h, pr_switch);

		gems = gameObject.AddComponent<GemManager> ();
		gems.init (num_tiles_w, num_tiles_h);
		makeGems ();

		trains = gameObject.AddComponent<TrainManager> ();
		trains.init (this);

		score = 0;
	}
Exemple #16
0
    void initialize()
    {
        //		Screen.SetResolution (500, 500, true); // for John's weird screen
        board = gameObject.AddComponent <Board> ();
        board.init(num_tiles_w, num_tiles_h, pr_switch);

        gems = gameObject.AddComponent <GemManager> ();
        gems.init(num_tiles_w, num_tiles_h);
        makeGems();

        trains = gameObject.AddComponent <TrainManager> ();
        trains.init(this);

        score = 0;
    }
    void nextCard()
    {
        thisAccountCardHolder                 = null;
        thisAccountPlayerManager              = null;
        thisAccountPlayerStandTrainManager    = null;
        thisAccountItemHolderList             = new List <ItemHolder> ();
        thisAccountCanAttackPlayerManagerList = new List <PlayerManager> ();

        PlayerIndexCardHolderMap thisPlayerIndexCardInfo = thisRoundPlayerIndexCardInfoQueue.Dequeue();

        thisAccountCardHolder = thisPlayerIndexCardInfo.cardHolder;
        thisAccountCardInfo   = thisAccountCardHolder.Card;
        int playerIndex = thisPlayerIndexCardInfo.playerIndex;

        thisAccountPlayerManager = GameManager.Instance.gamePlayManager.playerInGameManager.GetPlayerManagerByIndex(playerIndex);

        GameManager.Instance.gamePlayManager.cameraController.ForcusOnPos(thisAccountPlayerManager.PlayerRenderer.transform.position);
        cardToPlayer(thisAccountCardInfo, thisAccountPlayerManager);
        reactionManager.UpdatePlayerAction(playerIndex, thisAccountPlayerManager.ThisPlayerInfo.playerName, thisAccountCardInfo.accountDescription);
    }
Exemple #18
0
        // Start is called before the first frame update
        private void Start()
        {
            SaveLoadManager.Load(out playerTrain, out player);
            sceneData = new SceneData();
            //
            playerTrain = FindObjectOfType <TrainManager>().gameObject;
            //
            mainPlayer   = playerTrain.GetComponentInChildren <MainPlayer>();
            trainManager = playerTrain.GetComponentInChildren <TrainManager>();
            trainManager.Init(sceneData);
            mainPlayer.Init();
            sceneData.TargetEnemyCount = targetEnemyCount;
            sceneData.TargetPropsCount = targetPropsCount;
            sceneData.TrainSpeed       = trainSpeed;
            sceneData.LineLength       = lineLength;
            sceneData.CurrentLevel     = currentLevel;
            sceneData.LinesCount       = linesCount;
            sceneData.Player           = player;
            worldMover.SetupMover(sceneData);
            generatorManager.Init(sceneData);
            renderManager.Init();
            triggerManager.Init(generatorManager);
            //hangar.Init(sceneData); //Commited by Danny

            weaponController.Init(sceneData);


            trainStuffAdd();
            if (skillManager != null)
            {
                skillManager.Init();
            }
            pathCounter.Init(sceneData);
            sceneData.LinesOverall = generatorManager.LevelLenght;
            GenerateFirstArea();
            sceneData.CurrentState = GameState.Start;
            //sceneData.CurrentState = GameState.Preroll;
            //sceneData.CurrentState = GameState.Wait;
            //sceneData.CurrentState = GameState.Loop;
            //SaveLoadManager.SavePlayer(playerTrain, sceneData.Player); TEMPORARY OFF.
        }
Exemple #19
0
	// Use this for initialization
	//	public void init(int i, int j, Vector2 start_dir, int num_tiles_w, int num_tiles_h){
	public void init(int i, int j, int start_dir, TrainManager owner) {
		this.owner = owner;
		this.num_tiles_w = owner.num_tiles_w;
		this.num_tiles_h = owner.num_tiles_h;
		this.n = owner.owner.n;
		this.direction = start_dir;
		tile_width = Screen.width / num_tiles_w;

		this.transform.rotation = Quaternion.Euler(0f, 0f, (90f * direction)%360f);
		this.transform.Rotate (Vector2.right * direction);

		float[] pos = position (i, j);
		location = new Vector2 (pos [0], pos [1]);
		current_tile = owner.owner.board.tiles [i] [j];
		this.transform.position = Camera.main.ScreenToWorldPoint (
			new Vector3 (location.x, location.y, 8));

		GameObject modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);	// Create a quad object for holding the gem texture.
		model = modelObject.AddComponent<TrainModel>();						// Add a gemModel script to control visuals of the gem.
		model.init(this);
	}
Exemple #20
0
			// --- constructors ---
			/// <summary>Creates a new sound source.</summary>
			/// <param name="buffer">The sound buffer.</param>
			/// <param name="radius">The effective sound radius.</param>
			/// <param name="pitch">The pitch change factor.</param>
			/// <param name="volume">The volume change factor.</param>
			/// <param name="position">The position. If a train and car are specified, the position is relative to the car, otherwise absolute.</param>
			/// <param name="train">The train this sound source is attached to, or a null reference.</param>
			/// <param name="car">The car this sound source is attached to, or a null reference.</param>
			/// <param name="looped">Whether this sound source plays in a loop.</param>
			internal SoundSource(SoundBuffer buffer, double radius, double pitch, double volume, OpenBveApi.Math.Vector3 position, TrainManager.Train train, int car, bool looped) {
				this.Buffer = buffer;
				this.Radius = radius;
				this.Pitch = pitch;
				this.Volume = volume;
				this.Position = position;
				this.Train = train;
				this.Car = car;
				this.Looped = looped;
				this.State = SoundSourceState.PlayPending;
				this.OpenAlSourceName = 0;
				//Set the sound type to undefined to use Michelle's original processing
				if (train != null)
				{
					this.Type = SoundType.TrainCar;
				}
				else
				{
					this.Type = SoundType.Undefined;	
				}
				
			}
Exemple #21
0
    // Use this for initialization
    //	public void init(int i, int j, Vector2 start_dir, int num_tiles_w, int num_tiles_h){
    public void init(int i, int j, int start_dir, TrainManager owner)
    {
        this.owner       = owner;
        this.num_tiles_w = owner.num_tiles_w;
        this.num_tiles_h = owner.num_tiles_h;
        this.n           = owner.owner.n;
        this.direction   = start_dir;
        tile_width       = Screen.width / num_tiles_w;

        this.transform.rotation = Quaternion.Euler(0f, 0f, (90f * direction) % 360f);
        this.transform.Rotate(Vector2.right * direction);

        float[] pos = position(i, j);
        location                = new Vector2(pos [0], pos [1]);
        current_tile            = owner.owner.board.tiles [i] [j];
        this.transform.position = Camera.main.ScreenToWorldPoint(
            new Vector3(location.x, location.y, 8));

        GameObject modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);                // Create a quad object for holding the gem texture.

        model = modelObject.AddComponent <TrainModel>();                                        // Add a gemModel script to control visuals of the gem.
        model.init(this);
    }
        public override void Process()
        {
            if (Mods.Wheel != WheelType.RailroadInvisible)
            {
                if (IsOnTracks)
                {
                    Stop();
                }

                return;
            }

            if (IsOnTracks)
            {
                IsAttachedToRogersSierra = trainHandler.IsRogersSierra;

                if (IsAttachedToRogersSierra)
                {
                    if (Main.PlayerVehicle == Vehicle && Game.IsControlPressed(GTA.Control.VehicleAccelerate))
                    {
                        trainHandler.SwitchToRegular();
                    }

                    if (Main.RogersSierra.Locomotive.Speed > 0 && Utils.EntitySpeedVector(Main.RogersSierra.Locomotive).Y < 0)
                    {
                        trainHandler.SwitchToRegular();
                    }

                    return;
                }
                else
                {
                    trainHandler.IsAccelerationOn = Main.PlayerVehicle == Vehicle && Vehicle.IsVisible && Vehicle.IsEngineRunning;
                }

                if (Main.PlayerVehicle == Vehicle)
                {
                    Function.Call(Hash.DISABLE_CONTROL_ACTION, 27, 59, true);
                }

                //if (Game.GameTime > _checkTime)
                //{
                //    _checkTime = Game.GameTime + 1000;

                //    _train = World.GetClosestVehicle(Vehicle.Position, 25, ModelHandler.FreightModel, ModelHandler.SierraModel, ModelHandler.SierraTenderModel, ModelHandler.SierraDebugModel);

                //    if (_train != null)
                //        _speedDifference = Math.Abs(_train.GetMPHSpeed() - Vehicle.GetMPHSpeed());
                //    else
                //        _train = null;

                //}

                //if (Vehicle.IsTouching(_train))
                //{
                //    Stop();

                //    if (_speedDifference > 20)
                //        Vehicle.Explode();

                //    return;
                //}

                if (_isReentryOn && trainHandler.AttachedToTarget && trainHandler.SpeedMPH == 0)
                {
                    if (Utils.Random.NextDouble() <= 0.25f)
                    {
                        TrainManager.CreateFreightTrain(Vehicle, !_direction).SetToDestroy(Vehicle, 35);
                    }

                    _isReentryOn = false;
                    return;
                }

                return;
            }

            //if (Utils.IsVehicleOnTracks(Vehicle))
            //    StartDriving();

            if (Mods.Wheel == WheelType.RailroadInvisible && (trainHandler == null || !trainHandler.Exists))
            {
                var wheelPos = new List <Vector3>
                {
                    Vehicle.Bones["wheel_lf"].Position,
                    Vehicle.Bones["wheel_rf"].Position,
                    Vehicle.Bones["wheel_rr"].Position,
                    Vehicle.Bones["wheel_lr"].Position
                };

                if (wheelPos.TrueForAll(x => Utils.IsWheelOnTracks(x, Vehicle)))
                {
                    StartDriving();
                }
            }
        }
Exemple #23
0
        /// <summary>Renders all default HUD elements</summary>
        /// <param name="Element">The HUD element these are to be rendererd onto</param>
        /// <param name="TimeElapsed">The time elapsed</param>
        private void RenderHUDElement(HUD.Element Element, double TimeElapsed)
        {
            if (TrainManager.PlayerTrain == null)
            {
                return;
            }
            TrainManager.TrainDoorState      LeftDoors  = TrainManager.GetDoorsState(TrainManager.PlayerTrain, true, false);
            TrainManager.TrainDoorState      RightDoors = TrainManager.GetDoorsState(TrainManager.PlayerTrain, false, true);
            System.Globalization.CultureInfo Culture    = System.Globalization.CultureInfo.InvariantCulture;
            string Command = Element.Subject.ToLowerInvariant();
            // default
            double w, h;

            if (Element.CenterMiddle.BackgroundTexture != null)
            {
                if (Program.CurrentHost.LoadTexture(Element.CenterMiddle.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                {
                    w = (double)Element.CenterMiddle.BackgroundTexture.Width;
                    h = (double)Element.CenterMiddle.BackgroundTexture.Height;
                }
                else
                {
                    w = 0.0; h = 0.0;
                }
            }
            else
            {
                w = 0.0; h = 0.0;
            }

            int stationIndex;

            if (TrainManager.PlayerTrain.Station >= 0 && TrainManager.PlayerTrain.StationState != TrainStopState.Completed)
            {
                stationIndex = TrainManager.PlayerTrain.LastStation;
            }
            else
            {
                stationIndex = TrainManager.PlayerTrain.LastStation + 1;
            }
            if (stationIndex > Program.CurrentRoute.Stations.Length - 1)
            {
                stationIndex = TrainManager.PlayerTrain.LastStation;
            }

            double x = Element.Alignment.X < 0 ? 0.0 : Element.Alignment.X == 0 ? 0.5 * (Program.Renderer.Screen.Width - w) : Program.Renderer.Screen.Width - w;
            double y = Element.Alignment.Y < 0 ? 0.0 : Element.Alignment.Y == 0 ? 0.5 * (Program.Renderer.Screen.Height - h) : Program.Renderer.Screen.Height - h;

            x += Element.Position.X;
            y += Element.Position.Y;
            // command
            const double speed = 1.0;
            MessageColor sc    = MessageColor.None;
            string       t;

            switch (Command)
            {
            case "reverser":
                if (TrainManager.PlayerTrain.Handles.Reverser.Driver < 0)
                {
                    sc = MessageColor.Orange;
                    if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 2)
                    {
                        t = TrainManager.PlayerTrain.ReverserDescriptions[2];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandleBackward;
                    }
                }
                else if (TrainManager.PlayerTrain.Handles.Reverser.Driver > 0)
                {
                    sc = MessageColor.Blue;
                    if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 0)
                    {
                        t = TrainManager.PlayerTrain.ReverserDescriptions[0];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandleForward;
                    }
                }
                else
                {
                    sc = MessageColor.Gray;
                    if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 1)
                    {
                        t = TrainManager.PlayerTrain.ReverserDescriptions[1];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandleNeutral;
                    }
                }
                Element.TransitionState = 0.0;
                break;

            case "power":
                if (TrainManager.PlayerTrain.Handles.SingleHandle)
                {
                    return;
                }
                if (TrainManager.PlayerTrain.Handles.Power.Driver == 0)
                {
                    sc = MessageColor.Gray;
                    if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.PowerNotchDescriptions.Length > 0)
                    {
                        t = TrainManager.PlayerTrain.PowerNotchDescriptions[0];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandlePowerNull;
                    }
                }
                else
                {
                    sc = MessageColor.Blue;
                    if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Power.Driver < TrainManager.PlayerTrain.PowerNotchDescriptions.Length)
                    {
                        t = TrainManager.PlayerTrain.PowerNotchDescriptions[TrainManager.PlayerTrain.Handles.Power.Driver];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandlePower + TrainManager.PlayerTrain.Handles.Power.Driver.ToString(Culture);
                    }
                }
                Element.TransitionState = 0.0;
                break;

            case "brake":
                if (TrainManager.PlayerTrain.Handles.SingleHandle)
                {
                    return;
                }
                if (TrainManager.PlayerTrain.Handles.Brake is TrainManager.AirBrakeHandle)
                {
                    if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver)
                    {
                        sc = MessageColor.Red;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleEmergency;
                        }
                    }
                    else if (TrainManager.PlayerTrain.Handles.Brake.Driver == (int)TrainManager.AirBrakeHandleState.Release)
                    {
                        sc = MessageColor.Gray;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleRelease;
                        }
                    }
                    else if (TrainManager.PlayerTrain.Handles.Brake.Driver == (int)TrainManager.AirBrakeHandleState.Lap)
                    {
                        sc = MessageColor.Blue;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleLap;
                        }
                    }
                    else
                    {
                        sc = MessageColor.Orange;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 3)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[3];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleService;
                        }
                    }
                }
                else
                {
                    if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver)
                    {
                        sc = MessageColor.Red;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleEmergency;
                        }
                    }
                    else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                    {
                        sc = MessageColor.Green;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleHoldBrake;
                        }
                    }
                    else if (TrainManager.PlayerTrain.Handles.Brake.Driver == 0)
                    {
                        sc = MessageColor.Gray;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleBrakeNull;
                        }
                    }
                    else
                    {
                        sc = MessageColor.Orange;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && ((TrainManager.PlayerTrain.Handles.HasHoldBrake && TrainManager.PlayerTrain.Handles.Brake.Driver + 2 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length) || (!TrainManager.PlayerTrain.Handles.HasHoldBrake && TrainManager.PlayerTrain.Handles.Brake.Driver + 1 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length)))
                        {
                            t = TrainManager.PlayerTrain.Handles.HasHoldBrake ? TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 2] : TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 1];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleBrake + TrainManager.PlayerTrain.Handles.Brake.Driver.ToString(Culture);
                        }
                    }
                }
                Element.TransitionState = 0.0;
                break;

            case "locobrake":
                if (!TrainManager.PlayerTrain.Handles.HasLocoBrake)
                {
                    return;
                }

                if (TrainManager.PlayerTrain.Handles.LocoBrake is TrainManager.LocoAirBrakeHandle)
                {
                    if (TrainManager.PlayerTrain.Handles.LocoBrake.Driver == (int)TrainManager.AirBrakeHandleState.Release)
                    {
                        sc = MessageColor.Gray;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleRelease;
                        }
                    }
                    else if (TrainManager.PlayerTrain.Handles.LocoBrake.Driver == (int)TrainManager.AirBrakeHandleState.Lap)
                    {
                        sc = MessageColor.Blue;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleLap;
                        }
                    }
                    else
                    {
                        sc = MessageColor.Orange;
                        if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 3)
                        {
                            t = TrainManager.PlayerTrain.BrakeNotchDescriptions[3];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleService;
                        }
                    }
                }
                else
                {
                    if (TrainManager.PlayerTrain.Handles.LocoBrake.Driver == 0)
                    {
                        sc = MessageColor.Gray;
                        if (TrainManager.PlayerTrain.LocoBrakeNotchDescriptions != null && TrainManager.PlayerTrain.LocoBrakeNotchDescriptions.Length > 1)
                        {
                            t = TrainManager.PlayerTrain.LocoBrakeNotchDescriptions[1];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleBrakeNull;
                        }
                    }
                    else
                    {
                        sc = MessageColor.Orange;
                        if (TrainManager.PlayerTrain.LocoBrakeNotchDescriptions != null && TrainManager.PlayerTrain.Handles.LocoBrake.Driver < TrainManager.PlayerTrain.LocoBrakeNotchDescriptions.Length)
                        {
                            t = TrainManager.PlayerTrain.LocoBrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.LocoBrake.Driver];
                        }
                        else
                        {
                            t = Translations.QuickReferences.HandleLocoBrake + TrainManager.PlayerTrain.Handles.LocoBrake.Driver.ToString(Culture);
                        }
                    }
                }
                Element.TransitionState = 0.0;
                break;

            case "single":
                if (!TrainManager.PlayerTrain.Handles.SingleHandle)
                {
                    return;
                }
                if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver)
                {
                    sc = MessageColor.Red;
                    if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0)
                    {
                        t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandleEmergency;
                    }
                }
                else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                {
                    sc = MessageColor.Green;
                    if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1)
                    {
                        t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandleHoldBrake;
                    }
                }
                else if (TrainManager.PlayerTrain.Handles.Brake.Driver > 0)
                {
                    sc = MessageColor.Orange;
                    if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Brake.Driver + 3 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length)
                    {
                        t = TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 3];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandleBrake + TrainManager.PlayerTrain.Handles.Brake.Driver.ToString(Culture);
                    }
                }
                else if (TrainManager.PlayerTrain.Handles.Power.Driver > 0)
                {
                    sc = MessageColor.Blue;
                    if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Power.Driver < TrainManager.PlayerTrain.PowerNotchDescriptions.Length)
                    {
                        t = TrainManager.PlayerTrain.PowerNotchDescriptions[TrainManager.PlayerTrain.Handles.Power.Driver];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandlePower + TrainManager.PlayerTrain.Handles.Power.Driver.ToString(Culture);
                    }
                }
                else
                {
                    sc = MessageColor.Gray;
                    if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.PowerNotchDescriptions.Length > 0)
                    {
                        t = TrainManager.PlayerTrain.PowerNotchDescriptions[0];
                    }
                    else
                    {
                        t = Translations.QuickReferences.HandlePowerNull;
                    }
                }
                Element.TransitionState = 0.0;
                break;

            case "doorsleft":
            case "doorsright":
            {
                if ((LeftDoors & TrainManager.TrainDoorState.AllClosed) == 0 | (RightDoors & TrainManager.TrainDoorState.AllClosed) == 0)
                {
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else
                {
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                }
                TrainManager.TrainDoorState Doors = Command == "doorsleft" ? LeftDoors : RightDoors;
                if ((Doors & TrainManager.TrainDoorState.Mixed) != 0)
                {
                    sc = MessageColor.Orange;
                }
                else if ((Doors & TrainManager.TrainDoorState.AllClosed) != 0)
                {
                    sc = MessageColor.Gray;
                }
                else if (TrainManager.PlayerTrain.Specs.DoorCloseMode == TrainManager.DoorMode.Manual)
                {
                    sc = MessageColor.Green;
                }
                else
                {
                    sc = MessageColor.Blue;
                }
                t = Command == "doorsleft" ? Translations.QuickReferences.DoorsLeft : Translations.QuickReferences.DoorsRight;
            } break;

            case "stopleft":
            case "stopright":
            case "stopnone":
            {
                int s = TrainManager.PlayerTrain.Station;
                if (s >= 0 && Program.CurrentRoute.Stations[s].PlayerStops() && Interface.CurrentOptions.GameMode != GameMode.Expert)
                {
                    bool cond;
                    if (Command == "stopleft")
                    {
                        cond = Program.CurrentRoute.Stations[s].OpenLeftDoors;
                    }
                    else if (Command == "stopright")
                    {
                        cond = Program.CurrentRoute.Stations[s].OpenRightDoors;
                    }
                    else
                    {
                        cond = !Program.CurrentRoute.Stations[s].OpenLeftDoors & !Program.CurrentRoute.Stations[s].OpenRightDoors;
                    }
                    if (TrainManager.PlayerTrain.StationState == TrainStopState.Pending & cond)
                    {
                        Element.TransitionState -= speed * TimeElapsed;
                        if (Element.TransitionState < 0.0)
                        {
                            Element.TransitionState = 0.0;
                        }
                    }
                    else
                    {
                        Element.TransitionState += speed * TimeElapsed;
                        if (Element.TransitionState > 1.0)
                        {
                            Element.TransitionState = 1.0;
                        }
                    }
                }
                else
                {
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                }
                t = Element.Text;
            } break;

            case "stoplefttick":
            case "stoprighttick":
            case "stopnonetick":
            {
                int s = TrainManager.PlayerTrain.Station;
                if (s >= 0 && Program.CurrentRoute.Stations[s].PlayerStops() && Interface.CurrentOptions.GameMode != GameMode.Expert)
                {
                    int c = Program.CurrentRoute.Stations[s].GetStopIndex(TrainManager.PlayerTrain.Cars.Length);
                    if (c >= 0)
                    {
                        bool cond;
                        if (Command == "stoplefttick")
                        {
                            cond = Program.CurrentRoute.Stations[s].OpenLeftDoors;
                        }
                        else if (Command == "stoprighttick")
                        {
                            cond = Program.CurrentRoute.Stations[s].OpenRightDoors;
                        }
                        else
                        {
                            cond = !Program.CurrentRoute.Stations[s].OpenLeftDoors & !Program.CurrentRoute.Stations[s].OpenRightDoors;
                        }
                        if (TrainManager.PlayerTrain.StationState == TrainStopState.Pending & cond)
                        {
                            Element.TransitionState -= speed * TimeElapsed;
                            if (Element.TransitionState < 0.0)
                            {
                                Element.TransitionState = 0.0;
                            }
                        }
                        else
                        {
                            Element.TransitionState += speed * TimeElapsed;
                            if (Element.TransitionState > 1.0)
                            {
                                Element.TransitionState = 1.0;
                            }
                        }
                        double d = TrainManager.PlayerTrain.StationDistanceToStopPoint;
                        double r;
                        if (d > 0.0)
                        {
                            r = d / Program.CurrentRoute.Stations[s].Stops[c].BackwardTolerance;
                        }
                        else
                        {
                            r = d / Program.CurrentRoute.Stations[s].Stops[c].ForwardTolerance;
                        }
                        if (r < -1.0)
                        {
                            r = -1.0;
                        }
                        if (r > 1.0)
                        {
                            r = 1.0;
                        }
                        y -= r * (double)Element.Value1;
                    }
                    else
                    {
                        Element.TransitionState += speed * TimeElapsed;
                        if (Element.TransitionState > 1.0)
                        {
                            Element.TransitionState = 1.0;
                        }
                    }
                }
                else
                {
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                }
                t = Element.Text;
            } break;

            case "clock":
            {
                int hours   = (int)Math.Floor(Program.CurrentRoute.SecondsSinceMidnight);
                int seconds = hours % 60; hours /= 60;
                int minutes = hours % 60; hours /= 60;
                hours %= 24;
                t      = hours.ToString(Culture).PadLeft(2, '0') + ":" + minutes.ToString(Culture).PadLeft(2, '0') + ":" + seconds.ToString(Culture).PadLeft(2, '0');
                if (renderer.OptionClock)
                {
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else
                {
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                }
            } break;

            case "gradient":
                if (renderer.OptionGradient == NewRenderer.GradientDisplayMode.Percentage)
                {
                    if (World.CameraTrackFollower.Pitch != 0)
                    {
                        double pc = World.CameraTrackFollower.Pitch;
                        t = Math.Abs(pc).ToString("0.00", Culture) + "%" + (Math.Abs(pc) == pc ? " ↗" : " ↘");
                    }
                    else
                    {
                        t = "Level";
                    }
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else if (renderer.OptionGradient == NewRenderer.GradientDisplayMode.UnitOfChange)
                {
                    if (World.CameraTrackFollower.Pitch != 0)
                    {
                        double gr = 1000 / World.CameraTrackFollower.Pitch;
                        t = "1 in " + Math.Abs(gr).ToString("0", Culture) + (Math.Abs(gr) == gr ? " ↗" : " ↘");
                    }
                    else
                    {
                        t = "Level";
                    }
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else if (renderer.OptionGradient == NewRenderer.GradientDisplayMode.Permil)
                {
                    if (World.CameraTrackFollower.Pitch != 0)
                    {
                        double pm = World.CameraTrackFollower.Pitch;
                        t = Math.Abs(pm).ToString("0.00", Culture) + "‰" + (Math.Abs(pm) == pm ? " ↗" : " ↘");
                    }
                    else
                    {
                        t = "Level";
                    }
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else
                {
                    if (World.CameraTrackFollower.Pitch != 0)
                    {
                        double gr = 1000 / World.CameraTrackFollower.Pitch;
                        t = "1 in " + Math.Abs(gr).ToString("0", Culture) + (Math.Abs(gr) == gr ? " ↗" : " ↘");
                    }
                    else
                    {
                        t = "Level";
                    }
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                } break;

            case "speed":
                if (renderer.OptionSpeed == NewRenderer.SpeedDisplayMode.Kmph)
                {
                    double kmph = Math.Abs(TrainManager.PlayerTrain.CurrentSpeed) * 3.6;
                    t = kmph.ToString("0.00", Culture) + " km/h";
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else if (renderer.OptionSpeed == NewRenderer.SpeedDisplayMode.Mph)
                {
                    double mph = Math.Abs(TrainManager.PlayerTrain.CurrentSpeed) * 2.2369362920544;
                    t = mph.ToString("0.00", Culture) + " mph";
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else
                {
                    double mph = Math.Abs(TrainManager.PlayerTrain.CurrentSpeed) * 2.2369362920544;
                    t = mph.ToString("0.00", Culture) + " mph";
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                } break;

            case "dist_next_station":
                if (!Program.CurrentRoute.Stations[stationIndex].PlayerStops())
                {
                    int    n  = Program.CurrentRoute.Stations[stationIndex].GetStopIndex(TrainManager.PlayerTrain.NumberOfCars);
                    double p0 = TrainManager.PlayerTrain.FrontCarTrackPosition();
                    double p1 = Program.CurrentRoute.Stations[stationIndex].Stops.Length > 0 ? Program.CurrentRoute.Stations[stationIndex].Stops[n].TrackPosition : Program.CurrentRoute.Stations[stationIndex].DefaultTrackPosition;
                    double m  = p1 - p0;
                    if (m < 0)
                    {
                        m = 0.0;                                 //Don't display negative numbers when passing (stop zone goes beyond the absolute station limit)
                    }
                    if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Km)
                    {
                        m /= 1000.0;
                        t  = "Pass: "******"0.000", Culture) + " km";
                        Element.TransitionState -= speed * TimeElapsed;
                        if (Element.TransitionState < 0.0)
                        {
                            Element.TransitionState = 0.0;
                        }
                    }
                    else if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Mile)
                    {
                        m /= 1609.34;
                        t  = "Pass: "******"0.0000", Culture) + " miles";
                        Element.TransitionState -= speed * TimeElapsed;
                        if (Element.TransitionState < 0.0)
                        {
                            Element.TransitionState = 0.0;
                        }
                    }
                    else
                    {
                        m /= 1609.34;
                        t  = "Pass: "******"0.0000", Culture) + " miles";
                        Element.TransitionState += speed * TimeElapsed;
                        if (Element.TransitionState > 1.0)
                        {
                            Element.TransitionState = 1.0;
                        }
                    }
                }
                else
                {
                    t = String.Empty;
                }
                break;

            case "dist_next_station2":
                if (!Program.CurrentRoute.Stations[stationIndex].PlayerStops())
                {
                    int    n  = Program.CurrentRoute.Stations[stationIndex].GetStopIndex(TrainManager.PlayerTrain.NumberOfCars);
                    double p0 = TrainManager.PlayerTrain.FrontCarTrackPosition();
                    double p1 = 0.0;
                    for (int i = stationIndex; i < Program.CurrentRoute.Stations.Length; i++)
                    {
                        if (Program.CurrentRoute.Stations[i].PlayerStops())
                        {
                            p1 = Program.CurrentRoute.Stations[i].Stops.Length > 0 ? Program.CurrentRoute.Stations[i].Stops[n].TrackPosition : Program.CurrentRoute.Stations[i].DefaultTrackPosition;
                        }
                    }

                    double m = p1 - p0;
                    if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Km)
                    {
                        m /= 1000.0;
                        t  = "Next Stop: " + m.ToString("0.000", Culture) + " km";
                        Element.TransitionState -= speed * TimeElapsed;
                        if (Element.TransitionState < 0.0)
                        {
                            Element.TransitionState = 0.0;
                        }
                    }
                    else if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Mile)
                    {
                        m /= 1609.34;
                        t  = "Next Stop: " + m.ToString("0.0000", Culture) + " miles";
                        Element.TransitionState -= speed * TimeElapsed;
                        if (Element.TransitionState < 0.0)
                        {
                            Element.TransitionState = 0.0;
                        }
                    }
                    else
                    {
                        m /= 1609.34;
                        t  = "Next Stop: " + m.ToString("0.0000", Culture) + " miles";
                        Element.TransitionState += speed * TimeElapsed;
                        if (Element.TransitionState > 1.0)
                        {
                            Element.TransitionState = 1.0;
                        }
                    }
                }
                else
                {
                    int    n  = Program.CurrentRoute.Stations[stationIndex].GetStopIndex(TrainManager.PlayerTrain.NumberOfCars);
                    double p0 = TrainManager.PlayerTrain.FrontCarTrackPosition();
                    double p1 = Program.CurrentRoute.Stations[stationIndex].Stops.Length > 0 ? Program.CurrentRoute.Stations[stationIndex].Stops[n].TrackPosition : Program.CurrentRoute.Stations[stationIndex].DefaultTrackPosition;;
                    double m  = p1 - p0;
                    if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Km)
                    {
                        if (Math.Abs(m) <= 10.0)
                        {
                            t = "Stop: " + m.ToString("0.00", Culture) + " m";
                        }
                        else
                        {
                            m /= 1000.0;
                            t  = "Stop: " + m.ToString("0.000", Culture) + " km";
                        }
                        Element.TransitionState -= speed * TimeElapsed;
                        if (Element.TransitionState < 0.0)
                        {
                            Element.TransitionState = 0.0;
                        }
                    }
                    else if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Mile)
                    {
                        m /= 1609.34;
                        t  = "Stop: " + m.ToString("0.0000", Culture) + " miles";
                        Element.TransitionState -= speed * TimeElapsed;
                        if (Element.TransitionState < 0.0)
                        {
                            Element.TransitionState = 0.0;
                        }
                    }
                    else
                    {
                        m /= 1609.34;
                        t  = "Stop: " + m.ToString("0.0000", Culture) + " miles";
                        Element.TransitionState += speed * TimeElapsed;
                        if (Element.TransitionState > 1.0)
                        {
                            Element.TransitionState = 1.0;
                        }
                    }
                }
                break;

            case "fps":
                int fps = (int)Math.Round(Program.Renderer.FrameRate);
                t = fps.ToString(Culture) + " fps";
                if (renderer.OptionFrameRates)
                {
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else
                {
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                } break;

            case "ai":
                t = "A.I.";
                if (TrainManager.PlayerTrain.AI != null)
                {
                    Element.TransitionState -= speed * TimeElapsed;
                    if (Element.TransitionState < 0.0)
                    {
                        Element.TransitionState = 0.0;
                    }
                }
                else
                {
                    Element.TransitionState += speed * TimeElapsed;
                    if (Element.TransitionState > 1.0)
                    {
                        Element.TransitionState = 1.0;
                    }
                } break;

            case "score":
                if (Interface.CurrentOptions.GameMode == GameMode.Arcade)
                {
                    t = Game.CurrentScore.CurrentValue.ToString(Culture) + " / " + Game.CurrentScore.Maximum.ToString(Culture);
                    if (Game.CurrentScore.CurrentValue < 0)
                    {
                        sc = MessageColor.Red;
                    }
                    else if (Game.CurrentScore.CurrentValue > 0)
                    {
                        sc = MessageColor.Green;
                    }
                    else
                    {
                        sc = MessageColor.Gray;
                    }
                    Element.TransitionState = 0.0;
                }
                else
                {
                    Element.TransitionState = 1.0;
                    t = "";
                } break;

            default:
                t = Element.Text;
                break;
            }
            // transitions
            float alpha = 1.0f;

            if ((Element.Transition & HUD.Transition.Move) != 0)
            {
                double s = Element.TransitionState;
                x += Element.TransitionVector.X * s * s;
                y += Element.TransitionVector.Y * s * s;
            }
            if ((Element.Transition & HUD.Transition.Fade) != 0)
            {
                alpha = (float)(1.0 - Element.TransitionState);
            }
            else if (Element.Transition == HUD.Transition.None)
            {
                alpha = (float)(1.0 - Element.TransitionState);
            }
            // render
            if (alpha != 0.0f)
            {
                // background
                if (Element.Subject == "reverser")
                {
                    w = Math.Max(w, TrainManager.PlayerTrain.MaxReverserWidth);
                    //X-Pos doesn't need to be changed
                }
                if (Element.Subject == "power")
                {
                    w = Math.Max(w, TrainManager.PlayerTrain.MaxPowerNotchWidth);
                    if (TrainManager.PlayerTrain.MaxReverserWidth > 48)
                    {
                        x += (TrainManager.PlayerTrain.MaxReverserWidth - 48);
                    }
                }
                if (Element.Subject == "brake")
                {
                    w = Math.Max(w, TrainManager.PlayerTrain.MaxBrakeNotchWidth);
                    if (TrainManager.PlayerTrain.MaxReverserWidth > 48)
                    {
                        x += (TrainManager.PlayerTrain.MaxReverserWidth - 48);
                    }
                    if (TrainManager.PlayerTrain.MaxPowerNotchWidth > 48)
                    {
                        x += (TrainManager.PlayerTrain.MaxPowerNotchWidth - 48);
                    }
                }
                if (Element.Subject == "single")
                {
                    w = Math.Max(Math.Max(w, TrainManager.PlayerTrain.MaxPowerNotchWidth), TrainManager.PlayerTrain.MaxBrakeNotchWidth);
                    if (TrainManager.PlayerTrain.MaxReverserWidth > 48)
                    {
                        x += (TrainManager.PlayerTrain.MaxReverserWidth - 48);
                    }
                }
                if (Element.CenterMiddle.BackgroundTexture != null)
                {
                    if (Program.CurrentHost.LoadTexture(Element.CenterMiddle.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        Color128 c = Element.BackgroundColor.CreateBackColor(sc, alpha);
                        renderer.Rectangle.Draw(Element.CenterMiddle.BackgroundTexture, new PointF((float)x, (float)y), new SizeF((float)w, (float)h), new Color128(c.R, c.G, c.B, c.A));
                    }
                }
                {                 // text
                    System.Drawing.Size size = Element.Font.MeasureString(t);
                    float  u = size.Width;
                    float  v = size.Height;
                    double p = Math.Round(Element.TextAlignment.X < 0 ? x : Element.TextAlignment.X == 0 ? x + 0.5 * (w - u) : x + w - u);
                    double q = Math.Round(Element.TextAlignment.Y < 0 ? y : Element.TextAlignment.Y == 0 ? y + 0.5 * (h - v) : y + h - v);
                    p += Element.TextPosition.X;
                    q += Element.TextPosition.Y;
                    Color128 c = Element.TextColor.CreateTextColor(sc, alpha);
                    Program.Renderer.OpenGlString.Draw(Element.Font, t, new System.Drawing.Point((int)p, (int)q), TextAlignment.TopLeft, c, Element.TextShadow);
                }
                // overlay
                if (Element.CenterMiddle.OverlayTexture != null)
                {
                    if (Program.CurrentHost.LoadTexture(Element.CenterMiddle.OverlayTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        Color128 c = Element.OverlayColor.CreateBackColor(sc, alpha);
                        renderer.Rectangle.Draw(Element.CenterMiddle.BackgroundTexture, new PointF((float)x, (float)y), new SizeF((float)w, (float)h), new Color128(c.R, c.G, c.B, c.A));
                    }
                }
            }
        }
Exemple #24
0
			/// <summary>Creates a new sound source.</summary>
			/// <param name="buffer">The sound buffer.</param>
			/// <param name="radius">The effective sound radius.</param>
			/// <param name="pitch">The pitch change factor.</param>
			/// <param name="volume">The volume change factor.</param>
			/// <param name="position">The position. If a train and car are specified, the position is relative to the car, otherwise absolute.</param>
			/// <param name="train">The train this sound source is attached to, or a null reference.</param>
			/// <param name="type">The type of sound</param>
			/// <param name="car">The car this sound source is attached to, or a null reference.</param>
			/// <param name="looped">Whether this sound source plays in a loop.</param>
			internal SoundSource(SoundBuffer buffer, double radius, double pitch, double volume, OpenBveApi.Math.Vector3 position, TrainManager.Train train, SoundType type, int car, bool looped)
			{
				this.Buffer = buffer;
				this.Radius = radius;
				this.Pitch = pitch;
				this.Volume = volume;
				this.Position = position;
				this.Train = train;
				this.Car = car;
				this.Looped = looped;
				this.State = SoundSourceState.PlayPending;
				this.OpenAlSourceName = 0;
				//Set sound type manually
				this.Type = type;
			}
    void cardToPlayer(CardInfo card, PlayerManager thisPlayer)
    {
        TrainConnection thisPlayerStandTrainConnection = thisPlayer.PlayerMoveController.PlayerTrainConnection;

        thisAccountPlayerStandTrainManager = thisPlayerStandTrainConnection.trainManager;

        if (thisPlayer.IsDie)
        {
            reactionManager.SetPlayerDie();
            return;
        }
        thisAccountPlayerManager.SetPlay(true);

        switch (card.cardType)
        {
        case CardType.Up:

            if (thisPlayerStandTrainConnection.nearbyTrain_Up != null)
            {
                thisPlayer.PlayerMoveController.Move(thisPlayerStandTrainConnection.nearbyTrain_Up);
                reactionManager.SetActionSuccess();
            }
            else
            {
                reactionManager.SetActionFail(CardType.Up);
            }

            break;

        case CardType.Down:

            if (thisPlayerStandTrainConnection.nearbyTrain_Down != null)
            {
                thisPlayer.PlayerMoveController.Move(thisPlayerStandTrainConnection.nearbyTrain_Down);
                reactionManager.SetActionSuccess();
            }
            else
            {
                reactionManager.SetActionFail(CardType.Down);
            }

            break;

        case CardType.Left:

            if (thisPlayerStandTrainConnection.nearbyTrain_Left != null)
            {
                thisPlayer.PlayerMoveController.Move(thisPlayerStandTrainConnection.nearbyTrain_Left);
                reactionManager.SetActionSuccess();
            }
            else
            {
                reactionManager.SetActionFail(CardType.Left);
            }

            break;

        case CardType.Right:

            if (thisPlayerStandTrainConnection.nearbyTrain_Right != null)
            {
                thisPlayer.PlayerMoveController.Move(thisPlayerStandTrainConnection.nearbyTrain_Right);
                reactionManager.SetActionSuccess();
            }
            else
            {
                reactionManager.SetActionFail(CardType.Right);
            }

            break;

        case CardType.Pick:

            thisAccountItemHolderList = thisAccountPlayerStandTrainManager.GetAllItemHolder;
            if (thisAccountItemHolderList.Count > 0)
            {
                SetMarkableMark(thisAccountItemHolderList.ToArray(), true);
            }
            else
            {
                reactionManager.SetActionFail(CardType.Pick);
            }

            break;

        case CardType.Punch:

            thisAccountCanAttackPlayerManagerList = thisAccountPlayerStandTrainManager.GetAllPlayerManager;
            if (thisAccountCanAttackPlayerManagerList.Count > 1)
            {
                SetMarkableMark(thisAccountCanAttackPlayerManagerList.ToArray(), thisPlayer, true);
            }
            else
            {
                reactionManager.SetActionFail(CardType.Punch);
            }

            break;

        case CardType.Shot:

            if (thisAccountPlayerManager.PlayerBulletController.BulletCount <= 0)
            {
                reactionManager.SetNoBullet();
                return;
            }

            if (thisAccountPlayerStandTrainManager.IsRoof)
            {
                List <TrainManager> roofTrainManagerList = GameManager.Instance.gamePlayManager.trainCommander.RoofTrainManagerList;

                for (int i = 0; i < roofTrainManagerList.Count; i++)
                {
                    List <PlayerManager> thisRoofPlayerManagerList = roofTrainManagerList [i].GetAllPlayerManager;
                    thisAccountCanAttackPlayerManagerList.AddRange(thisRoofPlayerManagerList);
                }
            }
            else
            {
                if (thisPlayerStandTrainConnection.nearbyTrain_Left != null)
                {
                    TrainManager leftTrainManager = thisPlayerStandTrainConnection.nearbyTrain_Left.trainManager;
                    if (leftTrainManager != null && leftTrainManager.GetAllPlayerManager.Count != 0)
                    {
                        thisAccountCanAttackPlayerManagerList.AddRange(leftTrainManager.GetAllPlayerManager);
                    }
                }
                if (thisPlayerStandTrainConnection.nearbyTrain_Right != null)
                {
                    TrainManager rightTrainManager = thisPlayerStandTrainConnection.nearbyTrain_Right.trainManager;
                    if (rightTrainManager != null && rightTrainManager.GetAllPlayerManager.Count != 0)
                    {
                        thisAccountCanAttackPlayerManagerList.AddRange(rightTrainManager.GetAllPlayerManager);
                    }
                }
            }
            if (thisAccountCanAttackPlayerManagerList.Count > 0)
            {
                SetMarkableMark(thisAccountCanAttackPlayerManagerList.ToArray(), thisPlayer, true);
            }
            else
            {
                reactionManager.SetActionFail(CardType.Shot);
            }

            break;

        case CardType.Police:

            if (policeManager == null)
            {
                policeManager = FindObjectOfType <PoliceManager> ();
            }

            GameManager.Instance.gamePlayManager.cameraController.ForcusOnPos(policeManager.PolicePosition);
            policeManager.ShowPath();

            break;
        }
    }
Exemple #26
0
        public static void client_recievedMessage(object sender, MqttMsgPublishEventArgs e)
        {
            switch (e.Topic)
            {
            case powerUp:
                if (!TrainManager.PlayerTrain.Handles.SingleHandle)
                {
                    int p = TrainManager.PlayerTrain.Handles.Power.Driver;
                    if (p < TrainManager.PlayerTrain.Handles.Power.MaximumNotch)
                    {
                        TrainManager.PlayerTrain.ApplyNotch(1, true, 0, true);
                    }
                }
                TrainManager.PlayerTrain.Handles.Power.ContinuousMovement = true;
                break;

            case powerDown:
                if (!TrainManager.PlayerTrain.Handles.SingleHandle)
                {
                    int p = TrainManager.PlayerTrain.Handles.Power.Driver;
                    if (p > 0)
                    {
                        TrainManager.PlayerTrain.ApplyNotch(-1, true, 0, true);
                    }
                }
                TrainManager.PlayerTrain.Handles.Power.ContinuousMovement = true;
                break;

            case brakeIncrease:
                if (!TrainManager.PlayerTrain.Handles.SingleHandle)
                {
                    if (TrainManager.PlayerTrain.Handles.Brake is TrainManager.AirBrakeHandle)
                    {
                        if (TrainManager.PlayerTrain.Handles.HasHoldBrake &
                            TrainManager.PlayerTrain.Handles.Brake.Driver ==
                            (int)TrainManager.AirBrakeHandleState.Release &
                            !TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                        {
                            TrainManager.PlayerTrain.ApplyHoldBrake(true);
                        }
                        else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                        {
                            TrainManager.PlayerTrain.ApplyAirBrakeHandle(TrainManager.AirBrakeHandleState.Lap);
                            TrainManager.PlayerTrain.ApplyHoldBrake(false);
                        }
                        else if (TrainManager.PlayerTrain.Handles.Brake.Driver ==
                                 (int)TrainManager.AirBrakeHandleState.Lap)
                        {
                            TrainManager.PlayerTrain.ApplyAirBrakeHandle(TrainManager.AirBrakeHandleState.Service);
                        }
                        else if (TrainManager.PlayerTrain.Handles.Brake.Driver ==
                                 (int)TrainManager.AirBrakeHandleState.Release)
                        {
                            TrainManager.PlayerTrain.ApplyAirBrakeHandle(TrainManager.AirBrakeHandleState.Lap);
                        }
                    }
                    else
                    {
                        int b = TrainManager.PlayerTrain.Handles.Brake.Driver;
                        if (TrainManager.PlayerTrain.Handles.HasHoldBrake & b == 0 &
                            !TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                        {
                            TrainManager.PlayerTrain.ApplyHoldBrake(true);
                        }
                        else if (b < TrainManager.PlayerTrain.Handles.Brake.MaximumNotch)
                        {
                            TrainManager.PlayerTrain.ApplyNotch(0, true, 1, true);
                            TrainManager.PlayerTrain.ApplyHoldBrake(false);
                        }
                    }
                }
                TrainManager.PlayerTrain.Handles.Brake.ContinuousMovement = true;
                break;

            case brakeDecrease:
                if (!TrainManager.PlayerTrain.Handles.SingleHandle)
                {
                    if (TrainManager.PlayerTrain.Handles.Brake is TrainManager.AirBrakeHandle)
                    {
                        if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver)
                        {
                            TrainManager.PlayerTrain.UnapplyEmergencyBrake();
                        }
                        else if (TrainManager.PlayerTrain.Handles.HasHoldBrake &
                                 TrainManager.PlayerTrain.Handles.Brake.Driver ==
                                 (int)TrainManager.AirBrakeHandleState.Lap &
                                 !TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                        {
                            TrainManager.PlayerTrain.ApplyHoldBrake(true);
                        }
                        else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                        {
                            TrainManager.PlayerTrain.ApplyAirBrakeHandle(TrainManager.AirBrakeHandleState.Release);
                            TrainManager.PlayerTrain.ApplyHoldBrake(false);
                        }
                        else if (TrainManager.PlayerTrain.Handles.Brake.Driver ==
                                 (int)TrainManager.AirBrakeHandleState.Lap)
                        {
                            TrainManager.PlayerTrain.ApplyAirBrakeHandle(TrainManager.AirBrakeHandleState.Release);
                        }
                        else if (TrainManager.PlayerTrain.Handles.Brake.Driver ==
                                 (int)TrainManager.AirBrakeHandleState.Service)
                        {
                            TrainManager.PlayerTrain.ApplyAirBrakeHandle(TrainManager.AirBrakeHandleState.Lap);
                        }
                    }
                    else
                    {
                        int b = TrainManager.PlayerTrain.Handles.Brake.Driver;
                        if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver)
                        {
                            TrainManager.PlayerTrain.UnapplyEmergencyBrake();
                        }
                        else if (b == 1 & TrainManager.PlayerTrain.Handles.HasHoldBrake)
                        {
                            TrainManager.PlayerTrain.ApplyNotch(0, true, 0, false);
                            TrainManager.PlayerTrain.ApplyHoldBrake(true);
                        }
                        else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver)
                        {
                            TrainManager.PlayerTrain.ApplyHoldBrake(false);
                        }
                        else if (b > 0)
                        {
                            TrainManager.PlayerTrain.ApplyNotch(0, true, -1, true);
                        }
                    }
                }
                TrainManager.PlayerTrain.Handles.Brake.ContinuousMovement = true;
                break;

            case reverserForward:
                if (TrainManager.PlayerTrain.Handles.Reverser.Driver < TrainManager.ReverserPosition.Forwards)
                {
                    TrainManager.PlayerTrain.ApplyReverser(1, true);
                }
                break;

            case reverserBackward:
                // reverser backward
                if (TrainManager.PlayerTrain.Handles.Reverser.Driver > TrainManager.ReverserPosition.Reverse)
                {
                    TrainManager.PlayerTrain.ApplyReverser(-1, true);
                }
                break;

            case doorsLeft:
                if ((TrainManager.GetDoorsState(TrainManager.PlayerTrain, true, false) &
                     TrainManager.TrainDoorState.Opened) == 0)
                {
                    if (TrainManager.PlayerTrain.Specs.DoorOpenMode != TrainManager.DoorMode.Automatic)
                    {
                        TrainManager.OpenTrainDoors(TrainManager.PlayerTrain, true, false);
                    }
                }
                else
                {
                    if (TrainManager.PlayerTrain.Specs.DoorOpenMode != TrainManager.DoorMode.Automatic)
                    {
                        TrainManager.CloseTrainDoors(TrainManager.PlayerTrain, true, false);
                    }
                }
                if (TrainManager.PlayerTrain.Plugin != null)
                {
                    TrainManager.PlayerTrain.Plugin.KeyDown(VirtualKeys.LeftDoors);
                }
                TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar].Doors[0].ButtonPressed = true;
                break;

            case doorsRight:
                if ((TrainManager.GetDoorsState(TrainManager.PlayerTrain, false, true) &
                     TrainManager.TrainDoorState.Opened) == 0)
                {
                    if (TrainManager.PlayerTrain.Specs.DoorOpenMode != TrainManager.DoorMode.Automatic)
                    {
                        TrainManager.OpenTrainDoors(TrainManager.PlayerTrain, false, true);
                    }
                }
                else
                {
                    if (TrainManager.PlayerTrain.Specs.DoorOpenMode != TrainManager.DoorMode.Automatic)
                    {
                        TrainManager.CloseTrainDoors(TrainManager.PlayerTrain, false, true);
                    }
                }
                if (TrainManager.PlayerTrain.Plugin != null)
                {
                    TrainManager.PlayerTrain.Plugin.KeyDown(VirtualKeys.RightDoors);
                }
                TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar].Doors[1].ButtonPressed = true;
                break;

            case sound1:
                Console.WriteLine(Encoding.UTF8.GetString(e.Message));
                if (isSound1Playing)
                {
                    if (Encoding.UTF8.GetString(e.Message) == "i")
                    {
                        isSound1Playing = false;
                        Publish("train/infos/sound1", isSound1Playing.ToString());
                        int d = TrainManager.PlayerTrain.DriverCar;
                        if (TrainManager.PlayerTrain.Cars[d].Horns.Length > 2)
                        {
                            TrainManager.PlayerTrain.Cars[d].Horns[2].Play();
                            if (TrainManager.PlayerTrain.Plugin != null)
                            {
                                TrainManager.PlayerTrain.Plugin.HornBlow(OpenBveApi.Runtime.HornTypes.Music);
                            }
                        }
                        int a = TrainManager.PlayerTrain.DriverCar;
                        TrainManager.PlayerTrain.Cars[a].Horns[2].Stop();
                    }
                }
                else
                {
                    if (Encoding.UTF8.GetString(e.Message) == "m")
                    {
                        isSound1Playing = true;
                        Publish("train/infos/sound1", isSound1Playing.ToString());
                        int d = TrainManager.PlayerTrain.DriverCar;
                        if (TrainManager.PlayerTrain.Cars[d].Horns.Length > 2)
                        {
                            TrainManager.PlayerTrain.Cars[d].Horns[2].Play();
                            if (TrainManager.PlayerTrain.Plugin != null)
                            {
                                TrainManager.PlayerTrain.Plugin.HornBlow(OpenBveApi.Runtime.HornTypes.Music);
                            }
                        }
                        int a = TrainManager.PlayerTrain.DriverCar;
                        TrainManager.PlayerTrain.Cars[a].Horns[2].Stop();
                    }
                }

                break;

            case sound2:
                if (isSound2Playing)
                {
                    if (Encoding.UTF8.GetString(e.Message) == "i")
                    {
                        isSound2Playing = false;
                        Publish("train/infos/sound2", isSound2Playing.ToString());
                        int q = TrainManager.PlayerTrain.DriverCar;
                        if (TrainManager.PlayerTrain.Cars[q].Horns.Length > 1)
                        {
                            TrainManager.PlayerTrain.Cars[q].Horns[1].Play();
                            if (TrainManager.PlayerTrain.Plugin != null)
                            {
                                TrainManager.PlayerTrain.Plugin.HornBlow(OpenBveApi.Runtime.HornTypes.Music);
                            }
                        }
                        int f = TrainManager.PlayerTrain.DriverCar;
                        TrainManager.PlayerTrain.Cars[f].Horns[1].Stop();
                    }
                }
                else
                {
                    if (Encoding.UTF8.GetString(e.Message) == "m")
                    {
                        isSound2Playing = true;
                        Publish("train/infos/sound2", isSound2Playing.ToString());
                        int q = TrainManager.PlayerTrain.DriverCar;
                        if (TrainManager.PlayerTrain.Cars[q].Horns.Length > 1)
                        {
                            TrainManager.PlayerTrain.Cars[q].Horns[1].Play();
                            if (TrainManager.PlayerTrain.Plugin != null)
                            {
                                TrainManager.PlayerTrain.Plugin.HornBlow(OpenBveApi.Runtime.HornTypes.Music);
                            }
                        }
                        int f = TrainManager.PlayerTrain.DriverCar;
                        TrainManager.PlayerTrain.Cars[f].Horns[1].Stop();
                    }
                }

                break;

            default:
                break;
            }
        }
    void Start()
    {
        speed = avgSpeed;

        manager = GetComponent <TrainManager>();
    }
Exemple #28
0
 /// <summary>
 /// Finds all required scripts
 /// </summary>
 public void Awake()
 {
     trackManager = GameObject.Find("Track Manager").GetComponent <TrackManager>();
     trainManager = GameObject.Find("Train Manager").GetComponent <TrainManager>();
 }
 // Start is called before the first frame update
 void Start()
 {
     trainManager = FindObjectOfType <TrainManager>();
 }
        public TrainAdd_NameType_Page(Page old, Train _t = null)
        {
            try
            {
                InitializeComponent();
                AddControl(this);

                OldPage = old;
                t       = _t;

                Title     = TextManager.Get().Text("addtrain");
                IconImg   = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "ico_timetable.png", 5, 7, 1, 6));
                imgAdd    = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_add.png", 5, 7, 1, 6));
                imgAddSel = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_add_sel.png", 5, 7, 1, 6));

                lbBack.ForeColor = ResourceManager.Get("trainadd.back.unsel");
                lbBack.SelColor  = ResourceManager.Get("trainadd.back.sel");
                lbBack.Font      = new Font(RTCore.Environment.Font, 20);
                lbBack.Text      = TextManager.Get().Text("back");
                lbBack.Location  = new Point(25, 553);

                lbAdd.ForeColor = ResourceManager.Get("trainadd.add.unsel");
                lbAdd.SelColor  = ResourceManager.Get("trainadd.add.sel");
                lbAdd.Font      = new Font(RTCore.Environment.Font, 20);
                lbAdd.Text      = TextManager.Get().Text("buy");
                lbAdd.Location  = new Point(Width - 25 - lbAdd.Width, 553);

                txtName.Text = "txtName";

                cbType.SelectedIndexChanged += delegate
                {
                    txtName.Text = TrainManager.SetTrainNameAuto(TrainManager.TrainDatas[cbType.SelectedIndex]);
                    GameManager.LastSelectTrainData = cbType.SelectedIndex;
                };
                cbType.Name = "cbType";
                cbType.Font = new Font(RTCore.Environment.Font, 20);
                cbType.Size = new Size(455, cbType.Height);
                ReAddItem();
                cbType.DropDownStyle = ComboBoxStyle.DropDownList;
                cbType.Location      = new Point((Width / 2) - 250, (Height / 2) - 75);
                Controls.Add(cbType);

                txtName.Font      = new Font(RTCore.Environment.Font, 20);
                txtName.Size      = new Size(500, txtName.Height);
                txtName.Location  = new Point(cbType.Location.X, cbType.Location.Y + cbType.Height + 80);
                txtName.MaxLength = 40;
                Controls.Add(txtName);

                pbDataAdd.Name        = "pbDataAdd";
                pbDataAdd.Location    = new Point(cbType.Location.X + cbType.Width + 10, cbType.Location.Y);
                pbDataAdd.Size        = new Size(cbType.Height, cbType.Height);
                pbDataAdd.SizeMode    = PictureBoxSizeMode.StretchImage;
                pbDataAdd.Image       = imgAdd;
                pbDataAdd.MouseEnter += delegate
                {
                    pbDataAdd.Image = imgAddSel;
                };
                pbDataAdd.MouseLeave += delegate
                {
                    pbDataAdd.Image = imgAdd;
                };
                pbDataAdd.Click += delegate
                {
                    PageManager.SetPage(new TrainDataAdd_Name_Page(this), AccessManager.AccessKey);
                };
                Controls.Add(pbDataAdd);

                lbInfo.Font     = new Font(RTCore.Environment.Font, 12);
                lbInfo.Location = new Point(txtName.Location.X, txtName.Location.Y + txtName.Height + 7);
                SetTextInfo();
                cbType.SelectedIndexChanged += delegate
                {
                    SetTextInfo();
                };

                picDataIcon.Location = new Point(Width - (Width - (txtName.Width + txtName.Location.X)) - 100, txtName.Location.Y + txtName.Height + 5);
            }
            catch (Exception ex)
            {
                RTCore.Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }