// Registering the spawned vehicle as player vehicle, enabling controllable.
    public void SelectVehicle()
    {
        // Registers the vehicle as player vehicle.
        RCC.RegisterPlayerVehicle(_spawnedVehicles[selectedIndex]);

        // Starts engine and enabling controllable when selected.
        _spawnedVehicles [selectedIndex].StartEngine();
        _spawnedVehicles [selectedIndex].SetCanControl(true);

        // Save the selected vehicle for instantianting it on next scene.
        PlayerPrefs.SetInt("SelectedRCCVehicle", selectedIndex);

        // If RCC Camera is choosen, it will disable RCC_CameraCarSelection script. This script was used for orbiting camera.
        if (RCCCamera)
        {
            if (RCCCamera.GetComponent <RCC_CameraCarSelection> ())
            {
                RCCCamera.GetComponent <RCC_CameraCarSelection> ().enabled = false;
            }
        }

        if (nextScene != "")
        {
            OpenScene();
        }
    }
    // Deactivates selected vehicle and returns to the car selection.
    public void DeSelectVehicle()
    {
        // De-registers the vehicle.
        RCC.DeRegisterPlayerVehicle();

        // Resets position and rotation.
        _spawnedVehicles[selectedIndex].transform.position = spawnPosition.position;
        _spawnedVehicles[selectedIndex].transform.rotation = spawnPosition.rotation;

        // Kills engine and disables controllable.
        _spawnedVehicles[selectedIndex].KillEngine();
        _spawnedVehicles[selectedIndex].SetCanControl(false);

        // Resets the velocity of the vehicle.
        _spawnedVehicles[selectedIndex].GetComponent <Rigidbody>().ResetInertiaTensor();
        _spawnedVehicles[selectedIndex].GetComponent <Rigidbody>().velocity        = Vector3.zero;
        _spawnedVehicles[selectedIndex].GetComponent <Rigidbody>().angularVelocity = Vector3.zero;

        // If RCC Camera is choosen, it wil enable RCC_CameraCarSelection script. This script was used for orbiting camera.
        if (RCCCamera)
        {
            if (RCCCamera.GetComponent <RCC_CameraCarSelection>())
            {
                RCCCamera.GetComponent <RCC_CameraCarSelection>().enabled = true;
            }
        }
    }
