Ejemplo n.º 1
0
    public IEnumerator TrackHype()
    {
        while (true)
        {
            if (_currentTime > 0)
            {
                _currentTime--;
                UpdateDisplays();
                yield return(new WaitForSeconds(1));
            }
            else if (_currentTime <= 0)
            {
                OpenArena();
                AudioManager.instance.PlayWithoutSpatial("ArenaCleared");
                FinishDisplays();
                _aggroSphere.SetActive(false);
                eventPanel.SetActive(true);
                arenaEndText.SetActive(true);

                eventPanel.SetActive(true);
                arenaEndText.SetActive(true);

                Invoke("DisableEvents", 3);

                _raceManager.time    = 0;
                _raceManager.inArena = false;

                //StopCoroutine(TrackHype());
                StopAllCoroutines();
                isActivated = false;

                foreach (RaycastCar i in _raceManager.cars)
                {
                    i.inArena = false;
                    i.activeSpline++;
                    if (!i.GetComponent <VehicleInput>())
                    {
                        i.GetComponent <AICheats>().startCheating();
                        aiMan.updateAI(i.GetComponent <AIBehaviour>());
                    }
                }
                yield return(null);
            }
            yield return(null);
        }
    }
Ejemplo n.º 2
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>());
        }
    }