Example #1
0
    void Start()
    {
        deathFX.SetActive(false);

        grindFX.SetActive(false);

        currLife = Life;

        lifeText.text = "Life: " + currLife + "/" + Life;

        jp = GetComponent <Jetpack>();
        im = GetComponent <Impactor>();
        pu = GetComponent <PickUp>();
        sw = GetComponent <soundWaveScript>();
        rn = GetComponentInChildren <Renderer>();
        rb = GetComponent <Rigidbody>();
        cl = GetComponent <Collider>();
    }
Example #2
0
    void ReadFile(string file)
    {
        filepath = file;

        using (XmlReader reader = XmlReader.Create(filepath))
        {
            GameObject temp;
            String     tempid;

            // print("name1 <" + reader.Name + "> <" + reader.NodeType + ">");

            Read(reader);
            chapterTitle = reader.GetAttribute("title");
            chapterId    = reader.GetAttribute("id");

            // Debug.Log("Begining read");
            int x = 0;
            while (reader.Name == "list" || Read(reader))
            {
                x++;
                //Debug.Log("XMLRead: Reading a list!! " + reader.GetAttribute("type"));
                if (x > 5)
                {
                    Debug.Log("broke");
                    break;
                }

                //print(getReaderState(reader) + " \"" + reader.GetAttribute("type") + "\"");
                if (reader.GetAttribute("type") == "evidence")
                {
                    while (Read(reader) && reader.Name == "evidence")
                    {
                        //Creates evidence gameobjects
                        tempid = reader.GetAttribute("id");
                        temp   = new GameObject("evidence");
                        temp.AddComponent <Evidence>();
                        temp.GetComponent <Evidence>().id       = tempid;
                        temp.GetComponent <Evidence>().filepath = reader.GetAttribute("filepath");
                        temp.GetComponent <Evidence>().text     = reader.GetAttribute("text");

                        objects.Add(tempid, temp);
                    }
                }
                else if (reader.GetAttribute("type") == "correlation")
                {
                    while (Read(reader) && reader.Name == "correlation")
                    {
                        // Debug.Log("Reading a correlation");
                        //Creates correlation gameobjects
                        tempid = reader.GetAttribute("id");
                        temp   = new GameObject("correlation");
                        temp.AddComponent <Correlation>();
                        temp.GetComponent <Correlation>().id        = tempid;
                        temp.GetComponent <Correlation>().evidence0 = reader.GetAttribute("ev0");
                        temp.GetComponent <Correlation>().evidence1 = reader.GetAttribute("ev1");
                        objects.Add(tempid, temp);
                        validCorrelations.Add(temp.GetComponent <Correlation>());
                    }
                }
                else if (reader.GetAttribute("type") == "decision")
                {
                    Read(reader);
                    while (reader.Name == "decision")
                    {
                        // print("0 " + getReaderState(reader));
                        // Debug.Log("Reading a decision");
                        //Creates decision gameobjects
                        tempid = reader.GetAttribute("id");
                        temp   = new GameObject("decision");
                        temp.AddComponent <Decision>();
                        temp.GetComponent <Decision>().id              = tempid;
                        temp.GetComponent <Decision>().text            = reader.GetAttribute("text");
                        temp.GetComponent <Decision>().decisionOptions = new List <GameObject>();
                        decisions.Add(temp.GetComponent <Decision>());

                        // print("1 " + getReaderState(reader));
                        DecisionOption lastOption = null;
                        while (Read(reader) && (reader.Name == "decisionOption" || reader.Name == "requirements" || reader.Name == "impact" || reader.Name == "impactor"))
                        {
                            if (reader.Name == "decisionOption")
                            {
                                //Creates decisionOption gameobjects
                                GameObject decisionOption = new GameObject("decisionOption");
                                decisionOption.AddComponent <DecisionOption>();
                                decisionOption.GetComponent <DecisionOption>().parentId = temp.GetComponent <Decision>().id;
                                decisionOption.GetComponent <DecisionOption>().id       = reader.GetAttribute("id");
                                decisionOption.GetComponent <DecisionOption>().text     = reader.GetAttribute("text");
                                //decisionOption.AddComponent<Requirements>();

                                decisionOption.transform.parent = temp.transform;
                                lastOption = decisionOption.GetComponent <DecisionOption>();

                                temp.GetComponent <Decision>().decisionOptions.Add(decisionOption);
                            }
                            else if (reader.Name == "requirements")
                            {
                                lastOption.requirements = ReadRequirements(reader);
                            }
                            else if (reader.Name == "impactor")
                            {
                                Impactor imp = new Impactor();
                                imp.requiredId = reader.GetAttribute("requiredId");
                                imp.multiplier = int.Parse(reader.GetAttribute("multiplier"));
                                imp.applicants.AddRange(Regex.Split(reader.GetAttribute("applicants"), ", "));
                                lastOption.impactors.Add(imp);
                            }
                            else if (reader.Name == "impact")
                            {
                                Impact imp = new Impact();
                                imp.magnitude = int.Parse(reader.GetAttribute("magnitude"));
                                imp.applicant = reader.GetAttribute("applicant");
                                lastOption.impacts.Add(imp);
                            }
                        }
                        objects.Add(tempid, temp);
                        //print("2 " + getReaderState(reader));
                    }
                }
                else if (reader.GetAttribute("type") == "phase")
                {
                    while (Read(reader) && reader.Name == "phase")
                    {
                        temp = new GameObject("phase");
                        temp.AddComponent <Phase>();
                        temp.GetComponent <Phase>().id   = reader.GetAttribute("id");
                        temp.GetComponent <Phase>().type = reader.GetAttribute("type");

                        if (temp.GetComponent <Phase>().type == "evidence")
                        {
                            ReadEvidencePhase(reader, temp);
                        }

                        phases.Add(temp.GetComponent <Phase>());
                    }
                }
                else
                {
                    Read(reader);
                }
            }
        }
    }