Ejemplo n.º 1
0
        public void RandomDetail()
        {
            Console.Clear();
            switch (random.Next(0, allDetail))
            {
            case 0:
                Wheel wheel = new Wheel();
                countWheel++;
                break;

            case 1:
                Engine engine = new Engine();
                countEngine++;
                break;

            case 2:
                SteeringWheel steeringWheel = new SteeringWheel();
                countSteeringWheel++;
                break;

            case 3:
                Seat seat = new Seat();
                countSeat++;
                break;
            }
            Console.WriteLine("Created Random Details");
        }
        /// <summary>
        /// Creates a new saved SteeringWheel with a random value assigned to every property
        /// </summary>
        public static SteeringWheel CreateSavedSteeringWheel()
        {
            SteeringWheel steeringWheel = CreateUnsavedValidSteeringWheel();

            steeringWheel.Save();
            return(steeringWheel);
        }
Ejemplo n.º 3
0
        [Test]  // Checks that deleting this instance has no effect in the related class
        public void Test_SingleRelationshipDeletion_DoNothing_Car()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel();

            TestProject.BO.Car boForRelationshipCar = TestUtilsCar.CreateSavedCar();
            steeringWheel.Car = boForRelationshipCar;
            steeringWheel.Save();

            //---------------Assert Preconditions---------------
            IRelationshipDef relationshipDef = ClassDef.Get <SteeringWheel>().RelationshipDefCol["Car"];

            Assert.AreEqual(DeleteParentAction.DoNothing, relationshipDef.DeleteParentAction);
            //---------------Execute Test ----------------------
            steeringWheel.MarkForDelete();
            steeringWheel.Save();
            //---------------Execute Test ----------------------
            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();

            try
            {
                Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID);
                Assert.Fail("BO should no longer exist and exception should be thrown");
            }
            catch (BusObjDeleteConcurrencyControlException ex)
            {
                StringAssert.Contains("There are no records in the database for the Class: SteeringWheel", ex.Message);
            }

            TestProject.BO.Car relatedBO = Broker.GetBusinessObject <TestProject.BO.Car>(boForRelationshipCar.ID);
            Assert.AreEqual(relatedBO.ID.ToString(), boForRelationshipCar.ID.ToString());
        }
        /// <summary>
        /// Creates a new unsaved SteeringWheel with a random value assigned to every property
        /// </summary>
        public static SteeringWheel CreateUnsavedValidSteeringWheel()
        {
            SteeringWheel steeringWheel = new SteeringWheel();

            steeringWheel.Car = TestUtilsCar.CreateSavedCar();
            return(steeringWheel);
        }
Ejemplo n.º 5
0
 public override void SafeAwake()
 {
     base.SafeAwake();
     steeringWheel = BB.GetComponent <SteeringWheel>();
     FPLogic       = steeringWheel.AddToggle("FPIO", "accept_fpio", false);
     UsedKeys      = steeringWheel.MapperTypes.Where(x => x is MKey).Select(x => x as MKey).ToArray();
 }
Ejemplo n.º 6
0
    void Start()
    {
        carUserControl = GetComponent <CarUserControl> ();
        SteeringWheel  = GetComponent <SteeringWheel> ();

        carUserControl.enabled = false;
        AudioListener.pause    = true;
        SteeringWheel.enabled  = false;
    }
Ejemplo n.º 7
0
        public StepView(AccelerationDirection acceleration, SteeringWheel direction, ApplicationStep currentStep, double distance, int totalSteps, int step)
        {
            Distance         = distance;
            this.currentStep = currentStep;
            this.ViewModel   = new StepViewModel(acceleration, direction, currentStep, distance, totalSteps, step, this);
            BindingContext   = ViewModel;

            ConfigureScreen();
            ConfigureModals();
        }