Esempio n. 3
0
        Boolean checkResponse(byte[] buf, RCC cmd, ref string s)
        {
            // Check negative/positive
            switch (buf[2])
            {
            case 0x50: // Positive
                s = p_res;
                addPosErr(ref s, BytesToUShort(Take(buf, 5, 2)));
                break;

            case 0x4E: // Negative
                s = n_res;
                addNegErr(ref s, BytesToUShort(Take(buf, 5, 2)));
                break;

            default: // Undefined
                s = u_res;
                return(false);
            }
            ;

            // Check command
            if (BytesToUShort(Take(buf, 3, 2)) != (ushort)cmd)
            {
                s += err_Cmd;
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        // 'Read Track' function
        //
        //  X - track number (1, 2, 3)
        //  result - result description
        //  track - Read track
        //
        //  RC:
        //      true  - success
        //      false -
        public Boolean readTrackX(int X, ref string result, ref byte[] track)
        {
            RCC cmd = 0;

            switch (X)
            {
            case 1: cmd = RCC.readTrack1; break;

            case 2: cmd = RCC.readTrack2; break;

            case 3: cmd = RCC.readTrack3; break;

            default: result = err_Fatal; return(false);
            }

            byte[] resp = null;
            if (!processPacket(cmd, ref resp, ref result))
            {
                return(false);
            }
            if (resp == null)
            {
                result = err_Fatal; return(false);
            }

            return(getTextFromResp(resp, ref track, ref result));
        }
        public static string Solve(string url, string id)
        {
            new WebClient().DownloadFile(url, id + ".png");
            string captchaId = "";

            try
            {
                captchaId = RCC.UploadCaptchaFile(id + ".png");
            }
            finally
            {
                File.Delete(id + ".png");
            }
            string text = null;

            while (string.IsNullOrEmpty(text))
            {
                Thread.Sleep(1000);
                try
                {
                    text = RCC.GetCaptcha(captchaId);
                }
                catch (Exception ex)
                {
                    if (!ex.Message.Contains("CAPCHA_NOT_READY"))
                    {
                        Log.Push("[Ошибка обработки captcha]: " + ex.Message);
                    }
                }
            }
            Log.Push("[captcha]: распознавание завершено");
            return(text);
        }
    private void CreateVehicles()
    {
        for (int i = 0; i < RCC_DemoVehicles.Instance.vehicles.Length; i++)
        {
            // Spawning the vehicle with no controllable, no player, and engine off. We don't want to let player control the vehicle while in selection menu.
            RCC_CarControllerV3 spawnedVehicle = RCC.SpawnRCC(RCC_DemoVehicles.Instance.vehicles[i], spawnPosition.position, spawnPosition.rotation, false, false, false);

            // Disabling spawned vehicle.
            spawnedVehicle.gameObject.SetActive(false);

            // Adding and storing it in _spawnedVehicles list.
            _spawnedVehicles.Add(spawnedVehicle);
        }

        SpawnVehicle();

        // If RCC Camera is choosen, it wil enable RCC_CameraCarSelection script. This script was used for orbiting camera.
        if (RCCCamera)
        {
            if (RCCCamera.GetComponent <RCC_CameraCarSelection> ())
            {
                RCCCamera.GetComponent <RCC_CameraCarSelection> ().enabled = true;
            }
        }
    }
Esempio n. 7
0
    /// <summary>
    /// Add a new Remote Creation Call.
    /// </summary>

    static void AddRCCs(object obj, System.Type type)
    {
        MethodInfo[] methods = type.GetMethods(
            BindingFlags.Public |
            BindingFlags.NonPublic |
            BindingFlags.Instance |
            BindingFlags.Static);

        for (int b = 0; b < methods.Length; ++b)
        {
            if (methods[b].IsDefined(typeof(RCC), true))
            {
                RCC tnc = (RCC)methods[b].GetCustomAttributes(typeof(RCC), true)[0];

                for (int i = 0; i < mRCCs.size; ++i)
                {
                    CachedFunc f = mRCCs[i];

                    if (f.id == tnc.id)
                    {
                        f.obj  = obj;
                        f.func = methods[b];
                        return;
                    }
                }

                CachedFunc ent = new CachedFunc();
                ent.obj  = obj;
                ent.func = methods[b];
                ent.id   = tnc.id;
                mRCCs.Add(ent);
            }
        }
    }
Esempio n. 8
0
        Boolean processPacket(RCC cmd, byte[] data,
                              ref byte[] resp, ref string result)
        {
            // Send Command
            if (!sendCmd(cmd, data))
            {
                result = err_Fatal; return(false);
            }

            // Wait ACK/NAK
            if (!waitAckNak(ref result))
            {
                return(false);
            }

            // DLE ENQ - Response Request
            sendEnq();

            int respL = 0;

            switch (cmd)
            {
            case RCC.readTrack1: respL = res_tr1_l; break;

            case RCC.readTrack2: respL = res_tr2_l; break;

            case RCC.readTrack3: respL = res_tr3_l; break;

            default: respL = common_res_l; break;
            }
            resp = new byte[respL];
            int offset = 0;

            // Response waiting timeout - 30 sec (5.02 sec minimum)
            var timerTh = new Thread(() => { Thread.Sleep(30 * 1000); });

            timerTh.Start();
            while (offset < respL && !checkPktEnd(resp, offset) && timerTh.IsAlive)
            {
                if (hPort.BytesToRead > 0)
                {
                    offset += hPort.Read(resp, offset, respL - offset);
                }
            }
            timerTh.Abort();

            Array.Resize(ref resp, offset);
            if (!checkResponse(resp, cmd, ref result))
            {
                return(false);
            }
            if (!checkPkt(resp, ref result))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 9
0
    void OnTriggerEnter(Collider col)
    {
        RCC_CarControllerV3 carController = col.gameObject.GetComponentInParent <RCC_CarControllerV3> ();

        if (!carController)
        {
            return;
        }

        RCC.Transport(spawnPoint.position, spawnPoint.rotation);
    }
Esempio n. 10
0
        public static string GetBalance()
        {
            string result;

            if (RCC != null)
            {
                result = RCC.GetBalance().ToString();
            }
            else
            {
                result = "?";
            }
            return(result);
        }
Esempio n. 11
0
    /// <summary>
    /// Remove previously registered Remote Creation Calls.
    /// </summary>

    static void RemoveRCCs <T> ()
    {
        MethodInfo[] methods = typeof(T).GetMethods(
            BindingFlags.Public |
            BindingFlags.NonPublic |
            BindingFlags.Instance |
            BindingFlags.Static);

        for (int b = 0; b < methods.Length; ++b)
        {
            if (methods[b].IsDefined(typeof(RCC), true))
            {
                RCC tnc = (RCC)methods[b].GetCustomAttributes(typeof(RCC), true)[0];
                RemoveRCC(tnc.id);
            }
        }
    }
Esempio n. 12
0
    // Registering the spawned vehicle as player vehicle, enabling controllable.
    public void SelectVehicle()
    {
        // Registers the vehicle as player vehicle.
        RCC.RegisterPlayerVehicle(_spawnedVehicles[selectedIndex]);

        // Starts engine and enabling controllable when selected.
        _spawnedVehicles [selectedIndex].StartEngine();
        _spawnedVehicles [selectedIndex].SetCanControl(true);

        // If RCC Camera is choosen, it will disable RCC_CameraCarSelection script. This script was used for orbiting camera.
        if (RCCCamera)
        {
            if (RCCCamera.GetComponent <RCC_CameraCarSelection> ())
            {
                RCCCamera.GetComponent <RCC_CameraCarSelection> ().enabled = false;
            }
        }
    }
    // Registering the spawned vehicle as player vehicle, enabling controllable.
    public void SelectVehicle()
    {
        // Registers the vehicle as player vehicle.
        RCC.RegisterPlayerVehicle(_spawnedVehicles[selectedIndex]);


        // Starts engine and enabling controllable when selected.
        //_spawnedVehicles [selectedIndex].StartEngine ();
        //s_spawnedVehicles [selectedIndex].SetCanControl(true);

        // Save the selected vehicle for instantianting it on next scene.
        PlayerPrefs.SetInt("SelectedRCCVehicle", selectedIndex);

        if (selectedIndex == 0)
        {
            PlayerPrefs.SetString("SelectedCar", "Tiger");
        }
        if (selectedIndex == 1)
        {
            PlayerPrefs.SetString("SelectedCar", "Panzer");
        }
        if (selectedIndex == 2)
        {
            PlayerPrefs.SetString("SelectedCar", "Legion");
        }
        if (selectedIndex == 3)
        {
            PlayerPrefs.SetString("SelectedCar", "Arrow");
        }


        //PlayerPrefs.SetInt("selectedCharacter", selectedCharacter);
        // If RCC Camera is choosen, it will disable RCC_CameraCarSelection script. This script was used for orbiting camera.
        //if (RCCCamera) {

        //	if (RCCCamera.GetComponent<RCC_CameraCarSelection> ())
        //		RCCCamera.GetComponent<RCC_CameraCarSelection> ().enabled = false;

        //}

        //if(nextScene != "")
        //OpenScene ();
    }
Esempio n. 14
0
        // 'Write Track' function
        //
        //  X - track number (1, 2, 3)
        //  result - result description
        //  track - Track to write
        //
        //  RC:
        //      true  - success
        //      false -
        public Boolean writeTrackX(int X, ref string result, byte[] track)
        {
            if (track == null)
            {
                return(false);
            }
            RCC cmd = 0;

            switch (X)
            {
            case 1: cmd = RCC.writeTrack1; break;

            case 2: cmd = RCC.writeTrack2; break;

            case 3: cmd = RCC.writeTrack3; break;

            default: result = err_Fatal; return(false);
            }
            return(processPacket(cmd, track, ref result));
        }
Esempio n. 15
0
    // Sets the mobile controller type.
    public void SetMobileController(int index)
    {
        switch (index)
        {
        case 0:
            RCC.SetMobileController(RCC_Settings.MobileController.TouchScreen);
            break;

        case 1:
            RCC.SetMobileController(RCC_Settings.MobileController.Gyro);
            break;

        case 2:
            RCC.SetMobileController(RCC_Settings.MobileController.SteeringWheel);
            break;

        case 3:
            RCC.SetMobileController(RCC_Settings.MobileController.Joystick);
            break;
        }
    }
Esempio n. 16
0
        // Send Command (DLE STX 'C' cmd prm DLE ETX BCC)
        Boolean sendCmd(RCC cmd, byte[] prm)
        {
            var len = start_stop_seq_l + // DLE STX ... DLE ETX BCC (5 bytes)
                      cmd_fixed_part_l + // 'C' XX (XX - Command) (3 bytes)
                      ((prm != null) ? prm.Length : 0);

            byte[] b = new byte[len];
            b[0] = (byte)TCC.DLE;
            b[1] = (byte)TCC.STX;
            b[2] = 0x43; // "C"
            b[3] = (byte)((UInt16)cmd / 0x100);
            b[4] = (byte)((UInt16)cmd % 0x100);;
            ///////////
            if (prm != null)
            {
                int i, j;
                for (i = 0, j = 5; i < prm.Length; i++, j++)
                {
                    // if DLE character is used in prm, double DLE
                    if (prm[i] == (byte)TCC.DLE)
                    {
                        len++;
                        Array.Resize(ref b, len);
                        b[j++] = prm[i];
                    }
                    b[j] = prm[i];
                }
            }
            ///////////
            b[b.Length - 3] = (byte)TCC.DLE;
            b[b.Length - 2] = (byte)TCC.ETX;
            Boolean res = false;

            b[b.Length - 1] = bcc(b, ref res);
            if (res)
            {
                hPort.Write(b, 0, b.Length);
            }
            return(res);
        }
Esempio n. 17
0
        /// <summary>
        /// Randomly generates a firm object (production technology and output market parameters).
        /// </summary>
        /// <param name="ip">A pointer to the collection of input parameters.</param>
        /// <param name="FirmID">Unique identifier for this firm (run number)</param>
        public Firm(InputParameters ip, int FirmID)
        {
            // Choose random values for DISP2 (the top DISP1 resources
            // account for DISP2 percent of total resource costs), and
            // density (sparsity) of resource consumption pattern matrix
            this.g = GenRandNumbers.GenUniformDbl(ip.DISP2_MIN, ip.DISP2_MAX);
            this.d = GenRandNumbers.GenUniformDbl(ip.DNS_MIN, ip.DNS_MAX);

            // Generate the true product margins and the true, optimal
            // decision vector. Keep generating new margins until there
            // is at least one product in the optimal mix.
            RowVector MAR, DECT0;

            do
            {
                MAR   = this.GenMargins(ip);
                DECT0 = MAR.Map(x => (x < 1.0) ? 0.0 : 1.0);
            } while (DECT0.TrueForAll(x => x == 0.0));

            // Generate vector of maximum production quantities
            this.mxq = this.GenMXQ(ip);
            // And associated vector of optimal production quantities
            ColumnVector QT = mxq.ewMultiply(DECT0);

            // Flowchart 5.1 - Create resource consumption pattern matrix
            this.res_cons_pat = GenResConsPat(ip);

            // Flowchart 5.2 - Compute TRU
            // Calculate vector of total units of resource
            // consumption, by product
            ColumnVector TRU = this.CalcResConsumption(QT);

            // Flowchart 5.3 - Compute MAXRU
            // Calculate resource consumption under the assumption
            // that all products are produced at maximum quantity
            ColumnVector MAXRU = this.CalcResConsumption(mxq);

            RowVector RCC, PC_B, RCCN;
            double    TCT0;

            #region Flowchart 5.4 - Generate RCC, RCU, and RCCN

            /* -------------------------------- */
            // Flowchart 5.4(a)-(g)

            // Generate vector of total resource costs (RCC)
            RCC = GenRCC(ip);

            /* -------------------------------- */
            // Flowchart 5.4(h)

            // Now generate unit resource costs (RCU) by doing element-wise
            // division of RCC by MAXRU
            this.rcu = RCC.Map((x, i) => x / MAXRU[i]);

            /* -------------------------------- */
            // Flowchart 5.4(i)

            // Compute new RCC vector (RCCN) based on unit resource
            // costs (RCU) and true unit resource consumption (TRU)
            RCCN = this.rcu.ewMultiply(TRU);
            // Check to see if the first resource (RCCN[0]) is the largest.
            // If not, increase RCU[0] by just enough to make it so.
            if (RCCN[0] < RCCN.Skip(1).Max() + 1)
            {
                RCCN[0]     = Math.Ceiling(RCCN.Max()) + 1.0;
                this.rcu[0] = RCCN[0] / TRU[0];
            }

            #endregion

            // Flowchart 5.5 - Calculate PC_B
            // Calculate true unit product costs
            PC_B = this.CalcTrueProductCosts();

            // Flowchart 5.6 - Compute total costs TCT0
            // Compute total costs
            TCT0 = this.CalcTotCosts(QT);

            // Flowchart 5.7 - Rename RCCN to RCC
            RCC         = RCCN;
            initial_rcc = RCC;

            #region Flowchart 5.8 - Calculate SP, TRV0, PROFITT0

            // Calculate product selling prices, total revenue, and profit
            this.sp = PC_B.ewMultiply(MAR);
            double TRV0 = this.sp * QT;
            this.profitt0 = TRV0 - TCT0;

            #endregion

            // 5.9(a) Create RANK vector
            // Note: this method provides a stable sort. It's important to use a stable sort.
            // LOOKUP IN VERSION.TXT WHY IT'S IMPORTANT TO USE A STABLE SORT HERE.
            initial_rank = Enumerable.Range(0, RCC.Dimension).OrderByDescending(i => RCC[i]).ToArray();

            #region Flowchart 5.9(b) - Create RES_CONS_PAT_PRCT

            this.res_cons_pat_prct = new RectangularMatrix(ip.RCP, ip.CO);

            for (int r = 0; r < this.res_cons_pat.RowCount; ++r)
            {
                RowVector rv = this.res_cons_pat.Row(r);
                if (TRU[r] != 0.0)
                {
                    rv = rv.Map((alt_ij, col) => alt_ij * QT[col] / TRU[r]);
                    if (Math.Abs(rv.Sum() - 1.0) > 0.01)
                    {
                        throw new ApplicationException("Sum of row of RES_CONS_PAT_PRCT not equal to 1.");
                    }
                }
                else
                {
                    rv = rv.Map(alt_ij => 0.0);
                }

                this.res_cons_pat_prct.CopyRowInto(rv, r);
            }

            #endregion

            #region Flowchart 5.9(c) - Create correlation matrix
            // Create correlation matrix for rows of RES_CONS_PAT_PRCT
            MultivariateSample mvs = new MultivariateSample(ip.RCP);
            for (int c = 0; c < this.res_cons_pat_prct.ColumnCount; ++c)
            {
                mvs.Add(this.res_cons_pat_prct.Column(c));
            }

            this.pearsoncorr = new SymmetricMatrix(ip.RCP);

            for (int i = 0; i < mvs.Dimension; ++i)
            {
                for (int j = i; j < mvs.Dimension; ++j)
                {
                    //PearsonCorr[i, j] = mvs.PearsonRTest( i, j ).Statistic;
                    this.pearsoncorr[i, j] = mvs.TwoColumns(i, j).PearsonRTest().Statistic;
                }
            }

            #endregion

            // Flowchart 5.10 - Logging true system
            // Note: I'm deliberately passing copies of the fields MXQ, SP, etc.
            Output.LogFirm(
                ip, this, FirmID,
                MAR, DECT0,
                TRV0, TCT0, profitt0,
                RCC);
        }
Esempio n. 18
0
 Boolean processPacket(RCC cmd, ref string result)
 {
     byte[] resp = null;
       return processPacket(cmd, null, ref resp, ref result);
 }
Esempio n. 19
0
    private void OnClicked()
    {
        if (!RCC_SceneManager.Instance.activePlayerVehicle)
        {
            return;
        }

        switch (_buttonType)
        {
        case ButtonType.Start:

            RCC_SceneManager.Instance.activePlayerVehicle.KillOrStartEngine();

            break;

        case ButtonType.ABS:

            RCC_SceneManager.Instance.activePlayerVehicle.ABS = !RCC_SceneManager.Instance.activePlayerVehicle.ABS;

            break;

        case ButtonType.ESP:

            RCC_SceneManager.Instance.activePlayerVehicle.ESP = !RCC_SceneManager.Instance.activePlayerVehicle.ESP;

            break;

        case ButtonType.TCS:

            RCC_SceneManager.Instance.activePlayerVehicle.TCS = !RCC_SceneManager.Instance.activePlayerVehicle.TCS;

            break;

        case ButtonType.SH:

            RCC_SceneManager.Instance.activePlayerVehicle.steeringHelper = !RCC_SceneManager.Instance.activePlayerVehicle.steeringHelper;

            break;

        case ButtonType.Headlights:

            if (!RCC_SceneManager.Instance.activePlayerVehicle.highBeamHeadLightsOn && RCC_SceneManager.Instance.activePlayerVehicle.lowBeamHeadLightsOn)
            {
                RCC_SceneManager.Instance.activePlayerVehicle.highBeamHeadLightsOn = true;
                RCC_SceneManager.Instance.activePlayerVehicle.lowBeamHeadLightsOn  = true;
                break;
            }

            if (!RCC_SceneManager.Instance.activePlayerVehicle.lowBeamHeadLightsOn)
            {
                RCC_SceneManager.Instance.activePlayerVehicle.lowBeamHeadLightsOn = true;
            }

            if (RCC_SceneManager.Instance.activePlayerVehicle.highBeamHeadLightsOn)
            {
                RCC_SceneManager.Instance.activePlayerVehicle.lowBeamHeadLightsOn  = false;
                RCC_SceneManager.Instance.activePlayerVehicle.highBeamHeadLightsOn = false;
            }

            break;

        case ButtonType.LeftIndicator:

            if (RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn != RCC_CarControllerV3.IndicatorsOn.Left)
            {
                RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn = RCC_CarControllerV3.IndicatorsOn.Left;
            }
            else
            {
                RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn = RCC_CarControllerV3.IndicatorsOn.Off;
            }

            break;

        case ButtonType.RightIndicator:

            if (RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn != RCC_CarControllerV3.IndicatorsOn.Right)
            {
                RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn = RCC_CarControllerV3.IndicatorsOn.Right;
            }
            else
            {
                RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn = RCC_CarControllerV3.IndicatorsOn.Off;
            }

            break;

        case ButtonType.HazardLights:

            if (RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn != RCC_CarControllerV3.IndicatorsOn.All)
            {
                RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn = RCC_CarControllerV3.IndicatorsOn.All;
            }
            else
            {
                RCC_SceneManager.Instance.activePlayerVehicle.indicatorsOn = RCC_CarControllerV3.IndicatorsOn.Off;
            }

            break;

        case ButtonType.Low:

            QualitySettings.SetQualityLevel(1);

            break;

        case ButtonType.Med:

            QualitySettings.SetQualityLevel(3);

            break;

        case ButtonType.High:

            QualitySettings.SetQualityLevel(5);

            break;

        case ButtonType.GearUp:

            RCC_SceneManager.Instance.activePlayerVehicle.GearShiftUp();

            break;

        case ButtonType.GearDown:

            RCC_SceneManager.Instance.activePlayerVehicle.GearShiftDown();

            break;

        case ButtonType.SlowMo:

            if (Time.timeScale != .2f)
            {
                Time.timeScale = .2f;
            }
            else
            {
                Time.timeScale = 1f;
            }

            break;

        case ButtonType.Record:

            RCC.StartStopRecord();

            break;

        case ButtonType.Replay:

            RCC.StartStopReplay();

            break;

        case ButtonType.Neutral:

            RCC.StopRecordReplay();

            break;

        case ButtonType.ChangeCamera:

            RCC.ChangeCamera();

            break;
        }

        Check();
    }
Esempio n. 20
0
 //	Sets the main controller type.
 public void SetController(int index)
 {
     RCC.SetController(index);
 }
Esempio n. 21
0
 // Here we are setting new selected behavior to corresponding one.
 public void InitBehavior()
 {
     RCC.SetBehavior(selectedBehaviorIndex);
 }
Esempio n. 22
0
        Boolean processPacket(RCC cmd, byte[] data, 
                          ref byte[] resp, ref string result)
        {
            // Send Command
              if (!sendCmd(cmd, data)) { result = err_Fatal; return false; }

              // Wait ACK/NAK
              if (!waitAckNak(ref result)) return false;

              // DLE ENQ - Response Request
              sendEnq();

              int respL = 0;
              switch (cmd) {
            case RCC.readTrack1: respL = res_tr1_l; break;
            case RCC.readTrack2: respL = res_tr2_l; break;
            case RCC.readTrack3: respL = res_tr3_l; break;
            default: respL = common_res_l; break;
              }
              resp = new byte[respL];
              int offset = 0;

              // Response waiting timeout - 30 sec (5.02 sec minimum)
              var timerTh = new Thread(() => { Thread.Sleep(30 * 1000); });
              timerTh.Start();
              while (offset < respL && !checkPktEnd(resp, offset) && timerTh.IsAlive)
            if (hPort.BytesToRead > 0)
              offset += hPort.Read(resp, offset, respL - offset);
              timerTh.Abort();

              Array.Resize(ref resp, offset);
              if (!checkResponse(resp, cmd, ref result)) return false;
              if (!checkPkt(resp, ref result)) return false;

              return true;
        }
Esempio n. 23
0
 // Send Command (DLE STX 'C' cmd prm DLE ETX BCC)
 Boolean sendCmd(RCC cmd, byte[] prm)
 {
     var len = start_stop_seq_l + // DLE STX ... DLE ETX BCC (5 bytes)
         cmd_fixed_part_l + // 'C' XX (XX - Command) (3 bytes)
         ((prm != null) ? prm.Length : 0);
       byte[] b = new byte[len];
       b[0] = (byte)TCC.DLE;
       b[1] = (byte)TCC.STX;
       b[2] = 0x43;  // "C"
       b[3] = (byte)((UInt16)cmd / 0x100);
       b[4] = (byte)((UInt16)cmd % 0x100); ;
       ///////////
       if (prm != null) {
     int i, j;
     for (i = 0, j = 5; i < prm.Length; i++, j++) {
       // if DLE character is used in prm, double DLE
       if (prm[i] == (byte)TCC.DLE) {
     len++;
     Array.Resize(ref b, len);
     b[j++] = prm[i];
       }
       b[j] = prm[i];
     }
       }
       ///////////
       b[b.Length - 3] = (byte)TCC.DLE;
       b[b.Length - 2] = (byte)TCC.ETX;
       Boolean res = false;
       b[b.Length - 1] = bcc(b, ref res);
       if (res) hPort.Write(b, 0, b.Length);
       return res;
 }
Esempio n. 24
0
 public void DeRegisterPlayer()
 {
     // Deregisters the vehicle from as player vehicle.
     RCC.DeRegisterPlayerVehicle();
 }
Esempio n. 25
0
 Boolean processPacket(RCC cmd, ref byte[] response, ref string result)
 {
     return processPacket(cmd, null, ref response, ref result);
 }
Esempio n. 26
0
    private void Start()
    {
        Application.targetFrameRate = 300;
        if (SceneManager.GetActiveScene().name == "battle_online")
        {
            LosePanel.SetActive(false);
        }

        curr = starttime;

        if (RCC_SceneManager.Instance.activePlayerVehicle)
        {
            PhotonNetwork.Destroy(RCC_SceneManager.Instance.activePlayerVehicle.gameObject);
        }

        if (PhotonNetwork.CurrentRoom.Name == "Highway")
        {
            InsideOutsideCar.manage.OutFromCarButton.SetActive(false);
            /// fog
            RenderSettings.fog        = true;
            RenderSettings.fogColor   = new Color(0.9622642f, 0.7006145f, 0.4130474f);
            RenderSettings.fogMode    = FogMode.Exponential;
            RenderSettings.fogDensity = 0.003f;

            if (PlayerPrefs.GetInt("CurrentCar") == 0 || PlayerPrefs.GetInt("CurrentCar") == 4 ||
                PlayerPrefs.GetInt("CurrentCar") == 5 || PlayerPrefs.GetInt("CurrentCar") == 8 || PlayerPrefs.GetInt("CurrentCar") == 12)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("Cars/" + CarsPrefabs[PlayerPrefs.GetInt("CurrentCar")].name, new Vector3(Random.Range(0f, -100.19f), Random.Range(4f, 6f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                //newVehicle.gameObject.AddComponent<RCC_EnterExitCar>();
                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 1)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("hotrodd", new Vector3(Random.Range(0f, -100.19f), Random.Range(3.5f, 5f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponent <Rigidbody>().isKinematic = false;
                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 2)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("buggy", new Vector3(Random.Range(0f, -100.19f), Random.Range(3.5f, 5f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponent <Rigidbody>().isKinematic = false;
                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 3)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("gt500", new Vector3(Random.Range(0f, -100.19f), Random.Range(3.5f, 5f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
                isHighwayNetworkActive = true;
            }

            // if (PlayerPrefs.GetInt("CurrentCar") == 4)
            // {
            //     Amplitude.Instance.logEvent("HighwayLevelNetwork");
            //     newVehicle = PhotonNetwork.Instantiate("rasta", new Vector3(Random.Range(0f, -100.19f), Random.Range(3.5f, 5f)), spawnPoint.rotation, 0).GetComponent<RCC_CarControllerV3>();
            //     newVehicle.GetComponentInChildren<Rigidbody>().isKinematic = false;
            //     isHighwayNetworkActive = true;
            //  }

            if (PlayerPrefs.GetInt("CurrentCar") == 6)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("ig8", new Vector3(Random.Range(0f, -100.19f), Random.Range(3.5f, 5f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 7)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("lambo", new Vector3(Random.Range(0f, -100.19f), Random.Range(3.5f, 5f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 9)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("modelt", new Vector3(Random.Range(0f, -100.19f), Random.Range(4f, 6f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();

                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 10)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("towncar", new Vector3(Random.Range(0f, -100.19f), Random.Range(4f, 6f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 11)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("karus_bus", new Vector3(Random.Range(0f, -100.19f), Random.Range(4f, 6f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();

                isHighwayNetworkActive = true;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 13)
            {
                Amplitude.Instance.logEvent("HighwayLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("boss", new Vector3(Random.Range(0f, -100.19f), Random.Range(4f, 6f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();

                isHighwayNetworkActive = true;
            }

            // if (PlayerPrefs.GetInt("CurrentCar") == 14)
            // {
            //     Amplitude.Instance.logEvent("HighwayLevelNetwork");
            //     newVehicle = PhotonNetwork.Instantiate("vetty", new Vector3(Random.Range(0f, -100.19f), Random.Range(4f, 6f)), spawnPoint.rotation, 0).GetComponent<RCC_CarControllerV3>();

            //     isHighwayNetworkActive = true;
            // }
        }
        else if (PhotonNetwork.CurrentRoom.Name == "City")
        {
            InsideOutsideCar.manage.OutFromCarButton.SetActive(false);
            if (PlayerPrefs.GetInt("CurrentCar") == 1)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("hotrodd", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 2)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("buggy", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 3)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("gt500", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
            }

            //  if (PlayerPrefs.GetInt("CurrentCar") == 4)
            // {
            //     Amplitude.Instance.logEvent("CityLevelNetwork");
            //    newVehicle = PhotonNetwork.Instantiate("rasta", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent<RCC_CarControllerV3>();
            //    newVehicle.GetComponentInChildren<Rigidbody>().isKinematic = false;
            // }

            if (PlayerPrefs.GetInt("CurrentCar") == 6)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("ig8", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 7)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("lambo", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
            }
            if (PlayerPrefs.GetInt("CurrentCar") == 9)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("modelt", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
            }
            if (PlayerPrefs.GetInt("CurrentCar") == 10)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("towncar", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
                newVehicle.GetComponentInChildren <Rigidbody>().isKinematic = false;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 11)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("karus_bus", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 13)
            {
                Amplitude.Instance.logEvent("CityNetwork");
                newVehicle = PhotonNetwork.Instantiate("boss", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
            }

            //  if (PlayerPrefs.GetInt("CurrentCar") == 14)
            // {
            //      Amplitude.Instance.logEvent("CityNetwork");
            //      newVehicle = PhotonNetwork.Instantiate("vetty", new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent<RCC_CarControllerV3>();
            // }
            else if (PlayerPrefs.GetInt("CurrentCar") == 0 || PlayerPrefs.GetInt("CurrentCar") == 4 ||
                     PlayerPrefs.GetInt("CurrentCar") == 5 || PlayerPrefs.GetInt("CurrentCar") == 8 || PlayerPrefs.GetInt("CurrentCar") == 12)
            {
                Amplitude.Instance.logEvent("CityLevelNetwork");
                newVehicle = PhotonNetwork.Instantiate("Cars/" + CarsPrefabs[PlayerPrefs.GetInt("CurrentCar")].name, new Vector3(Random.Range(-755f, -757f), Random.Range(2f, 4f), Random.Range(-165f, -184f)), spawnPoint.rotation, 0).GetComponent <RCC_CarControllerV3>();
            }
        }

        RCC.RegisterPlayerVehicle(newVehicle);
        RCC.SetControl(newVehicle, true);

        #region Car Lights
        if (PlayerPrefs.GetInt("CurrentCar") == 4 || PlayerPrefs.GetInt("CurrentCar") == 6)
        {
            GameObject light = GameObject.Find("Ilum");
            light.SetActive(false);
        }

        if (PlayerPrefs.GetInt("CurrentCar") == 12)
        {
            GameObject light = GameObject.Find("rearGroundFlares");
            light.SetActive(false);
        }
        #endregion

        #region Load Wheel Susspens
        if (PlayerPrefs.GetInt("WheelSussp" + PlayerPrefs.GetInt("CurrentCar")) != 0)
        {
            if (PlayerPrefs.GetInt("CurrentCar") != 8 || PlayerPrefs.GetInt("CurrentCar") != 10)
            {
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontLeftWheelCollider.wheelCollider.suspensionDistance  = PlayerPrefs.GetFloat("WheelSusspFront" + PlayerPrefs.GetInt("CurrentCar"));
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontRightWheelCollider.wheelCollider.suspensionDistance = PlayerPrefs.GetFloat("WheelSusspFront" + PlayerPrefs.GetInt("CurrentCar"));

                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearLeftWheelCollider.wheelCollider.suspensionDistance  = PlayerPrefs.GetFloat("WheelSusspRear" + PlayerPrefs.GetInt("CurrentCar"));
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearRightWheelCollider.wheelCollider.suspensionDistance = PlayerPrefs.GetFloat("WheelSusspRear" + PlayerPrefs.GetInt("CurrentCar"));


                //newVehicle.GetComponentInChildren<RCC_CarControllerV3>().FrontLeftWheelCollider.wheelCollider.suspensionDistance = 0.2f;
                //newVehicle.GetComponentInChildren<RCC_CarControllerV3>().FrontRightWheelCollider.wheelCollider.suspensionDistance = 0.2f;

                //newVehicle.GetComponentInChildren<RCC_CarControllerV3>().RearLeftWheelCollider.wheelCollider.suspensionDistance = 0.2f;
                //newVehicle.GetComponentInChildren<RCC_CarControllerV3>().RearRightWheelCollider.wheelCollider.suspensionDistance = 0.2f;
            }
            if (PlayerPrefs.GetInt("CurrentCar") == 8)
            {
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontLeftWheelCollider.wheelCollider.suspensionDistance  = 0.02f;
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontRightWheelCollider.wheelCollider.suspensionDistance = 0.02f;

                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearLeftWheelCollider.wheelCollider.suspensionDistance  = 0.02f;
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearRightWheelCollider.wheelCollider.suspensionDistance = 0.02f;
            }

            if (PlayerPrefs.GetInt("CurrentCar") == 10)
            {
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontLeftWheelCollider.wheelCollider.suspensionDistance  = 0.05f;
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontRightWheelCollider.wheelCollider.suspensionDistance = 0.05f;

                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearLeftWheelCollider.wheelCollider.suspensionDistance  = 0.05f;
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearRightWheelCollider.wheelCollider.suspensionDistance = 0.05f;
            }
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontLeftWheelCollider.wheelCollider.suspensionDistance  = 0.2f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().FrontRightWheelCollider.wheelCollider.suspensionDistance = 0.2f;

            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearLeftWheelCollider.wheelCollider.suspensionDistance  = 0.2f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().RearRightWheelCollider.wheelCollider.suspensionDistance = 0.2f;
        }

        #endregion

        #region Load EngineUpdate
        if (MainMenuManager.manage.svChecked.engine0)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().maxspeed     = newVehicle.GetComponentInChildren <RCC_CarControllerV3>().defMaxSpeed;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().engineTorque = newVehicle.GetComponentInChildren <RCC_CarControllerV3>().engineTorque;
        }
        if (MainMenuManager.manage.svChecked.engine1)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().maxspeed     += 15f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().engineTorque += 250f;
        }
        if (MainMenuManager.manage.svChecked.engine2)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().maxspeed     += 30f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().engineTorque += 350f;
        }

        if (MainMenuManager.manage.svChecked.engine3)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 50f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 500f;
        }

        if (MainMenuManager.manage.svChecked.engine4)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 70f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 600f;
        }

        if (MainMenuManager.manage.svChecked.engine5)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 80f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 700f;
        }
        if (MainMenuManager.manage.svChecked.engine6)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 90f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 800f;
        }

        if (MainMenuManager.manage.svChecked.engine7)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 100f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 900f;
        }

        if (MainMenuManager.manage.svChecked.engine8)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 110f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 1200f;
        }
        if (MainMenuManager.manage.svChecked.engine9)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 115f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 1300f;
        }

        if (MainMenuManager.manage.svChecked.engine10)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 125f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 1400f;
        }

        if (MainMenuManager.manage.svChecked.engine11)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 135f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 1500f;
        }
        if (MainMenuManager.manage.svChecked.engine12)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 145f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 1600f;
        }
        if (MainMenuManager.manage.svChecked.engine13)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 155f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 1700f;
        }

        if (MainMenuManager.manage.svChecked.engine14)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 175f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 1850f;
        }
        if (MainMenuManager.manage.svChecked.engine15)
        {
            newVehicle.GetComponent <RCC_CarControllerV3>().maxspeed     += 195f;
            newVehicle.GetComponent <RCC_CarControllerV3>().engineTorque += 2150f;
        }
        #endregion

        #region TCS
        if (PlayerPrefs.GetInt("TCS" + PlayerPrefs.GetInt("CurrentCar")) == 1 && PlayerPrefs.GetInt("selectTCS" + PlayerPrefs.GetInt("CurrentCar")) == 1)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().TCSThreshold = PlayerPrefs.GetFloat("TCSsetup" + PlayerPrefs.GetInt("CurrentCar"));
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().TCS = false;
        }
        #endregion

        #region ESP
        if (PlayerPrefs.GetInt("ESP" + PlayerPrefs.GetInt("CurrentCar")) == 1 && PlayerPrefs.GetInt("selectESP" + PlayerPrefs.GetInt("CurrentCar")) == 1)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ESPThreshold = PlayerPrefs.GetFloat("ESPsetup" + PlayerPrefs.GetInt("CurrentCar"));
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ESP = false;
        }
        #endregion

        #region Traction
        if (PlayerPrefs.GetInt("Traction" + PlayerPrefs.GetInt("CurrentCar")) == 1 && PlayerPrefs.GetInt("selectTraction" + PlayerPrefs.GetInt("CurrentCar")) == 1)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().tractionHelperStrength = PlayerPrefs.GetFloat("TractionSetup" + PlayerPrefs.GetInt("CurrentCar"));
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().tractionHelper         = true;
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().tractionHelper = false;
        }

        #endregion

        #region load Car Config
        if (!MainMenuManager.NOSisChecked)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().useNOS = false;
            nosButton.SetActive(false);
            noslevel.interactable = false;
            noslevel.maxValue     = 0;
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().useNOS    = true;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().maxspeed += 35f;
            nosButton.SetActive(true);
            noslevel.interactable = true;
        }
        if (!MainMenuManager.TurboisChecked)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().useTurbo        = false;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().useExhaustFlame = false;
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().useTurbo        = true;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().maxspeed       += 10f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().useExhaustFlame = true;
        }
        if (!MainMenuManager.ABSisChecked)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABS = false;
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABS           = true;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.1f;
        }

        #endregion

        #region Load HandlingUpdate
        if (MainMenuManager.manage.svChecked.handling0)
        {
            //InstantiatedCar.GetComponent<RCC_CarControllerV3>().steerHelperLinearVelStrength += 0.05f;
            //InstantiatedCar.GetComponent<RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.05f;
        }
        if (MainMenuManager.manage.svChecked.handling1)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.05f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.05f;
        }
        if (MainMenuManager.manage.svChecked.handling2)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.1f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.1f;
        }
        if (MainMenuManager.manage.svChecked.handling3)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.15f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.15f;
        }
        if (MainMenuManager.manage.svChecked.handling4)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.2f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.2f;
        }
        if (MainMenuManager.manage.svChecked.handling5)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.25f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.25f;
        }
        if (MainMenuManager.manage.svChecked.handling6)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.28f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.28f;
        }
        if (MainMenuManager.manage.svChecked.handling7)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.35f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.35f;
        }
        if (MainMenuManager.manage.svChecked.handling8)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.45f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.45f;
        }
        if (MainMenuManager.manage.svChecked.handling9)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.6f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.6f;
        }
        if (MainMenuManager.manage.svChecked.handling10)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.7f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.7f;
        }
        if (MainMenuManager.manage.svChecked.handling11)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.8f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.8f;
        }
        if (MainMenuManager.manage.svChecked.handling12)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperLinearVelStrength  += 0.9f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().steerHelperAngularVelStrength += 0.9f;
        }
        #endregion

        #region BrakeUpdate
        if (MainMenuManager.manage.svChecked.brake0)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold = 0.1f;
            // InstantiatedCar.GetComponent<RCC_CarControllerV3>().brakeTorque = 1200f;
        }
        if (MainMenuManager.manage.svChecked.brake1)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.025f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 100f;
        }
        if (MainMenuManager.manage.svChecked.brake2)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.05f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 200f;
        }
        if (MainMenuManager.manage.svChecked.brake3)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.075f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 300f;
        }
        if (MainMenuManager.manage.svChecked.brake4)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.125f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 400f;
        }
        if (MainMenuManager.manage.svChecked.brake5)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.2f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 500f;
        }
        if (MainMenuManager.manage.svChecked.brake6)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.225f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 600f;
        }
        if (MainMenuManager.manage.svChecked.brake7)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.3f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 700f;
        }
        if (MainMenuManager.manage.svChecked.brake8)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.35f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 800f;
        }
        if (MainMenuManager.manage.svChecked.brake9)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.4f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 900f;
        }
        if (MainMenuManager.manage.svChecked.brake10)
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().ABSThreshold += 0.45f;
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>().brakeTorque  += 1000f;
        }
        #endregion

        #region Wheel Drive Mode
        if (MainMenuManager.WheelDriveisChecked)
        {
            switch (PlayerPrefs.GetString("DriveMode"))
            {
            case "":
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>()._wheelTypeChoise = RCC_CarControllerV3.WheelType.RWD;
                break;

            case "RWD":
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>()._wheelTypeChoise = RCC_CarControllerV3.WheelType.RWD;
                break;

            case "FWD":
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>()._wheelTypeChoise = RCC_CarControllerV3.WheelType.FWD;
                break;

            case "AWD":
                newVehicle.GetComponentInChildren <RCC_CarControllerV3>()._wheelTypeChoise = RCC_CarControllerV3.WheelType.AWD;
                break;
            }
        }
        else
        {
            newVehicle.GetComponentInChildren <RCC_CarControllerV3>()._wheelTypeChoise = RCC_CarControllerV3.WheelType.RWD;
        }
        #endregion

        //InstantiatedCar.GetComponent<BoxCollider>().tag = "";
    }
