public void UpdateBikeInfo(int d)
    {
        star[GameData.selectedBike].spriteName = "noStar";
        BikerGarageRotate.instance.bikeList[GameData.selectedBike].SetActive(false);
        GameData.selectedBike = (GameData.selectedBike + d + 7) % 7;
        PlayerPrefs.SetInt("selectedBike", GameData.selectedBike);
        star[GameData.selectedBike].spriteName = "star";
        BikerGarageRotate.instance.bikeList[GameData.selectedBike].SetActive(true);
        BikeData bike = (BikeData)(LoadData.BikeList[GameData.selectedBike]);

        level.spriteName = bike.level;

        if (GameData.selectedBike > 0)
        {
            price.text = bike.price.ToString();
            UM_InAppProduct product = UM_InAppPurchaseManager.Instance.GetProductById("spaceship" + GameData.selectedBike.ToString());
            IAPprice.text = "$ " + product._price;
        }

        speed.text                 = bike.speed.ToString() + "m/s";
        health.text                = bike.health.ToString();
        force.text                 = bike.force.ToString();
        speedBar.fillAmount        = bike.speed / 40f;
        healthBar.fillAmount       = (bike.health) / 500;
        controlSpeedBar.fillAmount = bike.force / 20f;

        buyBtn.SetActive(!GameData.GetBike(GameData.selectedBike));
        rBuyBtn.SetActive(!GameData.GetBike(GameData.selectedBike));
        startBtn.SetActive(GameData.GetBike(GameData.selectedBike));
    }
    /// <summary>
    /// The standard Unity Start method.
    /// </summary>
    void Start()
    {
        // Set the initial position and rotation; set the character controller.
        initialPosition          = transform.position;
        initialRotation          = transform.rotation;
        this.characterController = this.GetComponent <CharacterController>();

        // Reset position (altitude) and heading.
        this.ResetPositionAndHeadingToTransform();

        // Get a new BikeData object.
        bikeData = new BikeData();

        #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        // Try to start Ant.
        try
        {
            this.antStick       = new AntStick();
            this.antStickBridge = new AntStickBridge(antStick, bikeData);
            this.antStick.Start();
        }
        catch (Exception ex)
        {
            Debug.LogWarningFormat("[BikeController] Exception while loading Ant.\n{0}", ex.Message);
        }

        // Try to start the XSens Gyro.
        try
        {
            this.xsensGyro       = new XSensGyro();
            this.xsensGyroBridge = new XSensGyroBridge(xsensGyro, this);
            this.xsensGyro.Start();
            // We have to wait after starting the gyro to zero it.
            StartCoroutine(WaitThenZeroXSensGyro());
        }
        catch (Exception ex)
        {
            Debug.LogWarningFormat("[BikeController] Exception while loading XSens Gyro. The DLL is probably missing.\n{0}", ex.Message);
        }
        #else
        Debug.LogWarning("[BikeController] ANT and XSens are not available on non-Windows platforms.");
        #endif

        // Initialize and attach all the supplemental components needed by Bike Controller.

        UIOverlay.SetBikeController(this);
        this.uiOverlay = gameObject.AddComponent <UIOverlay>();

        UIDebugOverlay.SetBikeController(this);
        this.uiDebugOverlay = gameObject.AddComponent <UIDebugOverlay>();

        this.bikePhysics  = new BikePhysics(this);
        this.bikeSteering = new BikeSteering(this, this.steeringCurve);

        // Disable collisions between player character and the terrain.
        CharacterController characterController = this.GetComponent <CharacterController>();
        TerrainCollider     terrainCollider     = CollisionDisabler.GetTerrainColliderForActiveTerrain();
        (new CollisionDisabler(characterController, terrainCollider)).Start();
    }
