private void buildDecoration(uint inIndex)
    {
        FlowerProperties flowerProperties = GameObject.Find("World").GetComponent <FlowerProperties>();

        /*
         * Decoration ID codes:
         * (all decorations should be negative and should never have an ID of 0)
         * (flower ids take up the entire positive range of longs (including 0))
         * 0 ... 9: Japanese style path, bench, fence, archway, and then some extra IDs for padding in case more need added
         * 10...19: Urban style path, bench, fence, archway...
         * 20...29: Suburban style- path, bench, fence, archway...
         * 30...99: Padding for other styles that might be added in the future
         * 100+... misc IDs
         */
        isFlower = false;

        //Destroy the flower or decoration before building a new one
        //Destroy the root destroys everything
        if (rootObject != null)
        {
            GameObject.Destroy(rootObject);
            rootObject = null;
        }
        rootObject = Instantiate(flowerProperties.getDecorationObject(inIndex), transform);
        //The root object is a prefab not meant for UI so it needs to be fixed up
        fixDecorationForUI(rootObject);
    }
예제 #2
0
 public GameObject getDecorationObjectFromIndex(uint index)
 {
     if (flowerProperties == null)
     {
         flowerProperties = GameObject.Find("World").GetComponent <FlowerProperties>();
     }
     return(flowerProperties.getDecorationObject(index));
 }
예제 #3
0
 //If there's a flower and mask to apply then see if the flower should be displayed
 private bool shouldDisplayFlower(uint id)
 {
     if (searchMask != 0)
     {
         return(FlowerProperties.compareFlowers(id, searchFlower, searchMask));
     }
     else
     {
         return(true);
     }
 }
예제 #4
0
    // Start is called before the first frame update
    void Start()
    {
        //Scale it by 100 to get the right size
        transform.localScale = new Vector3(100 * transform.localScale.x, 100 * transform.localScale.y, 100 * transform.localScale.z);
        rootObject           = transform.GetChild(0).gameObject;

        //Get the scale it's supposed to return to when done viewing
        returnScale = transform.localScale;

        //Get the properties object
        flowerProperties = GameObject.Find("World").GetComponent <FlowerProperties>();

        hideFlower();
    }