Esempio n. 27
0
 Boolean processPacket(RCC cmd, ref string result)
 {
     byte[] resp = null;
     return(processPacket(cmd, null, ref resp, ref result));
 }
Esempio n. 28
0
    void Update()
    {
        if (activePlayerVehicle)
        {
            if (activePlayerVehicle != lastActivePlayerVehicle)
            {
                if (OnVehicleChanged != null)
                {
                    OnVehicleChanged();
                }
            }

            lastActivePlayerVehicle = activePlayerVehicle;
        }

        if (disableUIWhenNoPlayerVehicle && activePlayerCanvas)
        {
            CheckCanvas();
        }

        if (Input.GetKeyDown(RCC_Settings.Instance.recordKB))
        {
            RCC.StartStopRecord();
        }

        if (Input.GetKeyDown(RCC_Settings.Instance.playbackKB))
        {
            RCC.StartStopReplay();
        }

        if (Input.GetKey(RCC_Settings.Instance.slowMotionKB))
        {
            Time.timeScale = .2f;
        }

        if (Input.GetKeyUp(RCC_Settings.Instance.slowMotionKB))
        {
            Time.timeScale = orgTimeScale;
        }

        if (Input.GetButtonDown("Cancel"))
        {
            Cursor.lockState = CursorLockMode.None;
        }

        activeMainCamera = Camera.main;

        switch (recorder.mode)
        {
        case RCC_Recorder.Mode.Neutral:

            recordMode = RecordMode.Neutral;

            break;

        case RCC_Recorder.Mode.Play:

            recordMode = RecordMode.Play;

            break;

        case RCC_Recorder.Mode.Record:

            recordMode = RecordMode.Record;

            break;
        }
    }