Ejemplo n.º 8
0
        public static Car CreateCar(CarType type, string brand, int numberOfSeats, int numberOfWheels, ColorType color, SteeringType steeringType)
        {
            Car carToReturn = null;

            ISteering steering = null;

            // Hvilken styring skal bruges
            switch (steeringType)
            {
            case SteeringType.SteeringWheel:
                steering = new SteeringWheel();
                break;

            case SteeringType.Brain:
                steering = new Brain();
                break;

            case SteeringType.Joystick:
                steering = new Joystick();
                break;

            default:
                throw new Exception("SteeringType ikke valgt korrekt");
            }

            // Hvilken biltype
            switch (type)
            {
            case CarType.Personal:
                carToReturn = new Personal(brand, numberOfSeats, numberOfWheels, color, steering);
                break;

            case CarType.SUV:
                carToReturn = new SUV(brand, numberOfSeats, numberOfWheels, color, steering);
                break;

            case CarType.Van:
                carToReturn = new Van(brand, numberOfSeats, numberOfWheels, color, steering);
                break;

            case CarType.Truck:
                carToReturn = new Truck(brand, numberOfSeats, numberOfWheels, color, steering);
                break;

            case CarType.Bus:
                carToReturn = new Bus(brand, numberOfSeats, numberOfWheels, color, steering);
                break;

            default:
                throw new Exception("CarType ikke valgt korrekt");
            }

            return(carToReturn);
        }
Ejemplo n.º 9
0
    private static bool Prefix
    (
        SteeringWheel __instance,
        ref bool ___hasBeenPlaced,
        ref bool ___isDisplayingText,
        DisplayTextManager ___displayText,
        ref Network_Player ___localPlayer,
        ref Semih_Network ___network
    )
    {
        if (!___hasBeenPlaced)
        {
            return(true);
        }
        if (MyInput.GetButton("Sprint"))
        {
            ___isDisplayingText = true;
            ___displayText.ShowText("Toggle Engines", MyInput.Keybinds["Interact"].MainKey, 1, "Toggle Engine Direction", MyInput.Keybinds["Rotate"].MainKey, 2);

            if (MyInput.GetButtonDown("Interact"))
            {
                MoreSailsMoreSpeed.ToggleAllEngines();
            }
            if (MyInput.GetButtonDown("Rotate"))
            {
                MoreSailsMoreSpeed.ToggleAllEnginesDir();
            }
        }
        else
        {
            ___isDisplayingText = true;
            ___displayText.ShowText("Hold for more options", MyInput.Keybinds["Sprint"].MainKey, 1, Helper.GetTerm("Game/RotateSmooth2", false), MyInput.Keybinds["Rotate"].MainKey, 2);
            if (MyInput.GetButtonDown("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(false);
            }
            if (MyInput.GetButtonUp("Rotate"))
            {
                ___localPlayer.PlayerScript.SetMouseLookScripts(true);
            }
            if (MyInput.GetButton("Rotate"))
            {
                float axis = Input.GetAxis("Mouse X");
                Message_SteeringWheel_Rotate message = new Message_SteeringWheel_Rotate(Messages.SteeringWheelRotate, ___network.NetworkIDManager, __instance.ObjectIndex, axis);
                if (Semih_Network.IsHost)
                {
                    AccessTools.Method("SteeringWheel:Rotate").Invoke(__instance, new object[] { axis });
                    return(false);
                }
                ___network.SendP2P(___network.HostID, message, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
            }
        }
        return(false);
    }
        [Test]  // Ensures that a saved class can be loaded
        public void Test_LoadSteeringWheel()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel();

            //---------------Execute Test ----------------------
            SteeringWheel loadedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID);

            //---------------Test Result -----------------------
        }
Ejemplo n.º 11
0
        public override void SafeAwake()
        {
            steeringWheel = GetComponent <SteeringWheel>();
            SpeedSlider   = steeringWheel.SpeedSlider;

            base.SafeAwake();

#if DEBUG
            ConsoleController.ShowMessage("转向关节添加进阶属性");
#endif
        }
