// ================================================================ // // 继承于MonoBehaviour void Awake() { this.input = new CarInput(this); this.wheels = new CarWheels(this); this.squeal_sound = this.gameObject.GetComponent <CarSoundSqueal>(); this.car_rigidbody = this.gameObject.GetComponent <Rigidbody>(); }
// called when passing a race checkpoint // counts laps and disables car controls at the end of the race void OnTriggerEnter(Collider other) { Checkpoint waypoint = other.GetComponent <Checkpoint>(); if (waypoint != currentWaypoint) { // not always wrong (3 colliders, the first replaces the current checkpoint, the other 2 think its wrong //Debug.Log ("Wrong checkpoint - " + other.gameObject.name); } else { waypointsPassed++; if (waypoint.isStartFinish) { lapsCompleted++; } if (lapsCompleted == totalLaps) { CarInput input = GetComponent <CarInput> (); input.controlable = false; input.Steer = 0; input.Handbrake = 1; input.Accell = 0; } Debug.Log("Checkpoint - " + other.gameObject.name); currentWaypoint = waypoint.next; } }
public void AreaNotSupportTest() { var cal = new TaxCalculator(); var car = new CarInput { Name = "Chery QQ", CarFrom = Area.Other, Capacity = 1.0, Price = 6000 }; cal.GetUserPrice(car); }
public void InvalidInput_Capacity_Equals_Zero_Test() { var cal = new TaxCalculator(); var car = new CarInput { Name = "Jeep wrangler", CarFrom = Area.Usa, Capacity = 0, Price = 36995 }; cal.GetUserPrice(car); }
public void InvalidInput_Price_Less_Then_Zero_Test() { var cal = new TaxCalculator(); var car = new CarInput { Name = "Jeep wrangler", CarFrom = Area.Usa, Capacity = 6, Price = -2 }; cal.GetUserPrice(car); }
public void JapanCarTest() { var cal = new TaxCalculator(); var car = new CarInput { Name = "Honda Jazzy", CarFrom = Area.Japan, Capacity = 1.5, Price = 19490 }; double expectedPrice = 1744121.12; Assert.AreEqual(expectedPrice, cal.GetUserPrice(car), delta); }
public void UsaCarTest() { var cal = new TaxCalculator(); var car = new CarInput { Name = "Jeep wrangler", CarFrom = Area.Usa, Capacity = 3.6, Price = 36995 }; double expectedPrice = 3700091.92; Assert.AreEqual(expectedPrice, cal.GetUserPrice(car), delta); }
public void EuroCar_Capacity_Greater_Than_6_Test() { var cal = new TaxCalculator(); var euroCar = new CarInput { Name = "Benz G65", CarFrom = Area.Euro, Capacity = 16.0, Price = 217900 }; double expectedPrice = 34410768; Assert.AreEqual(expectedPrice, cal.GetUserPrice(euroCar), delta); }
public ActionResult Create(CarInput input) { if (!ModelState.IsValid) { return(View(input)); } Context.cars.Add(new Car { ID = input.ID, Color = input.Color, Brand = input.Brand, CarModel = input.CarModel, ParkingSpotNumber = input.ParkingSpotNumber, CarPlate = input.CarPlate, EnterDate = DateTime.Now }); return(RedirectToAction("List")); }
private void Start() { input = CarInput.Instance; index = 0; state = 0; transform.localPosition = initPosition; source = GetComponent<AudioSource>(); creditsMovie.Play (); source.Play (); fadeColor = fade.color; fadeColor.a = 1.0f; fade.color = fadeColor; }
// Start is called before the first frame update void Start() { _input = GetComponent <CarInput>(); numOfWeapons = weapons.Count; if (numOfWeapons > 0) { curWeapon = weapons[0]; curWeaponScript = curWeapon.GetComponentInChildren <Weapon>(); } else { curWeapon = null; curWeaponScript = null; } }
void OnTriggerEnter(Collider other) { //other = 경기중인 차 if (other.tag == "Bullet") { return; } CheckPoint checkPoint = other.GetComponent <CheckPoint>(); //자동차의 현재 체크포인트를 받는다. if (checkPoint != currentCheckPoint) { } else //체크포인트가 맞다면 { checkpointPassed++; //체크포인트가 finishline = true 라면 if (checkPoint.finishline) { lapsCompleted++; } //완료한 랩이 마지막 랩이면 if (lapsCompleted == totalLaps) { CarInput input = GetComponent <CarInput>(); input.controlable = false; input.steer = 0; input.handbreak = 1; input.accel = 0; state = RaceState.FINISHED; //입력중지, 모든값 0, 레이스 상태 FINISHED } currentCheckPoint = checkPoint.next; //다음체크포인트 } }
private void OnDestroy() { if (!isInitialized) { return; } input.Disable(); input.Car.Accelerate.started -= HandleAccelerate; input.Car.Accelerate.canceled -= HandleAccelerateRelease; input.Car.DeAccelerate.started -= HandleDeAccelerate; input.Car.DeAccelerate.canceled -= HandleDeAccelerateRelease; input.Dispose(); input = null; isInitialized = false; }
public void Init() { if (isInitialized) { return; } wheelController.Init(); input = new CarInput(); input.Enable(); input.Car.Accelerate.started += HandleAccelerate; input.Car.Accelerate.canceled += HandleAccelerateRelease; input.Car.DeAccelerate.started += HandleDeAccelerate; input.Car.DeAccelerate.canceled += HandleDeAccelerateRelease; isInitialized = true; }
private void Explode() { _rigidBody.AddForce(Vector3.up * _rigidBody.mass * 5f, ForceMode.Impulse); CarInput carInputController = GetComponent <CarInput>(); if (carInputController != null) { Destroy(carInputController); } AudioSource explosionSource = _cacheManager.GetAudioSource(_gameObject, "xcar"); if (explosionSource != null) { explosionSource.volume = 0.9f; explosionSource.Play(); } EngineRunning = false; Destroy(_engineLoopSound); Destroy(_engineStartSound); Movement.Destroy(); Movement = null; AI = null; WeaponsController = null; SpecialsController = null; SystemsPanel = null; GearPanel = null; _compassPanel = null; RadarPanel = null; Destroy(transform.Find("FrontLeft").gameObject); Destroy(transform.Find("FrontRight").gameObject); Destroy(transform.Find("BackLeft").gameObject); Destroy(transform.Find("BackRight").gameObject); }
private void OnEnable() { usedSlots = 0; selected = 0; pressed = false; moving = false; multiplayerManager = transform.root.GetComponent<MultiplayerManager>(); carInput = CarInput.Instance; for(int i = 0; i < nameLabel.Length; i++) { nameLabel[i].transform.parent.gameObject.SetActive (false); } for(int i = 0; i < sizeLabel.Length; i++) { sizeLabel[i].transform.parent.gameObject.SetActive (false); } cursor.gameObject.SetActive (false); errorMessage.SetActive (false); UpdateList(); }
void Awake() { // transforms sphere = transform.Find("Sphere"); car = transform.Find("Model"); chassis = car.Find("Chassis"); leftFrontWheel = car.Find("Front Left Tire"); rightFrontWheel = car.Find("Front Right Tire"); leftRearWheel = car.Find("Rear Left Tire"); rightRearWheel = car.Find("Rear Right Tire"); offset = car.position - sphere.position; sphereRB = sphere.GetComponent <Rigidbody>(); // particle systems particleSystems = new ParticleSystem[] { leftFrontWheel.GetComponentInChildren <ParticleSystem>(), rightFrontWheel.GetComponentInChildren <ParticleSystem>(), leftRearWheel.GetComponentInChildren <ParticleSystem>(), rightRearWheel.GetComponentInChildren <ParticleSystem>() }; foreach (ParticleSystem p in particleSystems) { p.Play(); var emission = p.emission; emission.rateOverTime = 0; } // input input = new CarInput { acceleration = 0, turn = 0 }; }
private void Awake() { carInput = GetComponent <CarInput>(); rb = GetComponent <Rigidbody>(); }
private void Start() { if(audioSource == null) { audioSource = GetComponent<AudioSource>(); } if(settingsManager == null) { settingsManager = transform.root.GetComponent<SettingsManager>(); } if(carDrifting == null) { carDrifting = settingsManager.GetComponent<CarDrifting>(); } if(multiplayerManager == null) { multiplayerManager = settingsManager.GetComponent<MultiplayerManager>(); } if(carInput == null) { carInput = CarInput.Instance; } _showing = false; menuAudioSource.enabled = true; audioSource.enabled = true; hasExternal = false; folderPath = Application.dataPath + "/Music/"; #if !UNITY_EDITOR StartCoroutine(GetStreamMusic()); #endif }
private void Awake() { carInput = GetComponent<CarInput>(); }
[Inject] public void Construct(CarInput input) { _input = input; }
public override double GetUserPrice(CarInput input) { return(carImports[(int)input.CarFrom].GetUserPrice(input.Capacity, input.Price)); }
public virtual double GetUserPrice(CarInput input) { throw new NotImplementedException(); }
private void Start() { volumeFadeIn = true; AudioListener.volume = 0.0f; // Initialize values pauseAnimation = false; pause = false; started = false; client = false; settings = false; isDrifting = false; canContinue = false; canDrift = true; canShowExtra = true; avoiding = false; timeLabelState = 0; totalScore = 0; driftScore = 0; maxDriftScore = 0; multiplier = 0; rigidbodyVelocity = Vector3.zero; multiplierTemp = multiplierTempInit; collisionTemp = collisionTempInit; avoidTemp = avoidTempInit; initPosition = new Vector3[labelsUI.Length]; dataManager = DataManager.Instance; carInput = CarInput.Instance; if(!standaloneModule) { standaloneModule = GameObject.Find ("EventSystem").GetComponent<KeyboardInputModule>(); } if(dataManager.isGamepad) { standaloneModule.horizontalAxis = "Horizontal360"; standaloneModule.verticalAxis = "Vertical360"; standaloneModule.submitButton = "Submit360"; standaloneModule.cancelButton = "Cancel360"; #if !UNITY_EDITOR UnityEngine.Cursor.visible = false; UnityEngine.Cursor.lockState = CursorLockMode.Locked; #endif } else { standaloneModule.horizontalAxis = "Horizontal"; standaloneModule.verticalAxis = "Vertical"; standaloneModule.submitButton = "Submit"; standaloneModule.cancelButton = "Cancel"; #if !UNITY_EDITOR UnityEngine.Cursor.visible = false; UnityEngine.Cursor.lockState = CursorLockMode.None; #endif } if(dataManager.isGamepad) { #if !UNITY_EDITOR UnityEngine.Cursor.visible = false; UnityEngine.Cursor.lockState = CursorLockMode.Locked; #endif } else { #if !UNITY_EDITOR UnityEngine.Cursor.visible = false; UnityEngine.Cursor.lockState = CursorLockMode.None; #endif } // Load data maxDriftScore = dataManager.bestDrift; for(int i = 0; i < labelsUI.Length; i++) { labelsUI[i].color = initColor; auxColor = labelsUI[i].color; auxColor.a = initAlpha; labelsUI[i].color = auxColor; initPosition[i] = labelsUI[i].transform.position; } network = GetComponent<CustomNetworkManager>(); introAnimation = GetComponent<CameraIntroAnimation>(); settingsManager = GetComponent<SettingsManager>(); extraTweenText = extraTween.GetComponent<Text>(); challengeLabelTween = challengeLabel.GetComponent<TweenFontSize>(); bloomUI = GameObject.Find ("UICamera").GetComponent<Bloom>(); pauseUI.SetActive (false); settingsUI.SetActive (false); gameplayUI.SetActive (false); startUI.SetActive(false); bloomUI.enabled = false; EventSystem.current.SetSelectedGameObject(null); // Enable match maker by default network.StartMatchMaker(); network.matchMaker.SetProgramAppID((UnityEngine.Networking.Types.AppID)338802); network.SetMatchHost("mm.unet.unity3d.com", 443, true); network.matchSize = 5; network.matchName = adressField.text; }
static CarInput() { instance = ScriptableObject.CreateInstance<CarInput>(); }
private void Start () { // Initialize values engine = GetComponent<CarEngine>(); carSetup = GetComponent<CarSetup>(); wheels = carSetup.Wheels; basicMaxRPM = carSetup.EngineMaxRPM; lightsSetup = GetComponent<LightsSetup>(); audioSource = GetComponent<AudioSource>(); cameraRig = GetComponent<CameraRig>(); carRigidbody = GetComponent<Rigidbody>(); carInput = CarInput.Instance; rumbling = false; rumbleTemp = rumbleTempInit; auxObject = null; dataManager = DataManager.Instance; sparksManager = GameObject.Find ("SparksManager").GetComponent<SparksManager>(); lookBack = false; respawnTemp = respawnTempInit; isPlayer = false; if(GetComponent<NetworkIdentity>()) { netIdentity = GetComponent<NetworkIdentity>(); isPlayer = netIdentity.isLocalPlayer; } else { isPlayer = true; } // Set up visual car switch(Application.platform) { case RuntimePlatform.WindowsEditor: case RuntimePlatform.WindowsPlayer: case RuntimePlatform.WindowsWebPlayer: { for(int i = 0; i < lowObjects.Length; i++) { lowObjects[i].SetActive (false); } for(int i = 0; i < highObjects.Length; i++) { highObjects[i].SetActive (true); } break; } case RuntimePlatform.WebGLPlayer: case RuntimePlatform.IPhonePlayer: case RuntimePlatform.BlackBerryPlayer: case RuntimePlatform.Android: { for(int i = 0; i < lowObjects.Length; i++) { lowObjects[i].SetActive (true); } for(int i = 0; i < highObjects.Length; i++) { highObjects[i].SetActive (false); } break; } default: { for(int i = 0; i < lowObjects.Length; i++) { lowObjects[i].SetActive (true); } for(int i = 0; i < highObjects.Length; i++) { highObjects[i].SetActive (false); } break; } } renderers = GetComponentsInChildren<MeshRenderer>(); }
public double GetUserPrice(CarInput car) { int index = (int)Math.Min(Math.Max(Math.Ceiling(Math.Min(car.Capacity, car.Price)), 0), 1); return(validations[index].GetUserPrice(car)); }
public override double GetUserPrice(CarInput car) { throw new Exceptions.InvalidInputCarException(); }
public void ApplyInput(CarInput input) { this.input = input; }
private void Awake() { carInput = new CarInput(); }
private void Start () { // Initialize carInput = CarInput.Instance; actualButton = false; canMove = true; resolutionType = (ResolutionType)DataManager.Instance.resolution; switch(resolutionType) { case ResolutionType._800x600: { textButton.text = "Resolution: 800x600"; break; } case ResolutionType._1024x768: { textButton.text = "Resolution: 1024x768"; break; } case ResolutionType._1280x720: { textButton.text = "Resolution: 1280x720"; break; } case ResolutionType._1280x1024: { textButton.text = "Resolution: 1280x1024"; break; } case ResolutionType._1366x768: { textButton.text = "Resolution: 1366x768"; break; } case ResolutionType._1440x900: { textButton.text = "Resolution: 1440x900"; break; } case ResolutionType._1680x1050: { textButton.text = "Resolution: 1680x1050"; break; } case ResolutionType._1920x1080: { textButton.text = "Resolution: 1920x1080"; break; } } // Get references if(settingsManager == null) { settingsManager = transform.root.GetComponent<SettingsManager>(); } if(GetComponent<AudioSource>()) { audioSource = GetComponent<AudioSource>(); } }
private void Start() { volumeFadeIn = true; AudioListener.volume = 0.0f; // Initialize values pauseAnimation = false; pause = false; started = false; settings = false; isDrifting = false; canContinue = false; canDrift = true; canShowExtra = true; avoiding = false; pressedExit = false; tutorial = false; canAdvanceTutorial = true; driftTutorial = false; driftTutorialObjective = false; driftTutorialDriftDone = false; checkingGamepad = false; disabledUI = false; totalScore = 0; driftScore = 0; maxDriftScore = 0; multiplier = 0; challengeTextState = 0; tutorialState = 0; driftTutorialState = 0; playerName = ""; previousTimeScale = Time.timeScale; rigidbodyVelocity = Vector3.zero; multiplierTemp = multiplierTempInit; collisionTemp = collisionTempInit; avoidTemp = avoidTempInit; initPosition = new Vector3[labelsUI.Length]; dataManager = DataManager.Instance; carInput = CarInput.Instance; // Initialize time challenge values leftTime = leftTimeInit; timePickupsCount = timePickupRoot.transform.childCount; currentTimePickup = 0; timePickups = new GameObject[timePickupsCount]; for(int i = 0; i < timePickups.Length; i++) { timePickups[i] = timePickupRoot.transform.GetChild (i).gameObject; } for(int i = 0; i < timePickups.Length; i++) { timePickups[i].GetComponent<DriftPickup>().DisablePickupForMinimap(); } timeChallengeUI.SetActive (false); for(int i = 0; i < freeTutorialLabels.Length; i++) { freeTutorialCameras[i].enabled = false; freeTutorialLabels[i].SetActive (false); } for(int i = 0; i < challengeTutorialCameras.Length; i++) { challengeTutorialCameras[i].enabled = false; challengeTutorialLabels[i].SetActive (false); } // Get player references carController = GameObject.FindWithTag ("Player").GetComponent<CarController>(); carEngine = carController.GetComponent<CarEngine>(); carSetup = carController.GetComponent<CarSetup>(); carAudio = carController.GetComponent<CarAudio>(); carRigidbody = carController.GetComponent<Rigidbody>(); introAnimation = GetComponent<CameraIntroAnimation>(); settingsManager = GetComponent<SettingsManager>(); extraTweenText = extraTween.GetComponent<Text>(); challengeLabelTween = challengeLabel.GetComponent<TweenFontSize>(); bloomUI = GameObject.Find ("UICamera").GetComponent<Bloom>(); if(dataManager.isGamepad) { #if !UNITY_EDITOR UnityEngine.Cursor.visible = false; UnityEngine.Cursor.lockState = CursorLockMode.Locked; #endif } else { #if !UNITY_EDITOR UnityEngine.Cursor.visible = false; UnityEngine.Cursor.lockState = CursorLockMode.None; #endif } // Load data maxDriftScore = dataManager.bestDrift; for(int i = 0; i < labelsUI.Length; i++) { labelsUI[i].color = initColor; auxColor = labelsUI[i].color; auxColor.a = initAlpha; labelsUI[i].color = auxColor; initPosition[i] = labelsUI[i].transform.position; } pauseUI.SetActive (false); settingsUI.SetActive (false); gameplayUI.SetActive (false); startUI.SetActive(false); bloomUI.enabled = false; carController.enabled = false; carEngine.enabled = false; carSetup.enabled = false; carRigidbody.isKinematic = true; //carRigidbody.constraints = RigidbodyConstraints.FreezeAll; // Disable car audio carAudio.EnableSources(0.5f); EventSystem.current.SetSelectedGameObject(null); }
private void Awake() { carInput = GetComponent <CarInput>(); }