//The following functions are accessed from the PDA.
        public IEnumerator ShowAllServices()
        {
            GameObject serviceSliceContainer = dataManager.GetComponent <GlobalContainerHolder>().ServiceSliceContainer;
            GameObject dConnectionContainer  = dataManager.GetComponent <GlobalContainerHolder>().DownwardConnectionContainer;

            foreach (Transform child in serviceSliceContainer.transform)
            {
                ServiceSlice currentSlice = child.GetComponent <ServiceSlice>();
                foreach (Transform sliceObj in currentSlice.transform)
                {
                    foreach (Transform sliceObjChild in sliceObj.transform)
                    {
                        if (sliceObjChild.gameObject.tag != "Highlight" && sliceObjChild.gameObject.tag != "TextLabel")
                        {
                            sliceObjChild.gameObject.SetActive(true);
                        }
                    }
                    if (sliceObj.gameObject.tag != "Highlight" && sliceObj.gameObject.tag != "TextLabel")
                    {
                        sliceObj.gameObject.SetActive(true);
                    }
                }
                yield return(null);
            }

            foreach (Transform child in dConnectionContainer.transform)
            {
                child.gameObject.SetActive(true);
            }
        }
        private Dictionary <ServiceSlice, List <Service> > distributeServicesToSlices(List <Service> services)
        {
            Dictionary <ServiceSlice, List <Service> > result = new Dictionary <ServiceSlice, List <Service> >();

            int sliceNumber = services.Count / GlobalVar.groupsPerSlice;

            for (int i = 0; i < sliceNumber; i++)
            {
                GameObject serviceSlice = new GameObject("ServiceSlice");
                float      height       = GlobalVar.startingHeight + GlobalVar.heightStep * i;
                serviceSlice.transform.position = new Vector3(0f, height, 0f);
                serviceSlice.transform.SetParent(ServiceSliceContainer.transform);
                ServiceSlice sliceComponent = serviceSlice.AddComponent <ServiceSlice>();
                sliceComponent.height = height;

                List <Service> currentServiceList = new List <Service>();
                for (int s = 0; s < GlobalVar.groupsPerSlice; s++)
                {
                    int sIdx = GlobalVar.groupsPerSlice * i + s;
                    if (sIdx < services.Count)
                    {
                        currentServiceList.Add(services[sIdx]);
                    }
                }
                result.Add(sliceComponent, currentServiceList);
            }

            return(result);
        }
        private Dictionary <ServiceSlice, List <Service> > distributeServicesToSlices(List <Service> services)
        {
            Dictionary <ServiceSlice, List <Service> > result = new Dictionary <ServiceSlice, List <Service> >();

            int sliceNumber = services.Count / GROUPS_PER_SLICE;

            for (int i = 0; i < sliceNumber; i++)
            {
                GameObject serviceSlice = new GameObject("ServiceSlice");
                float      height       = STARTING_HEIGHT + HEIGHT_STEP * i;
                serviceSlice.transform.position = new Vector3(0f, height, 0f);
                serviceSlice.transform.SetParent(ServiceSliceContainer.transform);
                ServiceSlice sliceComponent = serviceSlice.AddComponent <ServiceSlice>();
                sliceComponent.height = height;

                List <Service> currentServiceList = new List <Service>();
                for (int s = 0; s < GROUPS_PER_SLICE; s++)
                {
                    int sIdx = GROUPS_PER_SLICE * i + s;
                    if (sIdx < services.Count)
                    {
                        currentServiceList.Add(services[sIdx]);
                    }
                }
                result.Add(sliceComponent, currentServiceList);
            }

            return(result);
        }
        public IEnumerator HideAllServices()
        {
            GameObject serviceSliceContainer = dataManager.GetComponent <GlobalContainerHolder>().ServiceSliceContainer;
            GameObject dConnectionContainer  = dataManager.GetComponent <GlobalContainerHolder>().DownwardConnectionContainer;

            foreach (Transform child in dConnectionContainer.transform)
            {
                child.gameObject.SetActive(false);
            }

            foreach (Transform child in serviceSliceContainer.transform)
            {
                ServiceSlice currentSlice = child.GetComponent <ServiceSlice>();
                foreach (Transform sliceObj in currentSlice.transform)
                {
                    foreach (Transform sliceObjChild in sliceObj.transform)
                    {
                        sliceObjChild.gameObject.SetActive(false);
                    }
                    sliceObj.gameObject.SetActive(false);
                }
                yield return(null);
            }
        }
        private void constructServicesAndComponents(List <Service> services, ServiceSlice serviceSlice)
        {
            foreach (Service service in services)
            {
                CompilationUnit serviceCU = service.getServiceCU();
                if (serviceCU != null && serviceCU.getGameObject() != null)
                {
                    GameObject serviceGO = Instantiate(interfacePrefab, transform.position, Quaternion.identity);
                    serviceGO.layer = LayerMask.NameToLayer("InteractionSystemLayer");
                    serviceGO.name  = service.getName();
                    Vector3 cuPosition = serviceCU.getGameObject().transform.position;
                    cuPosition.y = 0f;
                    serviceGO.transform.position   = cuPosition + new Vector3(0f, serviceSlice.height, 0f);
                    serviceGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize);
                    serviceGO.transform.SetParent(serviceSlice.transform);
                    ServiceNodeScript sns = serviceGO.AddComponent <ServiceNodeScript>();
                    serviceGO.AddComponent <TextLabelComponent>();
                    ServiceLayerGO slGO = serviceCU.getGameObject().GetComponent <ServiceLayerGO>();
                    slGO.addServiceNode(sns);
                    #region construct ServiceComponents
                    List <ServiceComponent> implementingComponents = service.getImplementingComponents();
                    List <ServiceComponent> referencingComponents  = service.getReferencingComponents();
                    foreach (ServiceComponent sc in implementingComponents)
                    {
                        CompilationUnit componentCU = sc.getImplementationCU();
                        GameObject      scGO        = Instantiate(implementationPrefab, transform.position, Quaternion.identity);
                        scGO.layer                = LayerMask.NameToLayer("InteractionSystemLayer");
                        scGO.name                 = sc.getName();
                        cuPosition                = componentCU.getGameObject().transform.position;
                        cuPosition.y              = 0f;
                        scGO.transform.position   = cuPosition + new Vector3(0f, serviceSlice.height, 0f);
                        scGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize);
                        scGO.transform.SetParent(serviceSlice.transform);
                        ServiceNodeScript scGOcomponent = scGO.AddComponent <ServiceNodeScript>();
                        scGO.AddComponent <TextLabelComponent>();
                        scGOcomponent.addConnectedServiceNode(sns);
                        sns.addConnectedServiceNode(scGOcomponent);
                        scGOcomponent.disableServiceNode();
                        ServiceLayerGO sl = componentCU.getGameObject().GetComponent <ServiceLayerGO>();
                        sl.addServiceNode(scGOcomponent);
                    }
                    foreach (ServiceComponent sc in referencingComponents)
                    {
                        CompilationUnit componentCU = sc.getImplementationCU();
                        GameObject      scGO        = Instantiate(referencePrefab, transform.position, Quaternion.identity);
                        scGO.layer                = LayerMask.NameToLayer("InteractionSystemLayer");
                        scGO.name                 = sc.getName();
                        cuPosition                = componentCU.getGameObject().transform.position;
                        cuPosition.y              = 0f;
                        scGO.transform.position   = cuPosition + new Vector3(0f, serviceSlice.height, 0f);
                        scGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize);
                        scGO.transform.SetParent(serviceSlice.transform);
                        ServiceNodeScript scGOcomponent = scGO.AddComponent <ServiceNodeScript>();
                        scGO.AddComponent <TextLabelComponent>();
                        scGOcomponent.addConnectedServiceNode(sns);
                        sns.addConnectedServiceNode(scGOcomponent);

                        scGOcomponent.disableServiceNode();
                        ServiceLayerGO sl = componentCU.getGameObject().GetComponent <ServiceLayerGO>();
                        sl.addServiceNode(scGOcomponent);
                    }
                    #endregion
                    sns.disableServiceNode();
                }
            }
        }