Ejemplo n.º 12
0
    //public AudioSource carAudio;


    //public AudioSource welcomeVoiceOver;

    void Start()
    {
        CarUserControl carController = Car.GetComponent <CarUserControl>();
        SteeringWheel  steeringWheel = SteeringWheel.GetComponent <SteeringWheel>();



        carController.enabled = false;
        PauseCarSound(true);
        //welcomeVoiceOver.Play ();
        steeringWheel.enabled = false;
    }
        [Test]  // Ensures that the defaults have not been tampered
        public void Test_CreateSteeringWheelWithDefaults()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            SteeringWheel steeringWheel = new SteeringWheel();

            //---------------Test Result -----------------------
        }
        [Test]  // Ensures that gets and sets in the code refer to the same property
        public void Test_PropertyGetters()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = new SteeringWheel();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------


            //---------------Test Result -----------------------
        }
Ejemplo n.º 15
0
    public void ResumeButtonClicked()
    {
        PauseScreen.SetActive(false);

        CarUserControl carUserController = Car.GetComponent <CarUserControl>();
        CarController  carController     = Car.GetComponent <CarController> ();
        SteeringWheel  steeringWheel     = SteeringWheel.GetComponent <SteeringWheel>();

        carUserController.enabled = true;
        carController.enabled     = true;
        //AudioListener.pause = true;
        steeringWheel.enabled = true;
    }
Ejemplo n.º 16
0
    public void disappearButton()
    {
        CarUserControl carController = Car.GetComponent <CarUserControl>();
        SteeringWheel  steeringWheel = SteeringWheel.GetComponent <SteeringWheel>();

        WelcomeScreen.SetActive(false);
        ObjectivesScreen.SetActive(true);
        PauseButton.SetActive(true);

        carController.enabled = true;
        PauseCarSound(false);
        //welcomeVoiceOver.Play ();
        steeringWheel.enabled = true;
    }
Ejemplo n.º 17
0
        public void Test_ToString()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateUnsavedValidSteeringWheel();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string toStringValue = steeringWheel.ToString();

            //---------------Test Result -----------------------
            Assert.Fail("Implement ToString() for SteeringWheel and refine this test");
            //Assert.AreEqual(steeringWheel.SomeProperty, toStringValue);
        }
Ejemplo n.º 18
0
    public void PauseButtonClicked()
    {
        CarUserControl carUserController = Car.GetComponent <CarUserControl>();
        CarController  carController     = Car.GetComponent <CarController> ();
        SteeringWheel  steeringWheel     = SteeringWheel.GetComponent <SteeringWheel>();

        carUserController.enabled = false;
        carController.enabled     = false;
        //AudioListener.pause = true;
        steeringWheel.enabled = false;

        PauseMenu.SetActive(true);
        //ObjectivesMenu.SetActive (false);
        //pauseButton.SetActive (false);
    }
        [Test]  // Ensures that property setters in the code point to the correct property
        public void Test_PropertySettersUseCorrectPropertyNames()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = new SteeringWheel();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Car valueForCar = TestUtilsCar.CreateSavedCar();

            steeringWheel.SetPropertyValue("CarID", (object)valueForCar.ID.GetAsGuid());

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForCar, steeringWheel.Car);
        }
Ejemplo n.º 20
0
        [Test]  // Ensures that property setters in the code point to the correct property
        public void Test_PropertySettersUseCorrectPropertyNames()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = new SteeringWheel();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForCarID = TestUtilsCar.CreateSavedCar().VehicleID;

            steeringWheel.SetPropertyValue("CarID", valueForCarID);

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForCarID, steeringWheel.CarID);
        }
