예제 #1
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;
    }
예제 #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);
        }
    }
    // 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);
        }
    }
예제 #4
0
    // Start is called before the first frame update
    void Start()
    {
        _inArena = false;

        /*if (SceneManager.GetActiveScene() == SceneManager.GetSceneByBuildIndex(MineMap))
         * {
         *  nodesToLookAhead = MineNodes;
         *  offsetAngle = MineOffset;
         * }
         * else if (SceneManager.GetActiveScene() == SceneManager.GetSceneByBuildIndex(Interstellar))
         * {
         *  nodesToLookAhead = InterstellarNodes;
         *  offsetAngle = InterstellarOffset;
         * }*/


        nodesToLookAhead = InterstellarNodes;
        offsetAngle      = InterstellarOffset;

        avo = GetComponentInChildren <AIObstacleAvoidance>();

        thisCar = GetComponent <RaycastCar>();

        // //thisCar.drift = true;
    }
예제 #5
0
    public IEnumerator ResetBoost(float timeToReset, RaycastCar carToReset)
    {
        yield return(new WaitForSeconds(timeToReset));

        carToReset.gameObject.GetComponent <RaycastCar>().ResetBoostPadSpeed();
        _boostedCars.Remove(carToReset);
    }
예제 #6
0
 // Start is called before the first frame update
 void Start()
 {
     players       = FindObjectOfType <DataManager>();
     carInputs     = FindObjectOfType <RaycastCar>();
     abilityInputs = FindObjectOfType <VehicleAbilityBehavior>();
     playerNum     = FindObjectOfType <VehicleInput>();
 }
예제 #7
0
 public void SetImmunePlayer(GameObject immunePlayer)
 {
     _immunePlayer = immunePlayer;
     if (_immunePlayer.GetComponent <RaycastCar>() != null)
     {
         _immunePlayerScript = _immunePlayer.GetComponent <RaycastCar>();
     }
 }
예제 #8
0
 private void Start()
 {
     carInfo     = gameObject.GetComponent <RaycastCar>();
     carHeatInfo = gameObject.GetComponent <CarHealthBehavior>();
     if (carInfo != null)
     {
         originalMaxTurnAngle = carInfo.maxTurnAngle;
     }
 }
예제 #9
0
 void setUpCarUI(RaycastCar car, int playerID, int playerCount)
 {
     // Setup car dependent on # of players and car #
     if (playerCount == 2)
     {
         if (playerID == 2)
         {
             car.UIPanel.anchorMin = new Vector2(0, 0);
             car.UIPanel.anchorMax = new Vector2(1, .5f);
         }
         else
         {
             car.UIPanel.anchorMin = new Vector2(0, .5f);
             car.UIPanel.anchorMax = new Vector2(1, 1);
         }
         for (int i = 0; i < car.secondaryUIPanel.childCount; i++)
         {
             car.secondaryUIPanel.GetChild(i).localScale = car.secondaryUIPanel.GetChild(i).localScale *twoPlayerUIScalingFactor;
         }
     }
     else if (playerCount >= 3)
     {
         if (playerCount == 3)
         {
             fourthPlayerPanel.SetActive(true);
         }
         if (playerID == 1)
         {
             car.UIPanel.anchorMin = new Vector2(0, .5f);
             car.UIPanel.anchorMax = new Vector2(.5f, 1);
             car.UIPanel.pivot     = new Vector2(1, 1);
         }
         else if (playerID == 2)
         {
             car.UIPanel.anchorMin = new Vector2(.5f, .5f);
             car.UIPanel.anchorMax = new Vector2(1, 1);
             car.UIPanel.pivot     = new Vector2(1, 1);
         }
         else if (playerID == 3)
         {
             car.UIPanel.anchorMin = new Vector2(0, 0);
             car.UIPanel.anchorMax = new Vector2(.5f, .5f);
             car.UIPanel.pivot     = new Vector2(0, 0);
         }
         else if (playerID == 4)
         {
             car.UIPanel.anchorMin = new Vector2(.5f, 0);
             car.UIPanel.anchorMax = new Vector2(1, .5f);
             car.UIPanel.pivot     = new Vector2(1, 0);
         }
         for (int i = 0; i < car.secondaryUIPanel.childCount; i++)
         {
             car.secondaryUIPanel.GetChild(i).localScale = car.secondaryUIPanel.GetChild(i).localScale *threePlusPlayerUIScalingFactor;
         }
     }
 }