Exemple #3
0
        private void OnRunTelemetry(object sender, DataEventArgs <GPBikes.SPluginsBikeDataEx_t> e)
        {
            var data  = e.Data;
            var dbObj = new BikeData
            {
                TrackTime           = data.TrackTime,
                TrackPosition       = data.TrackPosition,
                RPM                 = data.BikeData.RPM,
                EngineTemperature   = data.BikeData.EngineTemperature,
                WaterTemperature    = data.BikeData.WaterTemperature,
                Gear                = data.BikeData.Gear,
                Fuel                = data.BikeData.Fuel,
                Speedometer         = data.BikeData.Speedometer,
                PosX                = data.BikeData.PosX,
                PosY                = data.BikeData.PosY,
                PosZ                = data.BikeData.PosZ,
                VelocityX           = data.BikeData.VelocityX,
                VelocityY           = data.BikeData.VelocityY,
                VelocityZ           = data.BikeData.VelocityZ,
                AccelerationX       = data.BikeData.AccelerationX,
                AccelerationY       = data.BikeData.AccelerationY,
                AccelerationZ       = data.BikeData.AccelerationZ,
                Rot0                = data.BikeData.Rot[0],
                Rot1                = data.BikeData.Rot[1],
                Rot2                = data.BikeData.Rot[2],
                Rot3                = data.BikeData.Rot[3],
                Rot4                = data.BikeData.Rot[4],
                Rot5                = data.BikeData.Rot[5],
                Rot6                = data.BikeData.Rot[6],
                Rot7                = data.BikeData.Rot[7],
                Rot8                = data.BikeData.Rot[8],
                Yaw                 = data.BikeData.Yaw,
                Pitch               = data.BikeData.Pitch,
                Roll                = data.BikeData.Roll,
                YawVelocity         = data.BikeData.YawVelocity,
                PitchVelocity       = data.BikeData.PitchVelocity,
                RollVelocity        = data.BikeData.RollVelocity,
                SuspNormLengthFront = data.BikeData.SuspNormLength[0],
                SuspNormLengthRear  = data.BikeData.SuspNormLength[1],
                Crashed             = data.BikeData.Crashed,
                Steer               = data.BikeData.Steer,
                Throttle            = data.BikeData.Throttle,
                FrontBrake          = data.BikeData.FrontBrake,
                RearBrake           = data.BikeData.RearBrake,
                Clutch              = data.BikeData.Clutch,
                WheelSpeedFront     = data.BikeData.WheelSpeed[0],
                WheelSpeedRear      = data.BikeData.WheelSpeed[1],
                PitLimiter          = data.BikeData.PitLimiter,
                EngineMapping       = data.BikeData.EngineMapping
            };

            mLogger.BikeDatas.AddObject(dbObj);
            mLogger.SaveChanges();
        }
Exemple #4
0
        public static void AssertAreEqual(BikeData recData, GPBikes.SPluginsBikeData_t data)
        {
            Assert.AreEqual(recData.RPM, data.RPM);
            Assert.AreEqual(recData.EngineTemperature, data.EngineTemperature);
            Assert.AreEqual(recData.WaterTemperature, data.WaterTemperature);
            Assert.AreEqual(recData.Gear, data.Gear);
            Assert.AreEqual(recData.Fuel, data.Fuel);
            Assert.AreEqual(recData.Speedometer, data.Speedometer);

            Assert.AreEqual(recData.PosX, data.PosX);
            Assert.AreEqual(recData.PosY, data.PosY);
            Assert.AreEqual(recData.PosZ, data.PosZ);

            Assert.AreEqual(recData.VelocityX, data.VelocityX);
            Assert.AreEqual(recData.VelocityY, data.VelocityY);
            Assert.AreEqual(recData.VelocityZ, data.VelocityZ);

            Assert.AreEqual(recData.AccelerationX, data.AccelerationX);
            Assert.AreEqual(recData.AccelerationY, data.AccelerationY);
            Assert.AreEqual(recData.AccelerationZ, data.AccelerationZ);

            Assert.AreEqual(recData.Rot0, data.Rot[0]);
            Assert.AreEqual(recData.Rot1, data.Rot[1]);
            Assert.AreEqual(recData.Rot2, data.Rot[2]);
            Assert.AreEqual(recData.Rot3, data.Rot[3]);
            Assert.AreEqual(recData.Rot4, data.Rot[4]);
            Assert.AreEqual(recData.Rot5, data.Rot[5]);
            Assert.AreEqual(recData.Rot6, data.Rot[6]);
            Assert.AreEqual(recData.Rot7, data.Rot[7]);
            Assert.AreEqual(recData.Rot8, data.Rot[8]);

            Assert.AreEqual(recData.Yaw, data.Yaw);
            Assert.AreEqual(recData.Pitch, data.Pitch);
            Assert.AreEqual(recData.Roll, data.Roll);

            Assert.AreEqual(recData.YawVelocity, data.YawVelocity);
            Assert.AreEqual(recData.PitchVelocity, data.PitchVelocity);
            Assert.AreEqual(recData.RollVelocity, data.RollVelocity);

            Assert.AreEqual(recData.SuspNormLengthFront, data.SuspNormLength[0]);
            Assert.AreEqual(recData.SuspNormLengthRear, data.SuspNormLength[1]);

            Assert.AreEqual(recData.Crashed, data.Crashed);
            Assert.AreEqual(recData.Throttle, data.Throttle);
            Assert.AreEqual(recData.FrontBrake, data.FrontBrake);
            Assert.AreEqual(recData.RearBrake, data.RearBrake);
            Assert.AreEqual(recData.Clutch, data.Clutch);

            Assert.AreEqual(recData.WheelSpeedFront, data.WheelSpeed[0]);
            Assert.AreEqual(recData.WheelSpeedRear, data.WheelSpeed[1]);

            Assert.AreEqual(recData.PitLimiter, data.PitLimiter);
            Assert.AreEqual(recData.EngineMapping, data.EngineMapping);
        }