Esempio n. 29
0
    public bool engineRunning;                        // Spawn with running engine?

    public void Spawn()
    {
        // Spawning the vehicle with given settings.
        currentVehiclePrefab = RCC.SpawnRCC(spawnVehiclePrefab, spawnTransform.position, spawnTransform.rotation, playerVehicle, controllable, engineRunning);
    }
Esempio n. 30
0
    public void Spawn()
    {
        // Last known position and rotation of last active vehicle.
        Vector3    lastKnownPos = new Vector3();
        Quaternion lastKnownRot = new Quaternion();

        // Checking if there is a player vehicle on the scene.
        if (RCC_SceneManager.Instance.activePlayerVehicle)
        {
            lastKnownPos = RCC_SceneManager.Instance.activePlayerVehicle.transform.position;
            lastKnownRot = RCC_SceneManager.Instance.activePlayerVehicle.transform.rotation;
        }

        // If last known position and rotation is not assigned, camera's position and rotation will be used.
        if (lastKnownPos == Vector3.zero)
        {
            if (RCC_SceneManager.Instance.activePlayerCamera)
            {
                lastKnownPos = RCC_SceneManager.Instance.activePlayerCamera.transform.position;
                lastKnownRot = RCC_SceneManager.Instance.activePlayerCamera.transform.rotation;
            }
        }

        // We don't need X and Z rotation angle. Just Y.
        lastKnownRot.x = 0f;
        lastKnownRot.z = 0f;

        RCC_CarControllerV3 lastVehicle = RCC_SceneManager.Instance.activePlayerVehicle;

                #if BCG_ENTEREXIT
        BCG_EnterExitVehicle lastEnterExitVehicle;
        bool enterExitVehicleFound = false;

        if (lastVehicle)
        {
            lastEnterExitVehicle = lastVehicle.GetComponentInChildren <BCG_EnterExitVehicle> ();

            if (lastEnterExitVehicle && lastEnterExitVehicle.driver)
            {
                enterExitVehicleFound = true;
                BCG_EnterExitManager.Instance.waitTime = 10f;
                lastEnterExitVehicle.driver.GetOut();
            }
        }
                #endif

        // If we have controllable vehicle by player on scene, destroy it.
        if (lastVehicle)
        {
            Destroy(lastVehicle.gameObject);
        }

        // Here we are creating our new vehicle.
        RCC.SpawnRCC(selectableVehicles[selectedVehicleIndex], lastKnownPos, lastKnownRot, true, true, true);

                #if BCG_ENTEREXIT
        if (enterExitVehicleFound)
        {
            lastEnterExitVehicle = null;

            lastEnterExitVehicle = RCC_SceneManager.Instance.activePlayerVehicle.GetComponentInChildren <BCG_EnterExitVehicle> ();

            if (!lastEnterExitVehicle)
            {
                lastEnterExitVehicle = RCC_SceneManager.Instance.activePlayerVehicle.gameObject.AddComponent <BCG_EnterExitVehicle> ();
            }

            if (BCG_EnterExitManager.Instance.BCGCharacterPlayer.characterPlayer && lastEnterExitVehicle && lastEnterExitVehicle.driver == null)
            {
                BCG_EnterExitManager.Instance.waitTime = 10f;
                BCG_EnterExitManager.Instance.BCGCharacterPlayer.characterPlayer.GetIn(lastEnterExitVehicle);
            }
        }
                #endif
    }
