예제 #1
0
        public void LoadScenario(String level, String scenarioFile)
        {
            //string path = "AssetData/Models/";

            string sceData = "AssetData/Levels/" + level + "/Scenario/" + scenarioFile + ".sce";

            List <string> tex = new List <string>();
            string        mdlName;

            if (File.Exists(sceData))
            {
                XDocument file;
                string    xmlText = File.ReadAllText(sceData);
                file = XDocument.Parse(xmlText);

                //Console.WriteLine(xmlText);

                string scenarioName = file.Root.Attribute("name").Value;

                foreach (XElement e in file.Descendants("objective"))
                {
                    Objective objective = new Objective();

                    Objective.ObjectiveType objectiveType = (Objective.ObjectiveType)Enum.Parse(typeof(Objective.ObjectiveType), e.Attribute("type").Value);

                    string str = e.Attribute("string").Value;

                    Console.WriteLine(objectiveType.ToString());

                    if (objectiveType == Objective.ObjectiveType.Elimination)
                    {
                        foreach (XElement t in e.Descendants("target"))
                        {
                            float x = Int32.Parse(t.Attribute("x").Value);
                            float y = Int32.Parse(t.Attribute("y").Value);
                            float z = Int32.Parse(t.Attribute("z").Value);

                            Type targetType = Type.GetType(t.Attribute("type").Value);

                            objective.SetObjective(str, targetType, x, y, z);
                        }

                        foreach (XElement t in e.Descendants("enemyspawn"))
                        {
                            float x = float.Parse(t.Attribute("x").Value);
                            float y = float.Parse(t.Attribute("y").Value);

                            int amount = Int32.Parse(t.Attribute("amount").Value);

                            //Type targetType = Type.GetType(t.Attribute("type").Value);

                            objective.CreateEnemySpawner(typeof(CPlayerBullet), amount, x, y);
                        }
                    }
                    else if (objectiveType == Objective.ObjectiveType.Reach)
                    {
                        foreach (XElement t in e.Descendants("checkpoint"))
                        {
                            float x = Int32.Parse(t.Attribute("x").Value);
                            float y = Int32.Parse(t.Attribute("y").Value);

                            objective.SetObjective(str, x, y);
                        }

                        foreach (XElement t in e.Descendants("enemyspawn"))
                        {
                            float x = float.Parse(t.Attribute("x").Value);
                            float y = float.Parse(t.Attribute("y").Value);

                            int amount = Int32.Parse(t.Attribute("amount").Value);

                            //Type targetType = Type.GetType(t.Attribute("type").Value);

                            objective.CreateEnemySpawner(typeof(CPlayerBullet), amount, x, y);
                        }
                    }
                    else if (objectiveType == Objective.ObjectiveType.Survival)
                    {
                        foreach (XElement t in e.Descendants("timer"))
                        {
                            int time = Int32.Parse(t.Attribute("time").Value);

                            objective.SetObjective(str, time);
                        }

                        foreach (XElement t in e.Descendants("enemyspawn"))
                        {
                            float x = float.Parse(t.Attribute("x").Value);
                            float y = float.Parse(t.Attribute("y").Value);

                            int amount = Int32.Parse(t.Attribute("amount").Value);

                            //Type targetType = Type.GetType(t.Attribute("type").Value);

                            objective.CreateEnemySpawner(typeof(CPlayerBullet), amount, x, y);
                        }
                    }
                    else if (objectiveType == Objective.ObjectiveType.Event)
                    {
                        foreach (XElement t in e.Descendants("bubble"))
                        {
                            List <string> dialog    = new List <string>();
                            List <string> subtitles = new List <string>();

                            foreach (XElement l in t.Descendants("line"))
                            {
                                dialog.Add(l.Attribute("soundbyte").Value);
                                subtitles.Add(l.Value);
                            }

                            objective.SetObjective(str, dialog, subtitles);
                        }
                    }

                    pObjectiveList.Add(objective);
                }

                foreach (XElement e in file.Descendants("model"))
                {
                    mdlName = e.Attribute("name").Value;
                    string type = e.Attribute("filetype").Value;
                }

                foreach (XElement e in file.Descendants("animation"))
                {
                    string name = e.Attribute("name").Value;

                    tex.Add(name);

                    Console.WriteLine("texture " + name);
                }
            }
            else
            {
                CConsole.Instance.Print("Scenario data for " + sceData + " wasn't found!");
            }
        }
예제 #2
0
 private void RemoveObjective(Objective objective)
 {
     pObjectiveList.Remove(objective);
 }