void SpawnObstacle(Vector3 position, Vector3 direction)
    {
        GameObject instance = GameObject.Instantiate(GetRandomPrefab(), position, Quaternion.identity) as GameObject;
        Obstacle obstacle = instance.GetComponentInChildren<Obstacle>();
        obstacle.Init();

        _obstacles.Add(obstacle);
        _obstaclesData[_numObstacles++] = new GrassEngine.ObstacleData(){ Position = position, Radius = obstacle.GetRadius(), ExpansiveForce = 0f };

        obstacle.Play(direction * Random.Range(_spawnObsacleForceMin, _spawnObsacleForceMax));
    }
Esempio n. 2
0
    void SpawnObstacle(Vector3 position, Vector3 direction)
    {
        GameObject instance = GameObject.Instantiate(GetRandomPrefab(), position, Quaternion.identity) as GameObject;
        Obstacle   obstacle = instance.GetComponentInChildren <Obstacle>();

        obstacle.Init();

        _obstacles.Add(obstacle);
        _obstaclesData[_numObstacles++] = new GrassEngine.ObstacleData()
        {
            Position = position, Radius = obstacle.GetRadius(), ExpansiveForce = 0f
        };

        obstacle.Play(direction * Random.Range(_spawnObsacleForceMin, _spawnObsacleForceMax));
    }