Esempio n. 31
0
 public void SetPlayer()
 {
     // Registers the vehicle as player vehicle.
     RCC.RegisterPlayerVehicle(currentVehiclePrefab);
 }
Esempio n. 32
0
 public void SetControl(bool control)
 {
     // Enables / disables controllable state of the vehicle.
     RCC.SetControl(currentVehiclePrefab, control);
 }
Esempio n. 33
0
 public void SetEngine(bool engine)
 {
     // Starts / kills engine of the vehicle.
     RCC.SetEngine(currentVehiclePrefab, engine);
 }
Esempio n. 34
0
    // Use this for initialization
    void Start()
    {
        int selectedIndex = PlayerPrefs.GetInt("SelectedRCCVehicle", 0);

        RCC.SpawnRCC(RCC_DemoVehicles.Instance.vehicles [selectedIndex], transform.position, transform.rotation, true, true, true);
    }
Esempio n. 35
0
        Boolean checkResponse(byte[] buf, RCC cmd, ref string s)
        {
            // Check negative/positive
              switch (buf[2]) {
            case 0x50: // Positive
              s = p_res;
              addPosErr(ref s, BytesToUShort(Take(buf, 5, 2)));
              break;
            case 0x4E: // Negative
              s = n_res;
              addNegErr(ref s, BytesToUShort(Take(buf, 5, 2)));
              break;
            default:   // Undefined
              s = u_res;
              return false;
              };

              // Check command
              if (BytesToUShort(Take(buf, 3, 2)) != (ushort)cmd) {
            s += err_Cmd;
            return false;
              }

              return true;
        }