private void Awake()
    {
        vehicleInput = GetComponent <VehicleInput>();
        wheels       = GetComponentsInChildren <Wheel>();

        screechDurationTimer = Timer.OfSeconds(minimumScreechDuration);
    }
示例#2
0
    void spawnPlayer(PlayerInfo player, int playerCount)
    {
        // spawns the car on the map in the right spot
        GameObject car        = Instantiate(carPool[player.carID * 4 + player.playerID - 1], spawnLocations[player.playerID - 1].position, spawnLocations[player.playerID - 1].rotation);
        RaycastCar raycastCar = car.GetComponentInChildren <RaycastCar>();

        cars[player.playerID - 1] = raycastCar;
        playerCars.Add(raycastCar);
        raycastCar.playerID = player.playerID;
        VehicleInput v = car.GetComponentInChildren <VehicleInput>();

        v.setPlayerNum(player.controllerID);
        if (raycastCar != null)
        {
            Camera c = raycastCar.gameObject.transform.parent.GetComponentInChildren <Camera>();
            if (playerCount == 2)
            {
                setUp_2(player.playerID, c);
            }
            else if (playerCount > 2)
            {
                setUp_3_4(player.playerID, c);
            }
        }

        setUpCarUI(raycastCar, player.playerID, playerCount);

        if (playerCount == 1)
        {
            rt.offsetMin = new Vector2(0, 150);
            rt.offsetMax = new Vector2(0, 150);
        }
    }
示例#3
0
    private void Start()
    {
        _vehicleInput = GetComponent <VehicleInput>();
        //InvokeRepeating("healthCooldown", 0, healFreq);
        healthCurrent = healthMax;

        gradient = new Gradient();

        // Populate the color keys at the relative time 0 and 1 (0 and 100%)
        colorKey          = new GradientColorKey[1];
        colorKey[0].color = vignetteColor;
        colorKey[0].time  = 0.0f;

        // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
        alphaKey          = new GradientAlphaKey[2];
        alphaKey[0].alpha = 1.0f;
        alphaKey[0].time  = 0.0f;
        alphaKey[1].alpha = 0.0f;
        alphaKey[1].time  = 1.0f;

        gradient.SetKeys(colorKey, alphaKey);

        _carBodyHolder   = GetComponent <Rigidbody>();
        raycastCarHolder = GetComponent <RaycastCar>();
        _carCollider     = raycastCarHolder.GetComponent <Collider>();
        _objectPooler    = ObjectPooler.instance;
    }
示例#4
0
 public void PlayerJoin(bool status, VehicleInput controllerNumber)
 {
     if (status == true)
     {
         _playerInput           = controllerNumber;
         _joined                = true;
         _playerNumberText.text = "PLAYER " + playerID;
         vehicleRotationHolder.SetActive(true);
         inactiveImage.enabled = false;
         infoPanelHolder.SetActive(true);
         AbilityInfoViewState();
         viewportCamera.enabled = true;
         cover.SetActive(false);
     }
     else if (status == false)
     {
         _joined = false;
         _ready  = false;
         _playerNumberText.text = "NO PLAYER";
         cover.SetActive(true);
         abilityExampleScript[selectedCarID].DeactivateAllAbilites();
         //vehicleRotationHolder.SetActive(false);
         viewportCamera.enabled = false;
         inactiveImage.enabled  = true;
         infoPanelHolder.SetActive(false);
         _playerInput = null;
         selectionManager.UpdateData(playerID, _ready, selectedCarID, 0);
     }
 }
