Ejemplo n.º 1
0
    void init(UnityProp p, LabVariables v)
    {
        p.pathSizeModifier  = v.pathSizeModifier.value;
        p.pathDirection     = v.pathDirection.value;
        p.pathSpeed         = v.pathSpeed.value;
        p.pathAngleModifier = v.pathAngleModifier.value;
        p.pathRotation      = v.pathRotation.value;

        p.setPropDirection(v.propDirection.value);
        p.propSpeed         = v.propSpeed.value;
        p.propAngleModifier = v.propAngleModifier.value;

        p.xAdj = v.xAdj.value;
        p.yAdj = v.yAdj.value;

        p.use3D   = v.use3D.value;
        p.mod3D   = v.mod3D.value;
        p.flip3D  = v.flip3D.value;
        p.twist3D = v.twist3D.value;

        p.path3DMask = v.path3DMask.value;
        p.prop3DMask = v.prop3DMask.value;

        p.speedControl            = SpeedHelper.getSpeed(v.speedControl.value, 1, 0);
        p.speedChangeModifier     = v.speedChangeModifier.value;
        p.directionChange         = DirectionHelper.getDirectionControl(v.directionChange.value);
        p.directionChangeModifier = v.directionChangeModifier.value;

        p.setShape(ShapeHelper.getShape(v.shape.value));
        p.setComplexShape(v.complexShape.value);

        propA = L.propAngleIncrement;
        pathA = L.pathAngleIncrement;
    }
Ejemplo n.º 2
0
 private void InitVariables()
 {
     data         = GameData.LoadFromJSONResource();
     passingStage = PlayerPrefHelper.GetPassingStage();
     levelData    = data.levelData[passingStage];
     radius       = Camera.main.ViewportToWorldPoint(new Vector3(RADIUS, 0, 0)).x - Camera.main.ViewportToWorldPoint(new Vector3(0, 0, 0)).x;
     speedHelper  = new SpeedHelper(levelData.speed);
 }
Ejemplo n.º 3
0
    private void Update()
    {
        if (slowOverTime)
        {
            this.speed = SpeedHelper.Slow(this.speed, this.maxSpeed, 0.05f);

            if (this.speed <= 0)
            {
                Destroy(this.gameObject);
            }
        }
    }
Ejemplo n.º 4
0
        private void OnTick(object sender, EventArgs e)
        {
            if (!Globals.Settings.SpeedometerEnabled || !EnableSpeedometer())
            {
                return;
            }
            try
            {
                this.UISpeedometer.Caption = SpeedHelper.GetSpeedInKmh(GetPlayerSpeed());
                this.DrawMeters();
            }
            catch (Exception exc)
            {
                Logger.LogToFile(PluginName, exc);
            }

            //UI.ShowSubtitle("jap.");

            this.prevPos = this.Character.Position;
        }
Ejemplo n.º 5
0
        private void OnTick(object sender, EventArgs e)
        {
            if (!Globals.Settings.TempomatEnabled || !PlayerHelper.PlayerIsNotNull())
            {
                //Resetting script
                if (this.TempomatEnabled)
                {
                    this.ResetScript();
                }
                return;
            }
            try
            {
                if (Game.IsPaused || !Game.Player.Character.IsInVehicle() || !VehicleIsTempomatAllowed())
                {
                    if (this.TempomatEnabled && this.Vehicle == null)
                    {
                        UI.Notify("Tempomat OFF : Error 404 - No vehicle found");
                        this.ResetScript();
                    }
                    return;
                }

                //GTA.UI.ShowSubtitle($"{((this.TempomatMaxSpeed * 1.05) * 3.6f).ToString("000")} | {(this.TempomatMaxSpeed * 3.6f).ToString("000")} | {((this.TempomatMaxSpeed / 1.05) * 3.6f).ToString("000")}");
                if (this.TempomatEnabled)
                {
                    var ResetScript = false;

                    if (Game.IsControlPressed(Globals.GameInputMethod, GTA.Control.VehicleExit))
                    {
                        UI.Notify("Tempomat OFF : Error 404 - No driver found");
                        ResetScript = true;
                    }

                    if ((Game.IsControlPressed(Globals.GameInputMethod, GTA.Control.VehicleBrake) || Game.IsControlPressed(Globals.GameInputMethod, GTA.Control.VehicleHandbrake)))
                    {
                        UI.Notify("Tempomat OFF : Brake detected!");
                        ResetScript = true;
                    }

                    if (ResetScript)
                    {
                        this.ResetScript();
                        return;
                    }


                    this.UISpeedometer.Caption = $"Max Speed: {SpeedHelper.GetSpeedInKmh(this.TempomatMaxSpeed)}";
                    this.UISpeedometer.Draw();

                    //If vehicle is accelerating, TempomatMaxSpeed should change to VehicleSpeed
                    if (Game.IsControlPressed(1, GTA.Control.VehicleAccelerate))
                    {
                        if (IsVehicleAbnormal())
                        {
                            return;
                        }

                        //Player should be accelerating
                        if (Vehicle.Speed > (TempomatMaxSpeed * 1.05))
                        {
                            this.TempomatMaxSpeed = Vehicle.Speed;
                            return;
                        }
                    }
                }

                if (Game.IsControlPressed(Globals.GameInputMethod, GTA.Control.VehicleDuck) && !Globals.NativeUiIsAnyMenuOpen)
                {
                    this.TempomatEnabled = !this.TempomatEnabled;

                    if (this.TempomatEnabled && !IsVehicleAbnormal())
                    {
                        this.TempomatMaxSpeed = Vehicle.Speed;

                        GTA.UI.Notify("Tempomat ON");

                        if (this.TempomatMaxSpeed < 2.777778f)
                        {
                            this.TempomatMaxSpeed = 2.777778f;
                        }
                        GTA.UI.Notify($"Tempomat set to: {SpeedHelper.GetSpeedInKmh(this.TempomatMaxSpeed)}");
                    }
                    else
                    {
                        UI.Notify("Tempomat OFF : Disabled by driver");
                        this.ResetScript();
                    }
                    Wait(250);
                }


                if (!this.TempomatEnabled || this.IsVehicleAbnormal())
                {
                    return;
                }


                //Mos MagicMathShit
                var factor = 10.0f;
                var perc   = Vehicle.Speed / this.TempomatMaxSpeed;
                this.TempomatAccelerationRate = (1.06f - perc) * factor;
                this.TempomatAccelerationRate = Math.Min(1f, this.TempomatAccelerationRate); //max 1
                this.TempomatAccelerationRate = Math.Max(0f, this.TempomatAccelerationRate); //min 0

                //Accelerate
                Game.SetControlNormal(Globals.GameInputMethod, Control.VehicleAccelerate, TempomatAccelerationRate);
            }
            catch (Exception exc)
            {
                Logger.LogToFile(PluginName, exc);
            }
        }