Ejemplo n.º 21
0
        [Test]  // Ensures that the defaults have not been tampered
        public void Test_CreateSteeringWheelWithDefaults()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            SteeringWheel steeringWheel = new SteeringWheel();

            //---------------Test Result -----------------------
            Assert.IsNotNull(steeringWheel.SteeringWheelID);
            Assert.IsInstanceOf(steeringWheel.Props["SteeringWheelID"].PropertyType, steeringWheel.SteeringWheelID);
            Assert.IsNull(steeringWheel.CarID);
        }
Ejemplo n.º 22
0
        [Test]  // Ensures that gets and sets in the code refer to the same property
        public void Test_PropertyGetters()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = new SteeringWheel();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            object valueForCarID = Guid.NewGuid();

            steeringWheel.CarID = (System.Guid)valueForCarID;

            //---------------Test Result -----------------------
            Assert.AreEqual(valueForCarID, steeringWheel.CarID);
        }
        [Test]  // Ensures that updates to property values are stored and can be retrieved
        public void Test_UpdateSteeringWheel()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            steeringWheel.Save();

            //---------------Test Result -----------------------
            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();
            SteeringWheel retrievedSteeringWheel =
                Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID);
        }
Ejemplo n.º 24
0
        public override void SafeAwake()
        {
            steeringWheel = GetComponent <SteeringWheel>();

            r2cToggle          = BB.AddToggle(LanguageManager.Instance.CurrentLanguage.ReturnToCenter, "Return to center", ReturnToCenter);
            r2cToggle.Toggled += (bool value) => { ReturnToCenter = NearToggle.DisplayInMapper = value; ChangedProperties(r2cToggle); };

            NearToggle          = BB.AddToggle(LanguageManager.Instance.CurrentLanguage.Near, "Near", Near);
            NearToggle.Toggled += (bool value) => { Near = value; ChangedProperties(NearToggle); };

            leftKey             = steeringWheel.KeyList.Find(match => match.Key == "left");
            rightKey            = steeringWheel.KeyList.Find(match => match.Key == "right");
            rotationSpeedSlider = steeringWheel.SpeedSlider;

#if DEBUG
            ConsoleController.ShowMessage("转向关节添加进阶属性");
#endif
        }
Ejemplo n.º 25
0
        [Test]  // Ensures that a class can be successfully saved
        public void Test_SaveSteeringWheel()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateUnsavedValidSteeringWheel();

            //---------------Assert Precondition----------------
            Assert.IsTrue(steeringWheel.Status.IsNew);
            BusinessObjectCollection <SteeringWheel> col = new BusinessObjectCollection <SteeringWheel>();

            col.LoadAll();
            Assert.AreEqual(0, col.Count);

            //---------------Execute Test ----------------------
            steeringWheel.Save();

            //---------------Test Result -----------------------
            Assert.IsFalse(steeringWheel.Status.IsNew);
            col.LoadAll();
            Assert.AreEqual(1, col.Count);
        }
Ejemplo n.º 26
0
        [Test]  // Checks that BOs in a single relationship load correctly (no tampering with class defs)
        public void Test_LoadThroughSingleRelationship_Car()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel();

            TestProject.BO.Car boForRelationshipCar = steeringWheel.Car;

            BusinessObjectManager.Instance.ClearLoadedObjects();
            GC.Collect();
            TestUtilsShared.WaitForGC();
            //---------------Execute Test ----------------------
            TestProject.BO.Car loadedRelatedBO     = Broker.GetBusinessObject <TestProject.BO.Car>(boForRelationshipCar.ID);
            SteeringWheel      loadedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID);

            //---------------Test Result -----------------------
            Assert.AreEqual(boForRelationshipCar, loadedSteeringWheel.Car);
            Assert.AreEqual(loadedRelatedBO, loadedSteeringWheel.Car);
            Assert.AreEqual(loadedRelatedBO, steeringWheel.Car);
        }
