private void ReadFlowers()
 {
     FlowerParent1 = first.plant.GetComponent <FlowerCreator>();
     FlowerParent2 = second.plant.GetComponent <FlowerCreator>();
     //FlowerParent1 = FlowerSlot1.GetComponent<BoxCollider>().gameObject.GetComponent<FlowerCreator>();
     //FlowerParent2 = FlowerSlot2.GetComponent<BoxCollider>().gameObject.GetComponent<FlowerCreator>();
     //FlowerParent1 = FlowerSlot1.GetComponentInChildren<Stem>();
     //FlowerParent2 = FlowerSlot2.GetComponentInChildren<Stem>();
 }
예제 #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        FlowerCreator myTarget = (FlowerCreator)target;

        if (GUILayout.Button("Build Flower"))
        {
            if (firstBuild)
            {
                myTarget.ClearFlower();
            }
            else
            {
                firstBuild = true;
            }
            myTarget.BuildFlower(firstBuild);
        }

        //myTarget.experience = EditorGUILayout.IntField("Experience", myTarget.experience);
        //EditorGUILayout.LabelField("Level", myTarget);
    }
    private void MixFlowers()
    {
        int Choice1 = 0;
        int Choice2 = 0;

        FlowerResult = new GameObject().AddComponent <FlowerCreator>();

        if (Random.value > 0.5)
        {
            FlowerResult.flowerPF = FlowerParent1.flowerPF;
            Choice1 = 1;
        }
        else
        {
            FlowerResult.flowerPF = FlowerParent2.flowerPF;
            Choice1 = 2;
        }

        if (Choice1 == 1)
        {
            if (Random.value > 0.75)
            {
                FlowerResult.leavesPF = FlowerParent2.leavesPF;
                Choice2 = 1;
            }
            else
            {
                FlowerResult.leavesPF = FlowerParent1.leavesPF;
                Choice2 = 2;
            }
        }
        else if (Choice1 == 2)
        {
            if (Random.value > 0.25)
            {
                FlowerResult.leavesPF = FlowerParent1.leavesPF;
                Choice2 = 1;
            }
            else
            {
                FlowerResult.leavesPF = FlowerParent2.leavesPF;
                Choice2 = 2;
            }
        }

        if (Choice1 == 1 && Choice2 == 1)
        {
            FlowerResult.stemPF = FlowerParent2.stemPF;
        }
        else if (Choice1 == 2 && Choice2 == 2)
        {
            FlowerResult.stemPF = FlowerParent1.stemPF;
        }
        else
        {
            if (Random.value > 0.5)
            {
                FlowerResult.stemPF = FlowerParent1.stemPF;
            }
            else
            {
                FlowerResult.stemPF = FlowerParent2.stemPF;
            }
        }
    }