Пример #1
0
        public void Execute(AllCars allCars, int activePLID)
        {
            int heading       = allCars.GetCarByPLID(activePLID).heading;
            int AmmountOfCars = allCars.Length();

            carHeadingsDiff = new UInt16[AmmountOfCars];

            for (int index = 0; index < AmmountOfCars; index++)
            {
                carHeadingsDiff[index] = (UInt16)Math.Abs(heading - allCars.GetCarByIndex(index).heading);
                int distance = allCars.GetCarByPLID(activePLID).GetDistanceToAnotherCar(allCars.GetCarByIndex(index));

                warningColors[index] = 9;
                if (carHeadingsDiff[index] < 270 && carHeadingsDiff[index] > 90 && distance < 300)
                {
                    warningColors[index] = 3;
                }
                if (carHeadingsDiff[index] < 210 && carHeadingsDiff[index] > 150 && distance < 300)
                {
                    warningColors[index] = 1;
                }
            }

            //if (parameters.showDanger) { buttons.DangerAhead(_inSim, color); } else { buttons.DangerAheadClear(_inSim); }
        }
Пример #2
0
        public void Execute(Parameters parameters, AllCars allCars, Commands commands, InSimDotNet.InSim _inSim, Buttons buttons)
        {
            if (parameters.dragMode)
            {
                if (parameters.dragPickPlayer1)
                {
                    dragPlayer1PLID = -1;
                    dragPlayer2PLID = -1;
                    player1Distance = 0;
                    player2Distance = 0;
                }

                if (parameters.dragPickPlayer1 && parameters.playerIndexChanged)
                {
                    int listID = parameters.playerIndexFromList;
                    dragPlayer1PLID = allCars.GetCarByIndex(listID).PLID;

                    parameters.dragPickPlayer1    = false;
                    parameters.dragPickPlayer2    = true;
                    parameters.playerIndexChanged = false;
                }

                if (parameters.dragPickPlayer2 && parameters.playerIndexChanged)
                {
                    int listID = parameters.playerIndexFromList;
                    dragPlayer2PLID = allCars.GetCarByIndex(listID).PLID;

                    parameters.dragPickPlayer2    = false;
                    parameters.dragReady          = true;
                    parameters.playerIndexChanged = false;
                }

                if (parameters.dragStarted)
                {
                    bool goodStart = true;
                    if (allCars.GetCarByPLID(dragPlayer1PLID).rawSpeed > 100)
                    {
                        string name = allCars.GetCarByPLID(dragPlayer1PLID).playerName;
                        commands.SendCommandMessage(_inSim, "/msg ^7Blogas Startas: ^8" + name);
                        goodStart = false;
                    }
                    if (allCars.GetCarByPLID(dragPlayer2PLID).rawSpeed > 100)
                    {
                        string name = allCars.GetCarByPLID(dragPlayer2PLID).playerName;
                        commands.SendCommandMessage(_inSim, "/msg ^7Blogas Startas: ^8" + name);
                        goodStart = false;
                    }
                    if (!goodStart)
                    {
                        parameters.dragStarted = false;
                    }
                }

                if (parameters.dragRunning)
                {
                    player1Distance += allCars.GetCarByPLID(dragPlayer1PLID).tickDistance;
                    player2Distance += allCars.GetCarByPLID(dragPlayer2PLID).tickDistance;

                    if (player1Distance > distanceToDrive || player2Distance > distanceToDrive)
                    {
                        if (player1Distance > player2Distance)
                        {
                            String output = "/msg " + allCars.GetCarByPLID(dragPlayer1PLID).playerName + "^7 Laimėjo";
                            commands.SendCommandMessage(_inSim, output);
                            parameters.dragRunning = false;
                        }
                        else
                        {
                            String output = "/msg " + allCars.GetCarByPLID(dragPlayer2PLID).playerName + "^7 Laimėjo";
                            commands.SendCommandMessage(_inSim, output);
                            parameters.dragRunning = false;
                        }
                    }
                }

                if (parameters.dragPrintPlayer1)
                {
                    string name = "None";
                    if (dragPlayer1PLID != -1)
                    {
                        name = allCars.GetCarByPLID(dragPlayer1PLID).playerName;
                    }
                    commands.SendCommandMessage(_inSim, "/msg ^7Dalyvis Nr1: ^8" + name);
                    parameters.dragPrintPlayer1 = false;
                }

                if (parameters.dragPrintPlayer2)
                {
                    string name = "None";
                    if (dragPlayer1PLID != -1)
                    {
                        name = allCars.GetCarByPLID(dragPlayer2PLID).playerName;
                    }
                    commands.SendCommandMessage(_inSim, "/msg ^7Dalyvis Nr2: ^8" + name);
                    parameters.dragPrintPlayer2 = false;
                }

                if (parameters.dragPrintDistance)
                {
                    commands.SendCommandMessage(_inSim, "/msg ^7Drago atstumas: ^3" + distanceToDrive / 1000 + "^7 metrų");
                    parameters.dragPrintDistance = false;
                }

                if (parameters.dragLights)
                {
                    parameters.dragLights = false;
                    new Thread(() =>
                    {
                        Thread.CurrentThread.IsBackground = true;
                        DragLights(parameters, commands, _inSim);
                        parameters.dragStarted = false;
                    }).Start();
                }

                string dragPlayerName1 = "None";
                if (dragPlayer1PLID != -1)
                {
                    dragPlayerName1 = allCars.GetCarByPLID(dragPlayer1PLID).playerName;
                }

                string dragPlayerName2 = "None";
                if (dragPlayer2PLID != -1)
                {
                    dragPlayerName2 = allCars.GetCarByPLID(dragPlayer2PLID).playerName;
                }
                buttons.ShowDragMenu(_inSim, parameters, dragPlayerName1, dragPlayerName2, distanceToDrive);
            }
        }