Пример #1
0
        void RespawnCar(GameObject car)
        {
            CarInfo ai = car.GetComponent <CarInfo>();

            if (ai != null)
            {
                int nextPoint = NextCheckPoint(ai.LastPoint);
                ai.transform.position = pathPoints[ai.LastPoint] + new Vector3(0, 2, 0);
                ai.GetComponent <CarController>().Velocity = Vector3.zero;
                ai.GetComponent <CarController>().Speed    = 0;
                ai.transform.LookAt(GetCheckPointPos(nextPoint));
            }
        }
Пример #2
0
    public void AssignPlayers(int numberOfHumanPlayers)
    {
        List <GameObject> listOfCars = new List <GameObject>();

        listOfCars.AddRange(GameObject.FindGameObjectsWithTag("Player"));

        for (int i = 0; i < listOfCars.Count; i++)
        {
            Debug.Log(listOfCars[i].name);
        }

        for (int i = 0; i < numberOfHumanPlayers; i++)
        {
            CarInfo carInfo = ValidateThisCar(listOfCars[i]);

            HumanPlayer humanPlayerScriptableObject = ScriptableObject.CreateInstance <HumanPlayer>();
            humanPlayerScriptableObject.playerNumber = (i + 1);
            carInfo.carStats.playerType = humanPlayerScriptableObject;

            carInfo.GetComponent <InputManager>().enabled    = true;
            carInfo.GetComponent <ControllerSetup>().enabled = true;

            listOfCars[i].name = "Player " + (i + 1);
            ListOfHumanAssignedCars.Add(listOfCars[i]);

            Debug.Log(listOfCars[i].name + " assigned");
        }

        listOfCars.RemoveRange(0, numberOfHumanPlayers);

        for (int i = 0; i < listOfCars.Count; i++)
        {
            CarInfo carInfo = ValidateThisCar(listOfCars[i]);

            carInfo.carStats.playerType = ScriptableObject.CreateInstance <ComputerPlayer>();

            carInfo.GetComponent <AIPathControl>().enabled = true;

            listOfCars[i].name = "AI " + (i + 1);

            listOfCars[i].GetComponent <GameEventListener>().OnEventChanged(pickupDetectedAI);

            Debug.Log("AI assigned to: " + listOfCars[i].name);
        }
    }