示例#5
0
 public void PlayerJoin(bool status, VehicleInput controllerNumber)
 {
     if (status == true)
     {
         _occupied                = true;
         _playerInput             = controllerNumber;
         _statusText.text         = "PRESS A TO CONFIRM MAP";
         coverBox.enabled         = false;
         mineMapSelect.enabled    = true;
         stellarMapSelect.enabled = false;
         mineSnapshot.enabled     = true;
         stellarSnapshot.enabled  = false;
         foreach (Image snapshot in mineSnapshotBehind)
         {
             snapshot.enabled = false;
         }
         foreach (Image snapshot in stellarSnapshotBehind)
         {
             snapshot.enabled = false;
         }
     }
     else if (status == false)
     {
         mapSelectManager.LoadVehicleSelect();
         _occupied = false;
     }
 }
    // The time sequence for setting when to move the vehicle and when the vehicle runs its respawn function
    private IEnumerator RespawnSequence()
    {
        yield return(new WaitForSeconds(0.1f));

        // _carMesh.SetActive(false);
        yield return(new WaitForSeconds(respawnSeconds / 2f));

        VehicleInput vi = _playerObject.GetComponent <VehicleInput>();

        if (vi != null)
        {
            vi.setStatus(false);
        }
        _movingCar = true;
        // _carMesh.SetActive(true);
        yield return(new WaitForSeconds(respawnSeconds / 5f));

        _playerObject.GetComponent <CarHealthBehavior>().Respawn();
        RaycastCar car = _playerObject.GetComponent <RaycastCar>();

        car.ignoreGravityDirection = true;
        _movingCar = false;
        if (vi != null)
        {
            vi.setStatus(true);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     players       = FindObjectOfType <DataManager>();
     carInputs     = FindObjectOfType <RaycastCar>();
     abilityInputs = FindObjectOfType <VehicleAbilityBehavior>();
     playerNum     = FindObjectOfType <VehicleInput>();
 }
示例#8
0
 // Start is called before the first frame update
 void Start()
 {
     players       = FindObjectOfType <DataManager>();
     playerNum     = FindObjectOfType <VehicleInput>();
     awardWinners  = new int[awardList.Length];
     winningPlayer = 0;
     playerHype    = GetComponent <HypeManager>();
 }
示例#9
0
        public override EnemyState ProcessState()
        {
            var targetDirection = (target.position - self.position).normalized;

            Input = new VehicleInput(
                1,
                Vector3.Dot(self.right, targetDirection) > 0 ? 1 : -1);

            return(null);
        }
示例#10
0
 private void AssignPlayer(VehicleInput givenController)
 {
     for (int i = 0; i < viewports.Length; i++)
     {
         if (!viewports[i].GetOccupied())
         {
             viewports[i].PlayerJoin(true, givenController);
             break;
         }
     }
 }
示例#11
0
    public void Init(VehicleSetUpData setupData, VehicleInput vehicleInput, List <Axle> axles)
    {
        m_vehicleInput = vehicleInput;
        //m_maxWheelTorque = setupData.MaxEngineTorque;
        m_rigidBody = GetComponent <Rigidbody>();
        //m_rigidBody.centerOfMass = setupData.

        //TODO null check, should also be a list
        m_front = axles[0];
        m_rear  = axles[1];
    }
        public async Task <IActionResult> Create()
        {
            var brands = await _brandServices.GetAll(0, 0);

            var vehicle = new VehicleInput()
            {
                Brands = GetBrandsItems(brands)
            };

            return(View(vehicle));
        }
示例#13
0
    private void CheckController(VehicleInput givenController, string givenCommand)
    {
        bool inUse = false;
        ViewportController selectedViewport = null;

        for (int i = 0; i < viewports.Length; i++)
        {
            if (viewports[i].GetJoined() && viewports[i].GetInput() == givenController)
            {
                inUse            = true;
                selectedViewport = viewports[i];
                break;
            }
        }

        if (!inUse && !_readyToStart && givenCommand == "AwakeButtonTriggered")
        {
            AssignPlayer(givenController);
        }
        else if (givenCommand == "SelectButtonTriggered")
        {
            if (inUse && !_readyToStart && !selectedViewport.GetReady())
            {
                selectedViewport.VehicleSelect(true);
            }
            else if (inUse && _readyToStart && !_isLoading && selectedViewport.GetReady())
            {
                _isLoading = true;
                AudioManager.instance.Play("Menu Selection", this.transform);
                continueText.enabled = false;
                backText.enabled     = false;
                loadingText.SetActive(true);
                StartCoroutine(LoadingMapScene(nextSceneIndex));
            }
        }
        else if (givenCommand == "BackButtonTriggered")
        {
            if (inUse && !selectedViewport.GetReady())
            {
                selectedViewport.PlayerJoin(false, null);
                AudioManager.instance.PlayWithoutSpatial("Menu Selection");
            }
            else if (inUse && selectedViewport.GetReady())
            {
                selectedViewport.VehicleSelect(false);
                AudioManager.instance.PlayWithoutSpatial("Menu Selection");
            }
            else if (!inUse && !_readyToStart)
            {
                LoadMainMenu();
            }
        }
    }
示例#14
0
    void Start()
    {
        wheels = GetComponentsInChildren <Wheel>();

        if (wheels.Length > 0)
        {
            wheels[0].WheelCollider.ConfigureVehicleSubsteps(criticalSpeed, stepsBelow, stepsAbove);
        }

        vehicleInput = GetComponent <VehicleInput>();
        FindObjectOfType <CarUI>().RenderFor(gameObject);
    }
示例#15
0
 private void AssignPlayer(VehicleInput givenController)
 {
     for (int i = 0; i < viewports.Length; i++)
     {
         if (!viewports[i].GetJoined())
         {
             viewports[i].PlayerJoin(true, givenController);
             AudioManager.instance.PlayWithoutSpatial("Menu Selection");
             break;
         }
     }
 }
示例#16
0
        public StandardDemo(DemosGame game)
            : base(game)
        {
            freeCameraControlScheme = new FreeCameraControlScheme(10, game.Camera, game);

            //Creates the player character (C).
            character = new CharacterControllerInput(Space, game.Camera, game);

            //Creates the drivable vehicle (V).
            var wheelModel   = game.Content.Load <Model>("carWheel");
            var wheelTexture = game.Content.Load <Texture2D>("wheel");

            whitePixel = game.Content.Load <Texture2D>("whitePixel");
            vehicle    = new VehicleInput(new Vector3(10000, 0, 0), Space, game.Camera, game, game.ModelDrawer, wheelModel, wheelTexture);
            Space.ForceUpdater.Gravity = new Vector3(0, (Fix64)(-9.81m), 0); //If left unset, the default value is (0,0,0).

            //Create the tossable ball.
            kapow      = new Sphere(new Vector3(11000, 0, 0), (Fix64).6m, 20);
            kapowMaker = new Explosion(Vector3.Zero, 400, 15, Space);
            //Create the right-click grab spring.
            grabber                  = new MotorizedGrabSpring();
            grabberGraphic           = game.ConstraintDrawer.Add(grabber);
            grabberGraphic.IsDrawing = false;
            Space.Add(grabber);
            Space.Add(kapow);


            //IMPORTANT PERFORMANCE NOTE:
            //  BEPUphysics uses an iterative system to solve constraints.  You can tell it to do more or less iterations.
            //  Less iterations is faster; more iterations makes the result more accurate.
            //
            //  The amount of iterations needed for a simulation varies.  The "Wall" and "Pyramid" simulations are each fairly
            //  solver intensive, but as few as 4 iterations can be used with acceptable results.
            //  The "Jenga" simulation usually needs a few more iterations for stability; 7-9 is a good minimum.
            //
            //  The Dogbot demo shows how accuracy can smoothly increase with more iterations.
            //  With very few iterations (1-3), it has slightly jaggier movement, as if the parts used to construct it were a little cheap.
            //  As you give it a few more iterations, the motors and constraints get more and more robust.
            //
            //  Many simulations can work perfectly fine with very few iterations,
            //  and using a low number of iterations can substantially improve performance.
            //
            //  To change the number of iterations used, uncomment and change the following line (10 iterations is the default):

            //Space.Solver.IterationLimit = 10;

            rayCastFilter = RayCastFilter;
        }
示例#17
0
        public override EnemyState ProcessState()
        {
            if (target == null)
            {
                Input = new VehicleInput(0, 0);
                return(null);
            }

            var targetDirection = (target.position + target.right * 2.5f - self.position).normalized;

            Input = new VehicleInput(
                1.1f,
                Vector3.Dot(self.right, targetDirection) > 0 ? 0.8f : -0.8f);

            return(null);
        }
    private void Awake()
    {
        if (gameObject.GetComponent <VehicleInput>())
        {
            _vehicleInput = GetComponent <VehicleInput>();
            tracker       = GetComponent <VehicleAwardsTracker>();

            /*switch(_vehicleInput.GetPlayerNum())
             * {
             *  case 1:
             *
             *      foreach (Image borderImage in borderImages)
             *      {
             *          borderImage.color = new Color32(193, 62, 62, 255);
             *      }
             *      break;
             *
             *  case 2:
             *
             *      foreach (Image borderImage in borderImages)
             *      {
             *          borderImage.color = new Color32(209, 154, 62, 255);
             *      }
             *      break;
             *
             *  case 3:
             *
             *      foreach (Image borderImage in borderImages)
             *      {
             *          borderImage.color = new Color32(50, 145, 191, 255);
             *      }
             *      break;
             *
             *  case 4:
             *
             *      foreach (Image borderImage in borderImages)
             *      {
             *          borderImage.color = new Color32(43, 142, 43, 255);
             *      }
             *      break;
             * }*/
        }
        else
        {
            isAI = true;
        }
    }
        protected override void Update()
        {
            if (Input.GetButtonDown("Gas"))
            {
                TryToGearUp();

                wobbleIntensity        = gasOnWobble;
                steeringBoostIntensity = steeringBoost;
                camRig.SetFOV(75);
                camRig.ActivateZoomBoom();
                vehicle.AddImpulse(throttleImpulse);
            }
            if (Input.GetButtonUp("Gas"))
            {
                wobbleIntensity = gasOffWobble;
                camRig.SetFOV(65);
                camRig.DeactivateZoomBoom();
            }
            steeringBoostIntensity = Mathf.Max(steeringBoostIntensity - Time.deltaTime / steeringBoostDecay, 0);

            if (Input.GetButton("Gas"))
            {
                throttle = 1;
            }
            else
            {
                throttle = Mathf.Max(throttle - Time.deltaTime / throttleDecay, 0);
            }

            if (pheonixTimer == 0 && pheonixWindowTimer == 0)
            {
                gear = 0;
            }
            pheonixWindowTimer    = Mathf.Max(pheonixWindowTimer - Time.deltaTime, 0);
            pheonixTimer          = Mathf.Max(pheonixTimer - Time.deltaTime, 0);
            effectivePheonixBoost = pheonixTimer > 0 ? pheonixSpeedBoost : 1;

            var input = new VehicleInput(
                throttle * effectivePheonixBoost,
                Input.GetAxis("Horizontal") * (1 + steeringBoostIntensity),
                pheonixTimer > 0);

            vehicle.SetInput(input);

            base.Update();
        }
示例#20
0
    //Call allowing vehicle to take input from player
    private void Start()
    {
        _originalTopSpeed     = topSpeed;
        _originalAcceleration = acceleration;
        _originalDeceleration = deceleration;
        _originalSteering     = steering;
        //AudioManager.instance.Play("Engine");
        _vehicleInput = GetComponent <VehicleInput>();

        if (leftDriftParticles != null && rightDriftParticles != null) //placed here just so that the BallCar prefab doesn't throw nulls
        {
            leftDriftParticles.SetActive(false);
            rightDriftParticles.SetActive(false);
        }
        airborne      = false;
        airborneTimer = 0;
        aimOn         = true;
    }
示例#21
0
    private void CheckController(VehicleInput givenController)
    {
        bool inUse = false;

        for (int i = 0; i < viewports.Length; i++)
        {
            if (viewports[i].GetOccupied() && viewports[i].GetInput() == givenController)
            {
                Debug.Log("ishapp");
                inUse = true;
                break;
            }
        }
        if (!inUse)
        {
            AssignPlayer(givenController);
        }
    }
示例#22
0
    void Start()
    {
        arrP = GameObject.FindObjectsOfType <VehicleInput>();

        foreach (VehicleInput p in arrP)
        {
            VehicleInput v = p.gameObject.GetComponent <VehicleInput>();
            if (p.gameObject.GetComponent <SphereCarController>().tiltShift.gameObject != null)
            {
                Camera c = p.gameObject.GetComponent <SphereCarController>().tiltShift.gameObject.GetComponent <Camera>();
                if (arrP.Length == 2)
                {
                    setUp_2(v.getPlayerNum(), c);
                }
                else if (arrP.Length > 2)
                {
                    setUp_3_4(v.getPlayerNum(), c);
                }
            }
        }
    }
        public async Task <IActionResult> Create(VehicleInput vehicleInput)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _vehicleServices.Create(vehicleInput);
                }
                else
                {
                    var brands = await _brandServices.GetAll(0, 0);

                    vehicleInput.Brands = GetBrandsItems(brands);
                    return(View(vehicleInput));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                return(View(vehicleInput));
            }

            return(RedirectToAction("Index"));
        }
