Example #1
0
    private IEnumerator RoundStarting()
    {
        // Increment the round number and display text showing the players what round it is.
        roundNumber++;
        gameText.text = "RIDE " + roundNumber;

        if (baseCost.Length > (roundNumber - 1))
        {
            costTotal = baseCost[roundNumber - 1];
        }
        updateMoneyText();

        driver.SetActive(driverVisible);


        timer.pauseTimer();
        timer.setTimer(baseTime[roundNumber - 1]);

        // redefine path for new round (to resolve path change in pickup passanger)
        playCon.Pathing(roundNumber - 1);

        // Set player to go to selected start-end nodes
        playerCar.TP2Start();
        playerCar.currentNode = 0;


        yield return(startWait);
    }
    /// <summary>
    /// Sets up the next round
    /// </summary>
    /// <returns></returns>
    private IEnumerator RoundStarting()
    {
        // Increment the round number and display text showing the players what round it is.
        roundNumber++;
        gameText.text = "RIDE " + roundNumber;

        if (baseCost.Length > (roundNumber - 1))
        {
            costTotal = baseCost[roundNumber - 1];
        }
        updateMoneyText();

        driver.SetActive(driverVisible);


        timer.pauseTimer();
        timer.setTimer(0);

        // redefine path for new round (to resolve path change in pickup passanger)
        playCon.Pathing(roundNumber - 1);

        // Set player to go to selected start-end nodes
        playerCar.TP2Start();
        playerCar.currentNode = 0;

        // Reset all AI cars
        AVController AICarAV;

        AICarsObject = GameObject.Find("AICars");
        for (int i = 0; i < AICarsObject.transform.childCount; i++)
        {
            AICarAV = AICarsObject.transform.GetChild(i).gameObject.transform.GetChild(0).GetComponent <AVController>();
            AICarAV.TP2Start();
        }

        yield return(startWait);
    }
    /// <summary>
    /// Sets the path for the car gameobject and places it in the world
    /// </summary>
    /// <param name="CarObject">GameObject representing the AI car</param>
    /// <param name="path">List of nodes for the car to travel to which form a path</param>
    /// <param name="dumbCarID">Integer identifying the car</param>
    /// <param name="smart">Boolean indicating whether the car is smart or not</param>
    private void setAICarParams(GameObject CarObject, List <string> path, int dumbCarID, bool smart)
    {
        // Make path from start to end
        GameObject PathGameObject = CarObject.transform.Find("Path").gameObject;

        if (!useCachedPath)
        {
            //Path thisPath = new Path() { nodeIDs = path };
            DumbCar thisCar = new DumbCar();
            thisCar.id = dumbCarID;
            //thisCar.path = path.ToArray();
            dumbCars.Add(thisCar); // NOTE: seems to add all cars whether they are dumb or not
            //paths.Add(thisPath);
        }

        makePath(PathGameObject, g, path);

        AVController av     = CarObject.GetComponentInChildren <AVController>();
        Vector3      offset = av.setOneWayRoads(path);

        av.setPath(path);
        av.isSmart = smart;

        // Set spawn
        GameObject SpawnObject      = CarObject.transform.Find("Spawn").gameObject;
        GameObject SpawnPointObject = SpawnObject.transform.Find("SpawnPoint").gameObject;

        Graph.Node startingNode = g.nodeIdNodeDict[path[0]];
        Vector2d   xy           = world.toXY(startingNode.lat, startingNode.lon);

        if (smart)
        {
            av.roundOver = false;
            av.TP2Start();
        }
        //SpawnPointObject.transform.position = new Vector3((float)xy[0], 0.71f, (float)xy[1]) + transform.InverseTransformPoint(offset);
    }