예제 #10
0
    // If there is no HotSpotBot, spawn the vehicle at the nearest point on the spline from its death location
    private void SpawnOnNearestSplinePoint()
    {
        RaycastCar car = _playerObject.GetComponent <RaycastCar>();
        Vector3    nearestPointOnSpline = car.GetNearestPointOnSpline(0);

        Vector3 pointOnSplineForward = car.GetNearestPointOnSpline(lookDistanceForward);

        LocalUp            = FindNormal(nearestPointOnSpline, _raceManager.orderedSplines[car.activeSpline]).normalized;
        transform.position = new Vector3(nearestPointOnSpline.x, nearestPointOnSpline.y, nearestPointOnSpline.z) + (spawnHeight * LocalUp);
        transform.LookAt(pointOnSplineForward, LocalUp);
    }
예제 #11
0
    // Start is called before the first frame update
    void Start()
    {
        _boostFieldScript = boostField.GetComponent <PainTrain_BoostShock>();
        _boostFieldScript.GiveInfo(gameObject, boostDamage, boostDamageRate);

        carInfo = gameObject.GetComponent <RaycastCar>();
        AbilityOffOfCooldown();
        if (carInfo != null)
        {
            originalMaxTurnAngle = carInfo.maxTurnAngle;
        }
    }
예제 #12
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <VehicleAbilityBehavior>())
     {
         _ability.Invoke(other.gameObject);
         if (other.GetComponent <VehicleInput>() != null)
         {//if it's a player
             _carToAdd = other.gameObject.GetComponent <RaycastCar>();
             _carToAdd.playerUIManagerScript.weaponsActivatedText.SetActive(true);
             _carToAdd.playerUIManagerScript.ResetWeaponText(4);
         }
     }
 }
예제 #13
0
 // Update is called once per frame
 void Update()
 {
     // Move the vehicle logic object to the platform position which includes the camera
     if (_movingCar)
     {
         _carMesh.transform.rotation      = transform.rotation;
         _playerObject.transform.position = new Vector3
                                                (transform.position.x, transform.position.y, transform.position.z) + (2 * LocalUp);
         _playerObject.transform.rotation = transform.rotation;
         RaycastCar car = _playerObject.GetComponent <RaycastCar>();
         car.ignoreGravityDirection = true;
         car.setGravityFlag(true);
     }
 }
예제 #14
0
 public void OnTriggerEnter(Collider other)
 {
     if (isActive)
     {
         if (other.gameObject.GetComponent <RaycastCar>() != null)
         {
             _carToAdd = other.gameObject.GetComponent <RaycastCar>();
             if (!_boostedCars.Contains(_carToAdd))
             {
                 _boostedCars.Add(_carToAdd);
                 other.gameObject.GetComponent <RaycastCar>().SetBoostPadSpeed(speedBoostPercentage / 100);
                 //   StartCoroutine(ResetBoost(boostTime, _carToAdd));
             }
         }
     }
 }
예제 #15
0
    IEnumerator distanceKill()
    {
        while (true)
        {
            yield return(null);

            if (_raceManager != null)
            {
                rearPlayer = _raceManager.cars[0];
                foreach (RaycastCar i in _raceManager.playerCars)
                {
                    if (i.activeSpline == rearPlayer.activeSpline)
                    {
                        if (i.closestIndex < rearPlayer.closestIndex)
                        {
                            rearPlayer = i.GetComponent <RaycastCar>();
                        }
                    }
                    else if (i.activeSpline < rearPlayer.activeSpline)
                    {
                        rearPlayer = i.GetComponent <RaycastCar>();
                    }
                }

                if (rearPlayer.activeSpline == GetComponent <RaycastCar>().activeSpline)
                {
                    if (rearPlayer.closestIndex - GetComponent <AIBehaviour>().closestIndex > killDist)
                    {
                        GetComponent <CarHealthBehavior>().AICheatKill();
                    }
                }
                else if (rearPlayer.activeSpline > GetComponent <RaycastCar>().activeSpline)
                {
                    if (rearPlayer.closestIndex > killDist - 20)
                    {
                        GetComponent <RaycastCar>().activeSpline++;
                        _raceManager.aiMan.updateAI(GetComponent <AIBehaviour>());
                        GetComponent <CarHealthBehavior>().AICheatKill();
                    }
                }
                yield return(new WaitForSeconds(2.0f));
            }
        }
    }
