예제 #1
0
    void GatherObjectData(KitchenComponent currentComp)
    {
        switch (currentComp.componentType)
        {
        case KitchenComponent.ComponentType.Accessory:

            foreach (Transform door in transform)
            {
                if (door.gameObject.CompareTag("Knobs"))
                {
                    knobs = door.gameObject;
                }
                else if (door.gameObject.CompareTag("Pulls"))
                {
                    pulls = door.gameObject;
                }
            }
            for (int i = 0; i < currentComp.materialList.Count; i++)
            {
                List <Material> newMats = currentComp.materialList[i].materialList;
                foreach (Material mat in newMats)
                {
                    accessoryMat.Add(mat);
                }
            }
            break;

        case KitchenComponent.ComponentType.Appliance:

            for (int i = 0; i < currentComp.materialList.Count; i++)
            {
                List <Material> newMats = currentComp.materialList[i].materialList;
                foreach (Material mat in newMats)
                {
                    applianceMat.Add(mat);
                }
            }

            foreach (Transform appliance in transform)
            {
                if (appliance.gameObject.CompareTag("ApplianceOpt"))
                {
                    applianceOptions.Add(appliance.gameObject);
                }
            }
            break;

        case KitchenComponent.ComponentType.Countertop:

            for (int i = 0; i < currentComp.materialList.Count; i++)
            {
                List <Material> newMats = currentComp.materialList[i].materialList;
                foreach (Material mat in newMats)
                {
                    counterMat.Add(mat);
                }
            }
            break;

        case KitchenComponent.ComponentType.Doors:


            foreach (Transform door in transform)
            {
                if (door.gameObject.CompareTag("Door"))
                {
                    doorOptions.Add(door.gameObject);
                }
            }

            if (woodMat.Count == 0)
            {
                for (int i = 0; i < currentComp.materialList.Count; i++)
                {
                    List <Material> newMats = currentComp.materialList[i].materialList;
                    foreach (Material mat in newMats)
                    {
                        woodMat.Add(mat);
                    }
                }
            }
            break;

        case KitchenComponent.ComponentType.Drawers:

            foreach (Transform drawer in transform)
            {
                if (drawer.gameObject.CompareTag("Drawer"))
                {
                    drawerOptions.Add(drawer.gameObject);
                }
            }

            if (woodMat.Count == 0)
            {
                for (int i = 0; i < currentComp.materialList.Count; i++)
                {
                    List <Material> newMats = currentComp.materialList[i].materialList;
                    foreach (Material mat in newMats)
                    {
                        woodMat.Add(mat);
                    }
                }
            }
            break;

        case KitchenComponent.ComponentType.Surface:
            for (int i = 0; i < currentComp.materialList.Count; i++)
            {
                List <Material> newMats = currentComp.materialList[i].materialList;
                foreach (Material mat in newMats)
                {
                    surfaceMat.Add(mat);
                }
            }
            break;

        default:
            Debug.Log("This wasn't assigned");
            break;
        }
    }
예제 #2
0
    private void ShowKitchenComponent(KitchenComponent component)
    {
        foreach (ComponentObject def in componentObjectDefinitions)
        {
            // this was a last minute addition when I realized sometimes more than one thing needs to be toggled on:
            // example: both "Add Knobs" and "Add Pulls" also need the row of metal options available
            if (def.additionalGameObjects.Length > 0)
            {
                foreach (GameObject GO in def.additionalGameObjects)
                {
                    GO.transform.parent.gameObject.SetActive(true);
                    GO.SetActive(true);
                    if (GO.CompareTag("Knobs"))
                    {
                        // set the toggle by whether or not the knobs are visible on this gameObject
                        if (camScript == null)
                        {
                            camScript = Camera.main.GetComponent <CameraController>();
                        }

                        GameObject currentGO = camScript.selectedObj.gameObject;
                        if (currentGO != null)
                        {
                            for (int i = 0; i < currentGO.transform.childCount; i++)
                            {
                                if (currentGO.transform.GetChild(i).gameObject.CompareTag("Knobs"))
                                {
                                    bool   active = currentGO.transform.GetChild(i).gameObject.activeInHierarchy;
                                    Toggle toggle = GO.GetComponent <Toggle>();
                                    if (toggle != null)
                                    {
                                        toggle.isOn = active;
                                    }
                                }
                            }
                        }
                    }
                    if (GO.CompareTag("Pulls"))
                    {
                        // set the toggle by whether or not the knobs are visible on this gameObject
                        if (camScript == null)
                        {
                            camScript = Camera.main.GetComponent <CameraController>();
                        }

                        GameObject currentGO = camScript.selectedObj.gameObject;
                        if (currentGO != null)
                        {
                            for (int i = 0; i < currentGO.transform.childCount; i++)
                            {
                                if (currentGO.transform.GetChild(i).gameObject.CompareTag("Pulls"))
                                {
                                    bool   active = currentGO.transform.GetChild(i).gameObject.activeInHierarchy;
                                    Toggle toggle = GO.GetComponent <Toggle>();
                                    if (toggle != null)
                                    {
                                        toggle.isOn = active;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (component == def.component)
            {
                def.gameObject.transform.parent.gameObject.SetActive(true);
                def.gameObject.SetActive(true);
                if (def.gameObject.CompareTag("Knobs"))
                {
                    // set the toggle by whether or not the knobs are visible on this gameObject
                    if (camScript == null)
                    {
                        camScript = Camera.main.GetComponent <CameraController>();
                    }

                    GameObject currentGO = camScript.selectedObj.gameObject;
                    if (currentGO != null)
                    {
                        for (int i = 0; i < currentGO.transform.childCount; i++)
                        {
                            if (currentGO.transform.GetChild(i).gameObject.CompareTag("Knobs"))
                            {
                                bool   active = currentGO.transform.GetChild(i).gameObject.activeInHierarchy;
                                Toggle toggle = def.gameObject.GetComponent <Toggle>();
                                if (toggle != null)
                                {
                                    toggle.isOn = active;
                                }
                            }
                        }
                    }
                }
                if (def.gameObject.CompareTag("Pulls"))
                {
                    // set the toggle by whether or not the knobs are visible on this gameObject
                    if (camScript == null)
                    {
                        camScript = Camera.main.GetComponent <CameraController>();
                    }

                    GameObject currentGO = camScript.selectedObj.gameObject;
                    if (currentGO != null)
                    {
                        for (int i = 0; i < currentGO.transform.childCount; i++)
                        {
                            if (currentGO.transform.GetChild(i).gameObject.CompareTag("Pulls"))
                            {
                                bool   active = currentGO.transform.GetChild(i).gameObject.activeInHierarchy;
                                Toggle toggle = def.gameObject.GetComponent <Toggle>();
                                if (toggle != null)
                                {
                                    toggle.isOn = active;
                                }
                            }
                        }
                    }
                }
            }
        }
    }