Ejemplo n.º 1
0
        /// <summary>
        /// Instantiates bots using the config file param values. It defaults some uninitialized values using the player's coords
        /// </summary>
        /// <param name="config">The config file to be used</param>
        public IEnumerator InstantiateBotsAtCoords(CoordsInstantiationConfig config)
        {
            if (config.xCoord == EnvironmentSettings.UNINITIALIZED_FLOAT)
            {
                Log($"X Coordinate value wasn't provided... using player's current scene base X coordinate.");
                config.xCoord = Mathf.Floor(DCLCharacterController.i.characterPosition.worldPosition.x / ParcelSettings.PARCEL_SIZE);
            }

            if (config.yCoord == EnvironmentSettings.UNINITIALIZED_FLOAT)
            {
                Log($"Y Coordinate value wasn't provided... using player's current scene base Y coordinate.");
                config.yCoord = Mathf.Floor(DCLCharacterController.i.characterPosition.worldPosition.z / ParcelSettings.PARCEL_SIZE);
            }

            var worldPosConfig = new WorldPosInstantiationConfig()
            {
                amount    = config.amount,
                xPos      = config.xCoord * ParcelSettings.PARCEL_SIZE,
                yPos      = DCLCharacterController.i.characterPosition.unityPosition.y - DCLCharacterController.i.characterController.height / 2,
                zPos      = config.yCoord * ParcelSettings.PARCEL_SIZE,
                areaWidth = config.areaWidth,
                areaDepth = config.areaDepth
            };

            Log($"Instantiating {config.amount} randomized avatars inside a {config.areaWidth}x{config.areaDepth} area positioned at ({config.xCoord}, {config.yCoord}) coords...");

            yield return(InstantiateBotsAtWorldPos(worldPosConfig));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Instantiates bots using the config file param values. It defaults some uninitialized values using the player's position
        /// </summary>
        /// <param name="config">The config file to be used</param>
        public IEnumerator InstantiateBotsAtWorldPos(WorldPosInstantiationConfig config)
        {
            yield return(EnsureGlobalSceneAndCatalog());

            if (config.xPos == EnvironmentSettings.UNINITIALIZED_FLOAT)
            {
                Log($"X Position value wasn't provided... using player's current X Position.");
                config.xPos = DCLCharacterController.i.characterPosition.unityPosition.x;
            }

            if (config.yPos == EnvironmentSettings.UNINITIALIZED_FLOAT)
            {
                Log($"Y Position value wasn't provided... using player's current Y Position.");
                config.yPos = DCLCharacterController.i.characterPosition.unityPosition.y;
            }

            if (config.zPos == EnvironmentSettings.UNINITIALIZED_FLOAT)
            {
                Log($"Z Position value wasn't provided... using player's current Z Position.");
                config.zPos = DCLCharacterController.i.characterPosition.unityPosition.z;
            }

            Log($"Instantiating {config.amount} randomized avatars inside a {config.areaWidth}x{config.areaDepth} area positioned at ({config.xPos}, {config.yPos}, {config.zPos})...");

            Vector3 randomizedAreaPosition = new Vector3();

            for (int i = 0; i < config.amount; i++)
            {
                randomizedAreaPosition.Set(Random.Range(config.xPos, config.xPos + config.areaWidth), config.yPos, Random.Range(config.zPos, config.zPos + config.areaDepth));
                InstantiateBot(randomizedAreaPosition);
            }

            Log($"Finished instantiating {config.amount} avatars. They may take some time to appear while their wearables are being loaded.");
        }
Ejemplo n.º 3
0
        public void InstantiateBotsAtWorldPos(string configJson)
        {
            var config = new DCL.Bots.WorldPosInstantiationConfig();

            JsonUtility.FromJsonOverwrite(configJson, config);

            CoroutineStarter.Start(botsController.InstantiateBotsAtWorldPos(config));
        }