예제 #1
0
    /// <summary>
    /// Спавним ботов
    /// </summary>
    private void SpawBots()
    {
        int numberBot = 0;

        while (IsCanSpawnBot(numberBot))
        {
            if (pathsContainer.Paths.Count == 0)
            {
                return;
            }

            Transform startPoint   = CheckPosition();
            Transform transformBot = Instantiate(prefabBot, startPoint.position, startPoint.rotation, parentCar);
            string    nameDriver   = NameBot();
            transformBot.name = "Enemy_" + nameDriver;
            transformBot.GetComponent <DriverName>().Driver_Name = nameDriver;

            SpawnWaypointCircuit(nameDriver);
            WaypointProgressTracker newWaypointProgressTracker = transformBot.GetComponent <WaypointProgressTracker>();
            newWaypointProgressTracker.circuit = newWaypointCircuit;
            newWaypointProgressTracker.Reset();

            Color newBotColor = CheckColor();
            AddColorBot(newBotColor, transformBot);

            ViewName viewName = Instantiate(prefabUi, Vector3.one * 1000, Quaternion.identity, parentUi);
            viewName.name = "ViewName_" + nameDriver;
            viewName.Init(transformBot, newBotColor, nameDriver);

            numberBot++;
        }
    }
예제 #2
0
    /// <summary>
    /// Спавним игрока
    /// </summary>
    private void SpawPlayer()
    {
        Transform startPoint      = CheckPosition();
        Transform transformPlayer = Instantiate(prefabPlayer, startPoint.position, startPoint.rotation, parentCar);

        transformPlayer.name = "Player";
        transformPlayer.GetComponent <DriverName>().Driver_Name = ConstString.PLAYER_NAME;

        ViewName viewName = Instantiate(prefabUi, Vector3.one * 1000, Quaternion.identity, parentUi);

        viewName.name = "ViewName_" + ConstString.PLAYER_NAME;
        viewName.Init(transformPlayer, Color.white, ConstString.PLAYER_NAME);

        EventManager.CallSpawnPlayer(transformPlayer);
    }