Beispiel #1
0
        public static ApplicationSkin FromXML(string filepath, ContentManager content)
        {
            ApplicationSkin skin = new ApplicationSkin();
            System.IO.Stream stream = new System.IO.FileStream(filepath, System.IO.FileMode.Open);
            XDocument xmlFile = XDocument.Load(System.Xml.XmlReader.Create(stream), LoadOptions.None);
            stream.Close();
            skin.content = content;
            XElement xmlSkin = xmlFile.Element("Skin");

            skin.sky = content.Load<Texture2D>("images\\sky04");

            XElement xmlTrack = xmlSkin.Element("Track");
            EngineModel trackModel = content.Load<Model>(xmlTrack.Element("Model").Value);
            if (xmlTrack.Element("X") != null)
                trackModel.X = float.Parse(xmlTrack.Element("X").Value);
            if (xmlTrack.Element("Y") != null)
                trackModel.Y = float.Parse(xmlTrack.Element("Y").Value);
            if (xmlTrack.Element("Z") != null)
                trackModel.Z = float.Parse(xmlTrack.Element("Z").Value);
            if (xmlTrack.Element("Scale") != null)
                trackModel.Scale = float.Parse(xmlTrack.Element("Scale").Value) * Vector3.One;
            //trackModel.Scale = new Vector3(0.005f, 0.33f, 0.05f);
            trackModel.RotationX += MathHelper.PiOver2;
            skin._track = trackModel;

            XElement xmlCollision = xmlSkin.Element("CollisionArea");
            /*PlanePrimitive plane = new PlanePrimitive(new Vector3(0, -10, trackModel.Y + 5),
                new Vector2(100, 10), Color.Purple);
            skin.cA = plane;*/
            EngineModel collisionModel = content.Load<Model>("models\\Individual tracks");
            //collisionModel.RotationY += MathHelper.PiOver2;
            collisionModel.SetTexture(0, content.Load<Texture2D>(@"models\notetex3"));
            collisionModel.Z = float.Parse(xmlCollision.Element("Z").Value);
            collisionModel.Y = trackModel.Y + 5;
            collisionModel.X = 100;
            collisionModel.RotationZ += MathHelper.PiOver2;
             collisionModel.Opacity = 50;
             collisionModel.Scale = new Vector3(0.5f);
            skin.collisionArea = collisionModel;
            /*
            EngineModel collisionModel = content.Load<Model>(xmlCollision.Element("Model").Value);
            collisionModel.Z = float.Parse(xmlCollision.Element("Z").Value);
            collisionModel.Y = trackModel.Y - 5;
            skin.collisionArea = collisionModel;*/

            skin.progressBar = ProgressBar.Load(xmlSkin.Element("ProgressBar"), content);

            foreach (InstrumentNote note in Enum.GetValues(typeof(InstrumentNote)))
            {
                XElement noteXML = xmlSkin.Element(Enum.GetName(typeof(InstrumentNote), note));
                skin.noteInfo.Add(note, new NoteModelInfo(noteXML.Element("Texture").Value,
                    float.Parse(noteXML.Element("X").Value)));
            }

            skin.trackEndZ = -50f;// float.Parse(xmlSkin.Element("CollisionArea").Element("Z").Value);
            skin.trackStartZ = -150f;

            skin.trackA = content.Load<Model>("models\\Individual tracks");
            skin.trackA.Position = new Vector3(-20, trackModel.Y - 30, skin.TrackEndZ - 25);//trackModel.Z - 100);
            skin.trackA.SetTexture(0, content.Load<Texture2D>(@"models\notetex2"));
            skin.trackA.ScaleX = .5f;

            skin.trackB = content.Load<Model>("models\\Individual tracks");
            skin.trackB.Position = new Vector3(-10, trackModel.Y - 30, skin.TrackEndZ - 25);//trackModel.Z - 100);
            skin.trackB.SetTexture(0, content.Load<Texture2D>(@"models\notetex3"));
            skin.trackB.ScaleX = .5f;

            skin.trackC = content.Load<Model>("models\\Individual tracks");
            skin.trackC.Position = new Vector3(0, trackModel.Y - 30, skin.TrackEndZ - 25);//trackModel.Z - 100);
            skin.trackC.SetTexture(0, content.Load<Texture2D>(@"models\notetex4"));
            skin.trackC.ScaleX = .5f;

            skin.trackD = content.Load<Model>("models\\Individual tracks");
            skin.trackD.Position = new Vector3(10, trackModel.Y - 30, skin.TrackEndZ - 25);//trackModel.Z - 100);
            skin.trackD.SetTexture(0, content.Load<Texture2D>(@"models\notetex5"));
            skin.trackD.ScaleX = .5f;

            skin.trackE = content.Load<Model>("models\\Individual tracks");
            skin.trackE.Position = new Vector3(20, trackModel.Y - 30, skin.TrackEndZ - 25);//trackModel.Z - 100);
            skin.trackE.SetTexture(0, content.Load<Texture2D>(@"models\notetex1"));
            skin.trackE.ScaleX = .5f;

            skin.ocarina = content.Load<Model>(xmlSkin.Element("Ocarina").Element("Model").Value);
            if (xmlSkin.Element("Ocarina").Element("Scale") != null)
                skin.ocarina.Scale = Vector3.One * float.Parse(xmlSkin.Element("Ocarina").Element("Scale").Value);
            skin.ocarina.Position = new Vector3(float.Parse(xmlSkin.Element("Ocarina").Element("X").Value),
                float.Parse(xmlSkin.Element("Ocarina").Element("Y").Value),
                float.Parse(xmlSkin.Element("Ocarina").Element("Z").Value));

            skin.noteBaseModel = xmlSkin.Element("NoteBase").Element("Model").Value;
            skin.noteBaseY = (xmlSkin.Element("NoteBase").Element("Y") != null ?
                float.Parse(xmlSkin.Element("NoteBase").Element("Y").Value) : 0);
            skin.noteBaseZ = (xmlSkin.Element("NoteBase").Element("Z") != null ?
                float.Parse(xmlSkin.Element("NoteBase").Element("Z").Value) : 0);
            skin.noteBaseScale = (xmlSkin.Element("NoteBase").Element("Scale") != null ?
                float.Parse(xmlSkin.Element("NoteBase").Element("Scale").Value) * Vector3.One : Vector3.One);

            skin._font = content.Load<SpriteFont>(xmlSkin.Element("Font").Value);
            skin.messageBoxFont = content.Load<SpriteFont>(xmlSkin.Element("Fonts").Element("MessageWindow").Value);

            skin.scoreFont = TextureFont.Load(xmlSkin.Element("ScoreFont"), content);
            skin.greenFont = TextureFont.Load(xmlSkin.Element("GreenFont"), content);

            return skin;
        }
Beispiel #2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            skin = ApplicationSkin.FromXML(Content.RootDirectory + "\\DefaultSkin.xml", Content);
            skin.GameTrack.RotationX -= MathHelper.Pi * 0.55f;
            skin.GameTrack.ScaleX = 2;

            songs = new List<BaseSong>();
            DirectoryInfo songbase = new DirectoryInfo(Content.RootDirectory + @"\songs\");
            foreach (FileInfo songfile in songbase.GetFiles())
                songs.Add(BaseSong.FromXML(songfile.FullName, Content, skin));
            FileInfo[] gamerProfileFiles = new DirectoryInfo(Content.RootDirectory + @"\gamers\").GetFiles("*.xml");
            gamers = new Gamer[gamerProfileFiles.Length];
            for (int index = 0; index < gamerProfileFiles.Length; index++)
                gamers[index] = Gamer.Load(gamerProfileFiles[index].FullName);

            //controller = OcarinaController.FromXNAKeyboard(PlayerIndex.One);
            controller = KeyboardController.FromXNAKeyboard(PlayerIndex.One);
            ReturnToSongSelectionScreen();
        }