예제 #5
0
 // Start is called before the first frame update
 void Start()
 {
     rootObject       = transform.Find("meshItem").gameObject;
     rootImage        = transform.Find("colorImage").gameObject;
     questionMarkMesh = rootObject.GetComponent <MeshFilter>().sharedMesh;
     fp = GameObject.Find("World").GetComponent <FlowerProperties>();
     setCurrentItem(-1);
     if (Pe_St_Le_Pi < 4)
     {
         //disable image
         rootImage.SetActive(false);
     }
     else
     {
         fitModelToBounds();
     }
 }
    public void rebuildFlower()//William
    {
        GameObject flower = this.gameObject;

        FlowerObj        flowerObj  = this;
        GameObject       world      = GameObject.Find("World");
        FlowerProperties fp         = world.GetComponent <FlowerProperties>();
        GameObject       stemObject = transform.GetChild(0).gameObject;

        //Destroy the flower before building a new one
        //Destroy the stem that destroys everything
        if (stemObject != null)
        {
            GameObject.DestroyImmediate(stemObject);
        }
        try
        {
            //Instantiate the given stem object
            stemObject = Instantiate(fp.flowerStem[flowerObj.stemIndex[0]], flower.transform);
        }
        catch
        {
            //Instantiate the given stem object
            stemObject = Instantiate(fp.flowerStem[flowerObj.stemIndex[0]], flower.transform);
        }
        stemObject.layer = LayerMask.NameToLayer("Placeable");

        Material stemMat = fp.stemMaterial;

        stemObject.GetComponent <MeshRenderer>().material       = stemMat;
        stemObject.GetComponent <MeshRenderer>().material.color = fp.flowerColors[flowerObj.stemIndex[1]];
        GameObject petalObject = null;
        //Add leaves and petal to the stem
        bool petalHasBeenFound = false;

        foreach (Transform child in stemObject.transform)
        {
            if (!petalHasBeenFound && child.gameObject.name.ToString().Equals("spetal"))
            {
                //It's the petal so it has been found
                petalHasBeenFound = true;
                //Now spawn it
                petalObject       = Instantiate(fp.flowerPetal[flowerObj.petalIndex[0]], child);
                petalObject.layer = LayerMask.NameToLayer("Placeable");
                Material petalMat = fp.petalMaterial;
                petalObject.GetComponent <MeshRenderer>().material       = petalMat;
                petalObject.GetComponent <MeshRenderer>().material.color = fp.flowerColors[flowerObj.petalIndex[1]];
            }
            else
            {
                //It's a leaf so spawn it
                GameObject leaf = Instantiate(fp.flowerLeaf[flowerObj.leafIndex[0]], child);
                leaf.layer = LayerMask.NameToLayer("Placeable");
                Material leafMat = fp.leafMaterial;
                leaf.GetComponent <MeshRenderer>().material       = leafMat;
                leaf.GetComponent <MeshRenderer>().material.color = fp.flowerColors[flowerObj.leafIndex[1]];
            }
        }
        //Add pistil to the petal
        GameObject pistilObject = Instantiate(fp.flowerPistil[flowerObj.pistilIndex[0]], petalObject.transform.GetChild(0));

        pistilObject.layer = LayerMask.NameToLayer("Placeable");
        Material pistilMat = fp.pistilMaterial;

        pistilObject.GetComponent <MeshRenderer>().material       = pistilMat;
        pistilObject.GetComponent <MeshRenderer>().material.color = fp.flowerColors[flowerObj.pistilIndex[1]];

        flower.name = flowerObj.flowerGridPos[0] + " " + flowerObj.flowerGridPos[1];
        world.GetComponent <WorldManager>().combineMeshes(flower.transform);
        world.GetComponent <WorldManager>().resizeBoxCollider(flower.gameObject);

        flower.layer = LayerMask.NameToLayer("Placeable");
    }
    //Builds a flower with the given index
    private void buildFlower(uint inIndex)
    {
        FlowerProperties flowerProperties = GameObject.Find("World").GetComponent <FlowerProperties>();

        //Set the indexes
        int stemIndex   = flowerProperties.getStemIndexFromIndex(inIndex);
        int petalIndex  = flowerProperties.getPetalIndexFromIndex(inIndex);
        int pistilIndex = flowerProperties.getPistilIndexFromIndex(inIndex);
        int leafIndex   = flowerProperties.getLeafIndexFromIndex(inIndex);

        //Set the colors
        int stemColor   = flowerProperties.getStemColorIndexFromIndex(inIndex);
        int leafColor   = flowerProperties.getLeafColorIndexFromIndex(inIndex);
        int petalColor  = flowerProperties.getPetalColorIndexFromIndex(inIndex);
        int pistilColor = flowerProperties.getPistilColorIndexFromIndex(inIndex);

        //Destroy the flower before building a new one
        //Destroy the stem that destroys everything
        if (rootObject != null)
        {
            GameObject.Destroy(rootObject);
            rootObject = null;
        }

        //Instantiate the given stem object
        rootObject       = Instantiate(flowerProperties.flowerStem[stemIndex], transform.GetChild(0));
        rootObject.layer = LayerMask.NameToLayer("UI");
        Material stemMat = flowerProperties.stemMaterial;

        rootObject.GetComponent <MeshRenderer>().material       = stemMat;
        rootObject.GetComponent <MeshRenderer>().material.color = flowerProperties.flowerColors[stemColor];

        //Add leaves and petal to the stem
        bool       petalHasBeenFound = false;
        GameObject petalObject       = null;

        foreach (Transform child in rootObject.transform)
        {
            if (!petalHasBeenFound && child.gameObject.name.ToString().Equals("spetal"))
            {
                //It's the petal so it has been found
                petalHasBeenFound = true;
                //Now spawn it
                petalObject       = Instantiate(flowerProperties.flowerPetal[petalIndex], child);
                petalObject.layer = LayerMask.NameToLayer("UI");
                //Color the material and apply it
                Material petalMat = flowerProperties.petalMaterial;
                petalObject.GetComponent <MeshRenderer>().material       = petalMat;
                petalObject.GetComponent <MeshRenderer>().material.color = flowerProperties.flowerColors[petalColor];;
            }
            else
            {
                //It's a leaf so spawn it
                GameObject leaf = Instantiate(flowerProperties.flowerLeaf[leafIndex], child);
                leaf.layer = LayerMask.NameToLayer("UI");
                //Color the material and apply it
                Material leafMat = flowerProperties.leafMaterial;
                leaf.GetComponent <MeshRenderer>().material       = leafMat;
                leaf.GetComponent <MeshRenderer>().material.color = flowerProperties.flowerColors[leafColor];
            }
        }

        if (petalObject != null)
        {
            //Add pistil to the petal
            GameObject pistilObject = Instantiate(flowerProperties.flowerPistil[pistilIndex], petalObject.transform.GetChild(0));
            pistilObject.layer = LayerMask.NameToLayer("UI");
            //Color the material and apply it
            Material pistilMat = flowerProperties.pistilMaterial;
            pistilObject.GetComponent <MeshRenderer>().material       = pistilMat;
            pistilObject.GetComponent <MeshRenderer>().material.color = flowerProperties.flowerColors[pistilColor];
        }

        //Now add the root object to the ui
        rootObject.transform.parent        = gameObject.transform.GetChild(0);
        rootObject.transform.localPosition = Vector3.zero;
        rootObject.transform.localScale    = Vector3.one * 80;

        //Give it a random rotation
        rootObject.transform.Rotate(0, Random.Range(0, 6.28f), 0);
    }
    private void fixDecorationForUI(GameObject decoration)
    {
        bool isAnimation;

        FlowerProperties flowerProperties = GameObject.Find("World").GetComponent <FlowerProperties>();
        //Pick out it's scale
        float itemScale = decoration.GetComponentInChildren <Placeable>().uiScale;

        //Make it part of the ui
        rootObject.layer = LayerMask.NameToLayer("UI");

        //Replace the shader so that it doesn't have the curvature
        Material oldMaterial;

        if (decoration.GetComponent <MeshRenderer>() != null)
        {
            oldMaterial = decoration.GetComponent <MeshRenderer>().material;
            isAnimation = false;
        }
        else
        {
            oldMaterial = decoration.GetComponentInChildren <SkinnedMeshRenderer>().material;
            //Check for flag or windmill
            if (rootObject.transform.Find("flagMesh") != null)
            {
                GameObject flagObject = rootObject.transform.Find("flagMesh").gameObject;
                flagObject.layer = LayerMask.NameToLayer("UI");
                flagObject.transform.localPosition = Vector3.zero;
                flagObject.transform.localRotation = Quaternion.identity;
            }
            else
            {
                GameObject windmillObject = rootObject.transform.Find("windmillBase").gameObject;
                windmillObject.layer = LayerMask.NameToLayer("UI");
                windmillObject.transform.localPosition = Vector3.zero;
                windmillObject.transform.localRotation = Quaternion.identity;
            }

            isAnimation = true;
        }
        oldMaterial.shader = flowerProperties.decorationUIShader;

        //Reset the transform
        decoration.transform.localPosition = Vector3.zero;
        decoration.transform.localRotation = Quaternion.identity;

        if (!isAnimation) //If it's not a flag
        {
            //Remove all children from the gameobject (for the bench to remove the prompt)
            while (decoration.transform.childCount > 0)
            {
                GameObject.DestroyImmediate(decoration.transform.GetChild(0).gameObject);
            }

            //Only need the MeshFilter, MeshRenderer, and Transform so remove everything else
            foreach (Component cc in decoration.GetComponents <Component>())
            {
                if (cc.GetType() != typeof(MeshFilter) && cc.GetType() != typeof(MeshRenderer) && cc.GetType() != typeof(Transform))
                {
                    Destroy(cc);
                }
            }
        }
        else //if it is a flag or a windmill
        {
            foreach (FlagDecorationController cc in decoration.GetComponents <FlagDecorationController>())
            {
                Destroy(cc);
            }

            foreach (windmillController cc in decoration.GetComponents <windmillController>())
            {
                Destroy(cc);
            }
        }

        //If it's a fence post then add another fence post and connect them
        if (decoration.name.Contains("post"))
        {
            //Get the fence connector
            string connectorStyle = "";
            if (decoration.name.Contains("Japanese"))
            {
                connectorStyle = "Japanese";
            }
            if (decoration.name.Contains("Urban"))
            {
                connectorStyle = "Urban";
            }
            if (decoration.name.Contains("Suburban"))
            {
                connectorStyle = "Suburban";
            }
            GameObject connectorPrefab = Resources.Load("Prefabs/Decorations/" + "connector" + connectorStyle + "Prefab") as GameObject;

            //Add another post
            if (connectorPrefab != null)
            {
                decoration.transform.localPosition = new Vector3(0, 0, .5f);
                GameObject otherPost = GameObject.Instantiate(decoration, decoration.transform);
                otherPost.transform.localPosition = new Vector3(0, 0, -1f);
                GameObject connectorInstance = GameObject.Instantiate(connectorPrefab, decoration.transform);
                connectorInstance.transform.localPosition = Vector3.zero;
                DestroyImmediate(connectorInstance.GetComponent <connectorController>());
                connectorInstance.GetComponent <MeshRenderer>().material.shader = flowerProperties.decorationUIShader;
                connectorInstance.layer = LayerMask.NameToLayer("UI");
            }
        }

        //Now add the root object to the ui
        rootObject.transform.parent        = gameObject.transform.GetChild(0);
        rootObject.transform.localPosition = Vector3.zero;
        rootObject.transform.localScale    = Vector3.one * (itemScale * 80);

        //Add exceptions for the grass
        if (decoration.GetComponent <Placeable>().id == 100)
        {
            //Set the grass ui shader
            oldMaterial.shader = flowerProperties.grassUIShader;
            //Scale it up by a bit
            decoration.transform.localScale = Vector3.one + Vector3.up * 10;
        }

        //Give it a random rotation
        rootObject.transform.Rotate(0, Random.Range(0, 6.28f), 0);

        if (!isAnimation)
        {
            rootObject.GetComponent <MeshRenderer>().material.renderQueue += 2;
        }
        else
        {
            rootObject.GetComponentInChildren <SkinnedMeshRenderer>().material.renderQueue += 2;
        }

        updateModelScale();
    }