Ejemplo n.º 27
0
 void Awake()
 {
     body = GetComponent <Rigidbody>();
     originalCenterOfMass = body.centerOfMass;
     myTransform          = transform;
     drivetrain           = GetComponent <Drivetrain>();
     axisCarController    = GetComponent <AxisCarController>();
     mouseCarcontroller   = GetComponent <MouseCarController>();
     mobileCarController  = GetComponent <MobileCarController>();
     brakeLights          = GetComponent <BrakeLights>();
     dashBoard            = myTransform.GetComponentInChildren <DashBoard>();
     steeringWheel        = transform.GetComponentInChildren <SteeringWheel>();
     soundController      = GetComponent <SoundController>();
     SetController(controller.ToString());
     axles = GetComponent <Axles>();
     //frontWheels=axles.frontAxle.wheels;
     //rearWheels=axles.rearAxle.wheels;
     //otherWheels=axles.otherWheels;
     //axles.allWheels=axles.axles.allWheels;
     invAllWheelsLength     = 1f / axles.allWheels.Length;
     fixedTimeStepScalar    = 0.02f / Time.fixedDeltaTime;
     invFixedTimeStepScalar = 1 / fixedTimeStepScalar;
 }
Ejemplo n.º 28
0
        public void Test_NotSettingCompulsoryPropertiesThrowsException()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateUnsavedValidSteeringWheel();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            steeringWheel.SteeringWheelID = null;

            try
            {
                steeringWheel.Save();
                Assert.Fail("Should throw an exception when compulsory properties are null");
            }
            //---------------Test Result -----------------------
            catch (BusObjectInAnInvalidStateException ex)
            {
                StringAssert.Contains("Steering Wheel ID' is a compulsory field and has no value", ex.Message);
            }
        }
Ejemplo n.º 29
0
        [Test]  // Ensures that a class can be deleted
        public void Test_DeleteSteeringWheel()
        {
            CheckIfTestShouldBeIgnored();
            //---------------Set up test pack-------------------
            SteeringWheel steeringWheel = TestUtilsSteeringWheel.CreateSavedSteeringWheel();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            steeringWheel.MarkForDelete();
            steeringWheel.Save();
            //---------------Test Result -----------------------
            try
            {
                SteeringWheel retrievedSteeringWheel = Broker.GetBusinessObject <SteeringWheel>(steeringWheel.ID);
                Assert.Fail("expected Err");
            }
            catch (BusObjDeleteConcurrencyControlException ex)
            {
                StringAssert.Contains("A Error has occured since the object you are trying to refresh has been deleted by another user", ex.Message);
                StringAssert.Contains("There are no records in the database for the Class: SteeringWheel", ex.Message);
            }
        }
Ejemplo n.º 30
0
	void Awake(){
		body=rigidbody;
		originalCenterOfMass=body.centerOfMass;
		myTransform=transform;
		drivetrain= GetComponent<Drivetrain>();
		axisCarController = GetComponent <AxisCarController>();
		mouseCarcontroller = GetComponent <MouseCarController>();
		mobileCarController = GetComponent <MobileCarController>();
		brakeLights=GetComponent <BrakeLights>();
		dashBoard = myTransform.GetComponentInChildren <DashBoard>();
		steeringWheel = transform.GetComponentInChildren <SteeringWheel>();
		soundController=GetComponent<SoundController>();
		SetController(controller.ToString());
		axles=GetComponent<Axles>();
		//frontWheels=axles.frontAxle.wheels;
		//rearWheels=axles.rearAxle.wheels;
		//otherWheels=axles.otherWheels;
		//axles.allWheels=axles.axles.allWheels;
		invAllWheelsLength=1f/axles.allWheels.Length;
		fixedTimeStepScalar=0.02f/Time.fixedDeltaTime;
		invFixedTimeStepScalar=1/fixedTimeStepScalar;		
	}
Ejemplo n.º 31
0
 public Vehicle()
 {
     wheel = new SteeringWheel(); brake = new BrakePedal();
 }
Ejemplo n.º 32
0
 void Start()
 {
     _wheel = GetComponent<SteeringWheel>();
 }