Exemple #1
0
    public BubbleController GenerateNewBubble(float _smallBubbleSpeed, float _bigBubbleSpeed)
    {
        bubbleNextId++;

        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Quad);

        go.name             = bubbleNextId.ToString();
        go.layer            = 8;
        go.transform.parent = bublesRoot.transform;
        GameObject.Destroy(go.GetComponent <MeshCollider>());
        go.AddComponent <SphereCollider>();

        Material newBubbleMat = new Material(baseMaterial);

        go.renderer.material = newBubbleMat;

        BubbleController controller = go.AddComponent <BubbleController>();

        float newBubbleSize  = GenerateSize();
        float newBubbleSpeed = GenerateSpeed(newBubbleSize, _smallBubbleSpeed, _bigBubbleSpeed);

        go.transform.position = GenerateInitPosition(newBubbleSize);
        controller.Setup(bubbleNextId, newBubbleSize, newBubbleSpeed, ResourceManager.GetRandomTextureFromSet());
        return(controller);
    }