예제 #9
0
    //Builds a flower with the given index for each element
    public void buildFlower(int inStem, int inLeaf, int inPetal, int inPistil)
    {
        if (flowerProperties == null)
        {
            flowerProperties = GameObject.Find("World").GetComponent <FlowerProperties>();
        }

        isFlower = true;
        //Set the indexes
        stemIndex   = inStem;
        petalIndex  = inPetal;
        pistilIndex = inPistil;
        leafIndex   = inLeaf;

        //Destroy the flower before building a new one
        //Destroy the stem that destroys everything
        if (rootObject != null)
        {
            GameObject.Destroy(rootObject);
            rootObject = null;
        }
        //Clear the leaves
        leafObjects.Clear();

        //Instantiate the given stem object
        rootObject       = Instantiate(getStemObjectFromIndex(inStem), transform);
        rootObject.layer = LayerMask.NameToLayer("UI");
        Material stemMat = flowerProperties.stemMaterial;

        rootObject.GetComponent <MeshRenderer>().material = stemMat;

        //Add leaves and petal to the stem
        bool petalHasBeenFound = false;

        foreach (Transform child in rootObject.transform)
        {
            if (!petalHasBeenFound && child.gameObject.name.ToString().Equals("spetal"))
            {
                //It's the petal so it has been found
                petalHasBeenFound = true;
                //Now spawn it
                petalObject       = Instantiate(getPetalObjectFromIndex(inPetal), child);
                petalObject.layer = LayerMask.NameToLayer("UI");
                Material petalMat = flowerProperties.petalMaterial;
                petalObject.GetComponent <MeshRenderer>().material = petalMat;
            }
            else
            {
                //It's a leaf so spawn it
                GameObject leaf = Instantiate(getLeafObjectFromIndex(inLeaf), child);
                leaf.layer = LayerMask.NameToLayer("UI");
                Material leafMat = flowerProperties.leafMaterial;
                leaf.GetComponent <MeshRenderer>().material = leafMat;
                leafObjects.Add(leaf);
            }
        }

        //Add pistil to the petal
        pistilObject       = Instantiate(getPistilObjectFromIndex(inPistil), petalObject.transform.GetChild(0));
        pistilObject.layer = LayerMask.NameToLayer("UI");
        Material pistilMat = flowerProperties.pistilMaterial;

        pistilObject.GetComponent <MeshRenderer>().material = pistilMat;
    }