예제 #16
0
    // Start is called before the first frame update
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.GetComponent <RaycastCar>() != null)
        {
            foreach (ParticleSystem vfx in vfxToActivate)
            {
                vfx.Play();
            }

            _carToAdd = other.gameObject.GetComponent <RaycastCar>();
            if (!_boostedCars.Contains(_carToAdd))
            {
                _boostedCars.Add(_carToAdd);
                other.gameObject.GetComponent <RaycastCar>().SetBoostPadSpeed(speedBoostPercentage / 100);
                StartCoroutine(ResetBoost(boostTime, _carToAdd));
                AudioManager.instance.Play("BoostPad", other.gameObject.transform);
            }
        }
    }
예제 #17
0
    // Start is called before the first frame update
    void Start()
    {
        RaceManager.tokens = 3;
        fourthPlayerPanel.SetActive(false);
        eventPanel   = GameObject.FindGameObjectWithTag("EventPanel");
        AIindex      = Random.Range(0, AICar.Length);
        rt           = eventPanel.GetComponent <RectTransform>();
        rt.offsetMin = new Vector2(0, 0);
        rt.offsetMax = new Vector2(0, 0);
        time         = 0;
        playerCars   = new List <RaycastCar>();

        spawnAI = DataManager.instance.CheckAISpawning();

        dm = DataManager.instance;
        if (dm == null)
        {
            Debug.LogError("Cannot find DataManager");
        }
        else
        {
            AudioManager.instance.SetRaceManager(this);
            int playerCount = dm.getNumActivePlayers();
            if (spawnAI)
            {
                cars = new RaycastCar[dm.playerInfo.Length];
            }
            else
            {
                cars = new RaycastCar[playerCount];
            }
            int playerNum = 1;
            int AINum     = 0;

            foreach (PlayerInfo player in dm.playerInfo)
            {
                if (player.isActive)
                {
                    spawnPlayer(player, playerCount);
                    playerNum++;
                }
                else
                {
                    if (spawnAI == true)
                    {
                        RaycastCar aiCar = Instantiate(AICar[AIindex], spawnLocations[playerNum + AINum - 1].position, spawnLocations[playerNum + AINum - 1].rotation).GetComponentInChildren <RaycastCar>();
                        cars[playerNum + AINum - 1] = aiCar;
                        aiMan.aiCars.Add(aiCar);
                        aiCar.playerID = player.playerID;
                        AINum++;
                        AIindex++;
                        if (AIindex >= AICar.Length)
                        {
                            AIindex = 0;
                        }
                    }
                }
            }
        }
        eventPanel.SetActive(false);
        foreach (RaycastCar i in aiMan.aiCars)
        {
            aiMan.updateAI(i.GetComponent <AIBehaviour>());
        }
    }