Exemple #5
0
 private void updateAll(BikeData data)
 {
     SetPulse(data.Pulse.ToString());
     SetRoundMin(data.Rpm.ToString());
     SetSpeed(data.Speed.ToString());
     SetDistance(data.Distance.ToString());
     SetResistance(data.Resistance.ToString());
     SetEnergy(data.Energy.ToString());
     SetTime(data.Time.ToString());
     SetWatt(data.Power.ToString());
     Application.DoEvents();
 }
Exemple #6
0
        public async Task OnGetAsync(int?id, int?categoryID)
        {
            BikeD = new BikeData();

            BikeD.Bikes = await _context.Bike
                          .Include(b => b.Store)
                          .Include(b => b.BikeCategories)
                          .ThenInclude(b => b.Category)
                          .AsNoTracking()
                          .OrderBy(b => b.Series)
                          .ToListAsync();

            if (id != null)
            {
                BikeID = id.Value;
                Bike bike = BikeD.Bikes
                            .Where(i => i.ID == id.Value).Single();
                BikeD.Categories = bike.BikeCategories.Select(s => s.Category);
            }
        }
Exemple #7
0
 private void update(JObject data)
 {
     if (User.Type == UserType.Client)
     {
         lock (sessionLock) {
             if (session != null)
             {
                 BikeData dataConverted = data["bikeData"].ToObject <BikeData>();
                 session.Data.Add(dataConverted);
                 if (session.LatestData.Count < 5)
                 {
                     session.LatestData.Add(dataConverted);
                 }
                 else
                 {
                     session.LatestData.RemoveAt(0);
                     session.LatestData.Add(dataConverted);
                 }
             }
         }
     }
 }
Exemple #8
0
        private void AddToGraphHistory(BikeData bike)
        {
            lock (sessionLock) {
                pulsehistory.Add(bike.Pulse);
                roundhistory.Add(bike.Rpm);
                speedhistory.Add(bike.Speed);
                distancehistory.Add(bike.Distance);
                resistancehistory.Add(bike.Resistance);
                energyhistory.Add(bike.Energy);
                generatedhistory.Add(bike.Power);
            }

            if (grafiek.IsHandleCreated)
            {
                this.Invoke((MethodInvoker) delegate {
                    updateGrafiek();
                });
            }
            else
            {
                Console.WriteLine("ERROR Grafiek niet aangemaakt");
            }
        }
Exemple #9
0
 public static void AssertAreEqual(BikeData recData, GPBikes.SPluginsBikeDataEx_t data)
 {
     Assert.AreEqual(recData.TrackTime, data.TrackTime);
     Assert.AreEqual(recData.TrackPosition, data.TrackPosition);
     AssertAreEqual(recData, data.BikeData);
 }