예제 #10
0
    /// <summary>
    /// Syncs the player inventory with the flowers in the player inventory home base panel
    /// </summary>
    private void PlayerInventorySync()
    {
        FlowerProperties   fp  = GameObject.Find("World").GetComponent <FlowerProperties>();
        UIControllerScript uic = otherCanvas.GetComponent <UIControllerScript>();

        //Now fill the other canvas and the UI inventory with the right items
        //Loop through the entire inventory
        for (int ii = 0; ii < fpc.inventorySize; ii++)
        {
            MenuSlot  hInventoryItem      = playerInventoryContainer.GetChild(ii).GetComponent <MenuSlot>();
            Placeable slotPlaceable       = uic.getInventoryDataAtSlot(ii);
            uint      currentSlotID       = 0;
            bool      currentSlotIsFlower = false;
            if (slotPlaceable != null)
            {
                currentSlotID       = slotPlaceable.id;
                currentSlotIsFlower = slotPlaceable.isFlower;
            }

            //If there's an item in the home base player inventory
            if (hInventoryItem.getItem() != null)
            {
                uic.inventoryClearSlot(ii);

                GameObject newObj;
                //Create a placeable based on the slot's id
                if (hInventoryItem.getItem().isFlower)
                {
                    //Make a flower
                    newObj = Instantiate(Resources.Load("Prefabs/FlowerPrefab", typeof(GameObject)) as GameObject);
                    FlowerObj p = newObj.GetComponent <FlowerObj>();
                    p.id = hInventoryItem.getItem().id;

                    int[] petal = new int[2] {
                        fp.getPetalIndexFromIndex(p.id), fp.getPetalColorIndexFromIndex(p.id)
                    };
                    int[] pistil = new int[2] {
                        fp.getPistilIndexFromIndex(p.id), fp.getPistilColorIndexFromIndex(p.id)
                    };
                    int[] leaf = new int[2] {
                        fp.getLeafIndexFromIndex(p.id), fp.getLeafColorIndexFromIndex(p.id)
                    };
                    int[] stem = new int[2] {
                        fp.getStemIndexFromIndex(p.id), fp.getStemColorIndexFromIndex(p.id)
                    };
                    int[] position = new int[2] {
                        -1, -1
                    };

                    p.init(petal, stem, pistil, leaf, position, transform.root);
                    p.alive = true;

                    uic.setSlot(ii, p);
                    uic.setSlotCount(ii, hInventoryItem.getItem().count);
                    Destroy(newObj);
                }
                else
                {
                    //Make a decoration
                    newObj = Instantiate(fp.getDecorationObject(hInventoryItem.getItem().id));
                    Placeable p = newObj.GetComponent <Placeable>();
                    p.id            = hInventoryItem.getItem().id;
                    p.isFlower      = hInventoryItem.getItem().isFlower;
                    p.flowerGridPos = new int[2] {
                        -1, -1
                    };
                    uic.setSlot(ii, p);
                    uic.setSlotCount(ii, hInventoryItem.getItem().count);
                    Destroy(newObj);
                }
            }
            else //If there's not an item in the home base player inventory slot
            {
                //Check to see if the player has an item in the inventory slot
                if (uic.getInventoryDataAtSlot(ii) != null)
                {
                    //The player had an item in the slot but moved it to the home base
                    //So clear the slot
                    uic.inventoryClearSlot(ii);
                }
            }
        }
    }
    //Resets the element to the given index
    public void setIndex(MeshType inType, int inMeshIndex, int inColorIndex)
    {
        myType     = inType;
        meshIndex  = inMeshIndex;
        colorIndex = inColorIndex;

        Material   setMaterial;
        GameObject setObject;
        Color      setColor;
        float      scaleAmount; //How much to scale the mesh
        float      xRotation;   //How much rotation to apply to the mesh at the start
        float      yOffset;     //How far in the slot to offset the element (0 = 0, 1 is bottom of slot, -1 is top)


        //Be sure that there is a properties script
        if (propertiesScript == null)
        {
            propertiesScript = GameObject.Find("World").GetComponent <FlowerProperties>();
        }

        //Sets various values depending on the type
        switch (myType)
        {
        case MeshType.PISTIL:
            setMaterial = propertiesScript.pistilMaterial;
            setObject   = propertiesScript.flowerPistil[meshIndex];
            scaleAmount = 100;
            xRotation   = 15;
            yOffset     = .25f;
            break;

        case MeshType.PETAL:
            setMaterial = propertiesScript.petalMaterial;
            setObject   = propertiesScript.flowerPetal[meshIndex];
            scaleAmount = 120;
            xRotation   = 20;
            yOffset     = .25f;
            break;

        case MeshType.LEAF:
            setMaterial = propertiesScript.petalMaterial;
            setObject   = propertiesScript.flowerLeaf[meshIndex];
            scaleAmount = 100;
            xRotation   = 15;
            yOffset     = 0f;
            break;

        case MeshType.STEM:
            setMaterial = propertiesScript.stemMaterial;
            setObject   = propertiesScript.flowerStem[meshIndex];
            scaleAmount = 200;
            xRotation   = 5;
            yOffset     = 1f;
            break;

        default:
            setMaterial = propertiesScript.stemMaterial;
            setObject   = propertiesScript.flowerStem[meshIndex];
            scaleAmount = 200;
            xRotation   = 5;
            yOffset     = .5f;
            break;
        }

        //What color to set the flower part
        setColor = propertiesScript.flowerColors[colorIndex];

        if (flowerPartObject == null) //If the part hasn't been created yet
        {
            //Instantiate a flower part
            flowerPartObject = Instantiate(setObject, gameObject.transform);

            //Compute the size of the flower part model
            float meshHeight = flowerPartObject.GetComponent <MeshFilter>().mesh.bounds.size.y * 2;
            float meshWidth  =
                Mathf.Max((flowerPartObject.GetComponent <MeshFilter>().mesh.bounds.size.x * 2),
                          (flowerPartObject.GetComponent <MeshFilter>().mesh.bounds.size.z * 2));

            //Scale it and rotate it to make it easier to see
            flowerPartObject.transform.localScale = Vector3.one * (1 / (Mathf.Max(meshHeight, meshWidth)));
            flowerPartObject.transform.RotateAround(transform.position, transform.right, xRotation);

            //Set the material, color, and layer
            flowerPartObject.GetComponent <MeshRenderer>().sharedMaterial = setMaterial;
            flowerPartObject.GetComponent <MeshRenderer>().material.color = setColor;
            flowerPartObject.layer = LayerMask.NameToLayer("UI");

            //Scale it depending on the given amount (from the switch statement)
            flowerPartObject.transform.localScale = flowerPartObject.transform.localScale * scaleAmount;

            //Compute the y offset depending on the mesh size
            if (meshWidth > meshHeight)
            {
                yOffset *= meshHeight / meshWidth;
            }
            //Move the model depending on the computed offset
            flowerPartObject.transform.Translate(-Vector3.up * yOffset, Space.Self);

            //Leaves have a unique origin so move then so that they'll spin from the middle of the geometry
            if (myType == MeshType.LEAF)
            {
                flowerPartObject.transform.Translate(Vector3.right * .5f, Space.Self);
            }
        }
        else
        {
            //Destroy the object first
            GameObject.Destroy(flowerPartObject);

            //Instantiate a new flower part
            flowerPartObject = Instantiate(setObject, gameObject.transform);

            //Compute the size of the flower part model
            float meshHeight = flowerPartObject.GetComponent <MeshFilter>().mesh.bounds.size.y * 2;
            float meshWidth  =
                Mathf.Max((flowerPartObject.GetComponent <MeshFilter>().mesh.bounds.size.x * 2),
                          (flowerPartObject.GetComponent <MeshFilter>().mesh.bounds.size.z * 2));

            //Scale it and rotate it to make it easier to see
            flowerPartObject.transform.localScale = Vector3.one * (1 / (Mathf.Max(meshHeight, meshWidth)));
            flowerPartObject.transform.RotateAround(transform.position, transform.right, xRotation);

            //Set the material, color, and layer
            flowerPartObject.GetComponent <MeshRenderer>().sharedMaterial = setMaterial;
            flowerPartObject.GetComponent <MeshRenderer>().material.color = setColor;
            flowerPartObject.layer = LayerMask.NameToLayer("UI");

            //Scale it depending on the given amount (from the switch statement)
            flowerPartObject.transform.localScale = flowerPartObject.transform.localScale * scaleAmount;

            //Compute the y offset depending on the mesh size
            if (meshWidth > meshHeight)
            {
                yOffset *= meshHeight / meshWidth;
            }
            //Move the model depending on the computed offset
            flowerPartObject.transform.Translate(-Vector3.up * yOffset, Space.Self);

            //Leaves have a unique origin so move then so that they'll spin from the middle of the geometry
            if (myType == MeshType.LEAF)
            {
                flowerPartObject.transform.Translate(Vector3.right * .5f, Space.Self);
            }
        }
    }
 //Find the flower properties script
 public void Start()
 {
     propertiesScript = GameObject.Find("World").GetComponent <FlowerProperties>();
 }