예제 #18
0
    // Start is called before the first frame update
    void Start()
    {
        arenaStatus.SetActive(false);
        if (GameObject.FindGameObjectWithTag("GameManager") != null)
        {
            _hypeManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <HypeManager>();
            _rm          = GameObject.FindGameObjectWithTag("GameManager").GetComponent <RaceManager>();
        }
        else
        {
            Debug.LogWarning("Game Manager Can Not be Found");
        }
        int numPlayers = 1;

        if (DataManager.instance != null)
        {
            numPlayers = DataManager.instance.getNumActivePlayers();
            _dm        = DataManager.instance;
        }
        else
        {
            Debug.LogWarning("Data Manager Can Not be Found");
        }

        int playerNum = vehicleInputScript.getPlayerNum();

        _chb = vehicleInputScript.GetComponent <CarHealthBehavior>();

        _raycastCarHolder = vehicleInputScript.GetComponent <RaycastCar>();
        _dm.playerUIDictionary.Add(_raycastCarHolder.playerID, this);

        //Old Attack Indicator Setup

        /*
         * if (numPlayers > 1)
         * {
         *  _heightOffset = 0.057f;
         *  for (int i = 0; i < attackIndicators.Count; i++)
         *  {
         *      attackIndicators[i].transform.localScale = multiplePlayerScale;
         *  }
         * }
         * else
         * {
         *  for (int i = 0; i < attackIndicators.Count; i++)
         *  {
         *      attackIndicators[i].transform.localScale = onePlayerScale;
         *  }
         * }
         */
        switch (playerNum)
        {
        case 1:     //is player 1
            if (numPlayers == 2)
            {
                offSetVector = new Vector3(0, localCam.pixelHeight, 0);
            }
            else if (numPlayers >= 3)
            {
                offSetVector = new Vector3(0, localCam.pixelHeight, 0);
            }
            break;

        case 2:     //is player 2
            if (numPlayers >= 3)
            {
                offSetVector = new Vector3(localCam.pixelWidth, localCam.pixelHeight, 0);
            }
            break;

        case 3:     //is player 3
            offSetVector = new Vector3(0, 0, 0);
            break;

        case 4:     //is player 4
            offSetVector = new Vector3(localCam.pixelWidth, 0, 0);
            break;
        }
        //Legacy Hype and Pole position Setters, Assigned per player
        //hypeText.color = Color.cyan;
        //hypeDisplay.sprite = hypeDisplayColors[playerNum - 1];
        //poleBean.sprite = beanSprites[playerNum - 1];
    }
예제 #19
0
 protected void Initialize()
 {
     car = gameObject.GetComponent <RaycastCar>();
 }
예제 #20
0
 private void Awake()
 {
     car = parent.GetComponent <RaycastCar>();
 }
예제 #21
0
    private void OnTriggerEnter(Collider other)
    {
        RaycastCar temp = other.GetComponent <RaycastCar>();

        if (isSecondTrigger == false)
        {
            if (temp != null)
            {
                if ((DataManager.instance.playerInfo[temp.playerID - 1].placeRace1 > previousPlace))
                {
                    DataManager.instance.playerInfo[temp.playerID - 1].placeRace1 = place;
                    previousPlace++;
                    place++;
                }
                if (DataManager.instance.playerInfo[temp.playerID - 1].isActive)
                {
                    humansFinish++;
                }
                if (humansFinish >= numHumans)
                {
                    // give all AI that havent finshed yet a time
                    float previousTime = rm.time;
                    for (int i = 0; i < DataManager.instance.playerInfo.Length; i++)
                    {
                        //If they haven't finished the race yet
                        if (DataManager.instance.playerInfo[i].placeRace1 == 3 && DataManager.instance.playerInfo[i].timerRace1 == 0f)
                        {
                            previousTime = supplyTime(i, previousTime, true);
                            place++;
                        }
                    }
                }
            }
        }
        else if (isSecondTrigger == true)
        {
            if (temp != null)
            {
                temp.finished = true;
                if (place == 0)
                {
                    if (temp.GetComponent <VehicleInput>())
                    {
                        if (numHumans > 1)
                        {
                            hm.setNumNodes(temp.GetComponent <RaycastCar>().closestIndex);
                            StartCoroutine(hm.EndGameCountDown(hm.countdownLength));
                        }
                    }
                    else
                    {
                        StartCoroutine(hm.EndGameCountDown(hm.countdownLength));
                    }
                }
                if ((DataManager.instance.playerInfo[temp.playerID - 1].placeRace2 > previousPlace))
                {
                    DataManager.instance.playerInfo[temp.playerID - 1].placeRace2 = place;
                    DataManager.instance.playerInfo[temp.playerID - 1].timerRace2 = rm.time;
                    previousPlace++;
                    place++;


                    if (DataManager.instance.playerInfo[temp.playerID - 1].isActive)
                    {
                        humansFinish++;
                        hm.incrementHumansFinished();
                    }
                    if (humansFinish >= numHumans)
                    {
                        // give all AI that havent finshed yet a time
                        float previousTime = rm.time;
                        for (int i = 0; i < DataManager.instance.playerInfo.Length; i++)
                        {
                            //If they haven't finished the race yet
                            if (DataManager.instance.playerInfo[i].placeRace2 == 3 && DataManager.instance.playerInfo[i].timerRace2 == 0f)
                            {
                                previousTime = supplyTime(i, previousTime, false);
                                place++;
                            }
                        }
                        hm.EndGame();
                    }
                }
            }
        }
    }