示例#24
0
    void Initialize()
    {
        // Cache Vehicle Input
        input = GetComponent <VehicleInput>();
        // Cache a reference to our car's transform
        carTransform = transform;
        // cache the rigidbody for our car
        carRigidbody = GetComponent <Rigidbody>();
        // cache the mass of our vehicle
        carMass = GetComponent <Rigidbody>().mass;
        // call to set up our wheels array
        setUpWheels();
        // we set a COG here and lower the center of mass to a
        //negative value in Y axis to prevent car from flipping over
        carRigidbody.centerOfMass = new Vector3(0f, -1.0f, -0f);
        frontLeftRayCast          = frontLeftWheel.GetComponentInParent <RaycastWheel>();
        frontRightRayCast         = frontRightWheel.GetComponentInParent <RaycastWheel>();
        rearLeftRayCast           = rearLeftWheel.GetComponentInParent <RaycastWheel>();
        rearRightRayCast          = rearRightWheel.GetComponentInParent <RaycastWheel>();
        gravityDirection          = -transform.up;

        lastSafePos = carTransform.position;

        rc = FindObjectOfType <RaceManager>();

        if (GetComponent <VehicleInput>())
        {
            //Sets ai spline to find/follow hotspotspline
            if (rc != null && rc.orderedSplines.Length != 0)
            {
                _aiSplineScript  = rc.orderedSplines[activeSpline].GetComponent <SplinePlus>();
                _branchesAtStart = new Dictionary <int, Branch>(_aiSplineScript.SPData.DictBranches);
                InvokeRepeating("findNearest", 0, 2);
            }
        }
    }
示例#25
0
 protected override void Start()
 {
     _playerInput = GetComponent <VehicleInput>();
 }
示例#26
0
 // Start is called before the first frame update
 void Start()
 {
     mouse = GetComponentInParent <VirtualMouse>();
     input = GetComponentInParent <VehicleInput>();
     gr    = GetComponentInParent <GraphicRaycaster>();
 }
示例#27
0
 private void Awake()
 {
     transmission = GetComponent <Transmission>();
     vehicleInput = GetComponent <VehicleInput>();
     carAudio     = GetComponent <CarAudio>();
 }
示例#28
0
 public void SetInput(VehicleInput input)
 {
     this.input = input;
 }
 public async Task Create(VehicleInput vehicleInput)
 {
     var vehicle = _mapper.Map <Vehicle>(vehicleInput);
     await _vehicleRepository.Create(vehicle);
 }
示例#30
0
 private void Awake()
 {
     m_vehicleInput = new VehicleInput();
 }