public Level(XElement SourceNode, Object pPersistenceData) { isloaded = true; Debug.Print("cLevel XML constructor"); MusicName = SourceNode.GetAttributeString("MusicName", null); LevelName = SourceNode.GetAttributeString("LevelName", "Default"); Description = SourceNode.GetAttributeString("Description", "Default"); MaxBalls = SourceNode.GetAttributeInt("MaxBalls", -1); LevelNameIntroTextFillColor = SourceNode.ReadElement("LevelNameIntroTextFillColor", Color.Black); LevelNameIntroTextPenColor = SourceNode.ReadElement("LevelnameIntroTextPenColor", Color.DodgerBlue); _LevelNameIntroFont = SourceNode.ReadElement("LevelNameIntroFont", new Font(BCBlockGameState.GetMonospaceFont(), 18)); TallyMusicName = SourceNode.GetAttributeString("TallyMusic"); TallyTickSound = SourceNode.GetAttributeString("TallyTickSound"); TallyPicKey = SourceNode.GetAttributeString("TallyPicKey"); GameOverMusic = SourceNode.GetAttributeString("GameOverMusic"); GameOverPicKey = SourceNode.GetAttributeString("GameOverPicKey"); IntroMusicName = SourceNode.GetAttributeString("IntroMusicName"); NextLevel = SourceNode.GetAttributeInt("NextLevel", -1); ShowNameLength = SourceNode.ReadElement<TimeSpan>("ShowNameLength"); levelblocks = StandardHelper.ReadList<Block>(SourceNode.Element("Blocks"),pPersistenceData); levelballs = StandardHelper.ReadList<cBall>(SourceNode.Element("Balls"),pPersistenceData); NoPaddle = SourceNode.GetAttributeBool("NoPaddle", false); PauseSound = SourceNode.GetAttributeString("PauseSound"); StartTrigger = SourceNode.GetAttributeInt("StartTrigger"); DeathSound = SourceNode.GetAttributeString("DeathSound", "mmdeath"); try { _SidebarColorMatrixValues = (float[][]) SourceNode.ReadArray<float[]>("SideBarColorMatrix", null,pPersistenceData); } catch (InvalidCastException) { } SidebarImageKey = SourceNode.GetAttributeString("SidebarImageKey"); SidebarTextColor = SourceNode.ReadElement<Color>("SidebarTextColor"); PauseImageKey = SourceNode.GetAttributeString("PauseImageKey"); try { _PauseColorMatrixValues = (float[][]) SourceNode.ReadArray<float[]>("PauseColorMatrix", null,pPersistenceData); } catch (InvalidCastException) { } PauseTextColor = SourceNode.ReadElement<Color>("PauseTextColor"); PauseFont = SourceNode.ReadElement<Font>("PauseFont"); LevelEvents = SourceNode.ReadList<TriggerEvent>("LevelEvents", null); try { _AvailablePowerups = BCBlockGameState.StringToTypes(SourceNode.ReadList<String>("AvailablePowerups",null,pPersistenceData)).ToList(); } catch { _AvailablePowerups = GamePowerUp.GetPowerUpTypes().ToList(); } MessageData = SourceNode.ReadList<PlayMessageData>("MessageData",null,pPersistenceData); try { Background = SourceNode.ReadElement<BackgroundDrawer>("Background", new BackgroundColourImageDrawer(Color.White),pPersistenceData); } catch { Background = new BackgroundColourImageDrawer(Color.Gray); } ClearTitle = SourceNode.GetAttributeString("ClearTitle", " SCORE \n"); }
internal void FromSerializer(SerializationInfo info, StreamingContext context) { isloaded = true; Debug.Print("cLevel Serialization constructor"); //each is wrapped with a try; any element causing an exception is ignored. Usually, an exception would occur if an item was missing. //SerializableImage grabimage = (SerializableImage)info.GetValue("BackgroundPic", typeof(SerializableImage)); try { MusicName = info.GetString("MusicName"); } catch { } try { LevelName = info.GetString("LevelName"); } catch { } try { Description = info.GetString("Description"); } catch { } try { MaxBalls = info.GetInt32("MaxBalls"); } catch { } try { LevelNameIntroTextFillColor = (Color) info.GetValue("LevelNameIntroTextFillColor", typeof(Color)); } catch { } try { LevelNameIntroTextPenColor = (Color) info.GetValue("LevelNameIntroTextPenColor", typeof(Color)); } catch { } try { LevelnameIntroFont = (Font) info.GetValue("LevelNameIntroFont", typeof(Font)); } catch { } try { TallyMusicName = info.GetString("TallyMusic"); } catch { } try { TallyTickSound = info.GetString("TallyTickSound"); } catch { } try { TallyPicKey = info.GetString("TallyPicKey"); } catch { } try { GameOverMusic = info.GetString("GameOverMusic"); } catch { } try { GameOverPicKey = info.GetString("GameOverPicKey"); } catch { } try { IntroMusicName = info.GetString("IntroMusicName"); } catch { } try { NextLevel = info.GetInt32("NextLevel"); } catch { } try { ShowNameLength = (TimeSpan) info.GetValue("ShowNameLength", typeof(TimeSpan)); } catch { } try { levelblocks = (List<Block>) info.GetValue("Blocks", typeof(List<Block>)); } catch { } try { levelballs = (List<cBall>) info.GetValue("Balls", typeof(List<cBall>)); } catch { } try { NoPaddle = info.GetBoolean("NoPaddle"); } catch { } try { PauseSound = info.GetString("PauseSound"); } catch { } try { StartTrigger = info.GetInt32("StartTrigger"); } catch { } try { DeathSound = info.GetString("DeathSound"); } catch { DeathSound = "mmdeath"; } try { _SidebarColorMatrixValues = (float[][]) info.GetValue("SideBarColorMatrix", typeof(float[][])); } catch { } try { _SidebarImageKey = info.GetString("SidebarImageKey"); } catch { } try { _SidebarTextColor = (Color) info.GetValue("SidebarTextColor", typeof(Color)); } catch { } try { _PauseImageKey = info.GetString("PauseImageKey"); } catch { } try { _PauseColorMatrixValues = (float[][]) info.GetValue("PauseColorMatrix", typeof(float[][])); } catch { } try { _PauseTextColor = (Color) info.GetValue("PauseTextColor", typeof(Color)); } catch { } try { _PauseFont = (Font) info.GetValue("PauseFont", typeof(Font)); } catch { } try { LevelEvents = (List<TriggerEvent>) info.GetValue("LevelEvents", typeof(List<TriggerEvent>)); } catch { } try { //info.AddValue("AvailablePowerups", BCBlockGameState.TypesToString(_AvailablePowerups).ToList()); _AvailablePowerups = BCBlockGameState.StringToTypes((List<String>) info.GetValue("AvailablePowerups", typeof(List<String>))).ToList(); } catch { _AvailablePowerups = GamePowerUp.GetPowerUpTypes().ToList(); } try { MessageData = (List<PlayMessageData>) info.GetValue("MessageData", typeof(List<PlayMessageData>)); } catch { } //empty catch... //try{LevelImage = info.getImage("LevelImage");}catch{} //try { BackgroundColor = (Color)info.GetValue("BackgroundColor", typeof(Color)); }catch{} //try { BackgroundPicKey = info.GetString("BackgroundPic"); }catch {} try { Background = (BackgroundColourImageDrawer) info.GetValue("Background", typeof(BackgroundColourImageDrawer)); } catch { Background = new BackgroundColourImageDrawer(Color.Gray); } try { _ClearTitle = info.GetString("ClearTitle"); } catch { _ClearTitle = " SCORE \n"; } }
public Level() { Background = new BackgroundColourImageDrawer(Color.Gray); TallyMusicName = "TALLYMUSIC"; TallyTickSound = "TALLYTICK"; GameOverMusic = "GAMEOVER"; MusicName = "BASESTOMP"; IntroMusicName = "ARKVC"; PauseSound = "PAUSE"; _MaxBalls = 250; LevelNameIntroTextFillColor = Color.White; LevelNameIntroTextPenColor = Color.Black; LevelnameIntroFont = new Font(BCBlockGameState.GetMonospaceFont(), 48); isloaded = true; //we aren't deferred.... }