Exemplo n.º 1
0
        public List<Node> populateNodes()
        {
            List<Node> tmpNodeList = new List<Node>();
            foreach (JSONObject n in nodes.list) //1st degree : list of nodes (only 1 element)
            {
                //Debug.Log(n.ToString());
                foreach (JSONObject poi in n.list[0].list) //3rd degree : list of pois
                {
                    //print(poi.ToString());
                    PointOfInterest p = new PointOfInterest((int)poi.list[0].n, (int)poi.list[3].n, (int)poi.list[4].n, (int)poi.list[5].n);

                    foreach (JSONObject b in poi.list[6].list)
                    {
                        //Debug.Log(b.ToString() + "\n");
                        iBeaconServer beacon = new iBeaconServer(poi.list[6].list[0].str, int.Parse(poi.list[6].list[1].str), int.Parse(poi.list[6].list[2].str));
                        p.setBeacon(beacon);
                    }
                    //foreach (JSONObject c in poi.list[7].list) //Media list
                    //{
                        //Debug.Log(c.ToString() + "\n");
                        /*foreach (JSONObject i in poi.list[8].list[0].list) // Image list
                        {
                            ExhibitionContent image = new Image(i.list[0].str, i.list[1].str, i.list[2].str);
                            p.addContent(image);
                            //Debug.Log(i.ToString() + "\n");
                        }*/
                        if (poi.list[7].list[1].list.Count > 0)
                        {
                            foreach (JSONObject v in poi.list[7].list[1].list) // Video list
                            {
                                string videoPath = v.list[0].str.Remove(0, 13);
                                //Remove extension type of the file
                                //print(videoPath);
                                Video video = new Video(videoPath, v.list[1].str, v.list[2].str);
                                p.addContent(video);
                                //Debug.Log(v.list[0].ToString() + "\n");
                            }
                        }

                        if (poi.list[7].list[2].list.Count > 0)
                        {
                            foreach (var a in poi.list[7].list[2].list) // Audio list
                            {
                                string audioPath = a.list[0].str.Remove(0, 13);
                                string mp3Path = audioPath.Remove(audioPath.Length - 4);
                                //print(mp3Path);
                                Audio audio = new Audio(mp3Path, a.list[1].str, a.list[2].str);
                                p.addContent(audio);
                            }
                        }
                    //}

                    for (int i = 0; i < poi.list[1].Count; i++) //Add all the poi description in the point of interest
                    {
                        string title = RemoveHtml.RemoveHtmlTags(poi.list[1].list[i].list[1].str);
                        string descr = RemoveHtml.RemoveHtmlTags(poi.list[2].list[i].list[1].str);
                        Description poiD = new Description(title, descr, poi.list[1].list[i].list[0].str);
                        p.addPoiDescription(poiD);
                    }

                    foreach (var sp in poi.list[8].list)
                    {
                        POS storyPoint = new POS((int)poi.list[0].n, (int)poi.list[3].n, (int)poi.list[4].n, (int)poi.list[5].n, (int)sp.list[1].n);

                        for (int i = 0; i < sp.list[2].Count; i++) // description and title JSON object
                        {
                            string title = RemoveHtml.RemoveHtmlTags(sp.list[2].list[i].list[1].str);
                            string descr = RemoveHtml.RemoveHtmlTags(sp.list[3].list[i].list[1].str);
                            Description spd = new Description(title, descr, sp.list[2].list[i].list[0].str);
                            storyPoint.addPoiDescription(spd);
                        }

                        //foreach (var c in sp.list[4].list) //storypoint content list
                        //{
                            /*foreach (var i in sp.list[4].list[0].list) //image list
                            {
                                if (i != null)
                                {
                                    ExhibitionContent image = new Image(i.list[0].str, i.list[2].str, i.list[1].str);
                                    storyPoint.addContent(image);
                                }
                            }*/

                            if (sp.list[4].list[1].list.Count > 0)
                            {
                                foreach (var v in sp.list[4].list[1].list) //video list
                                {
                                    string videoPath = v.list[0].str.Remove(0, 13);
                                    //Remove extension type of the file
                                    //print(videoPath);
                                    Video video = new Video(videoPath, v.list[1].str, v.list[2].str);
                                    storyPoint.addContent(video);
                                }
                            }

                            if (sp.list[4].list[2].list.Count > 0)
                            {
                                foreach (var a in sp.list[4].list[2].list) //audio list
                                {
                                    string audioPath = a.list[0].str.Remove(0, 13);
                                    string mp3Path = audioPath.Remove(audioPath.Length - 4);
                                    //print(mp3Path);
                                    Audio audio = new Audio(mp3Path, a.list[1].str, a.list[2].str);
                                    storyPoint.addContent(audio);
                                }
                            }
                        //}
                        tmpNodeList.Add(storyPoint);
                    }

                    tmpNodeList.Add(p);
                }//end of poi foreach

                foreach (JSONObject pot in n.list[1].list) //3rd degree : list of pot
                {
                    PointOfTransition pointOfTransition = new PointOfTransition((int)pot.list[0].n, (int)pot.list[2].n, (int)pot.list[3].n, (int)pot.list[4].n, pot.list[1].str);
                    tmpNodeList.Add(pointOfTransition);
                    //Debug.Log(pot.ToString() + "\n");
                }

            }//end of root foreach

            return tmpNodeList;
        }