public string DynFill(string sFilltp) { string sFilled = sFilltp; for (int cpos = 0; cpos < Conditions.Count; cpos++) { RuleCondition RuleCon = (RuleCondition)Conditions[cpos]; sFilled = sFilled.Replace("%Condition" + (cpos + 1) + "_Quantity%", RuleCon.Quantity.ToString()); sFilled = sFilled.Replace("%Condition" + (cpos + 1) + "_Property%", RuleCon.Property); sFilled = sFilled.Replace("%Condition" + (cpos + 1) + "_PropertyVal%", RuleCon.PropertyVal); } return(sFilled); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); // Ruleset version of this saved stone double SavedVersion = reader.ReadDouble(); // Load XML ruleset base RulesetLoader(); int RuleCount = reader.ReadInt(); // Version 0 - pre RuleCondition class, load differently // to future versions // -- if (version == 0) { // Ignore for (int rpos = 0; rpos < RuleCount; rpos++) { reader.ReadBool(); bool configurable = reader.ReadBool(); if (configurable) { reader.ReadInt(); reader.ReadString(); } } } // -- else { // Compare versions.. ignore any out of date saved data if (RulesetVersion == SavedVersion && RuleCount == Ruleset.Count) { // Same XML ruleset, so load custom data // for (int rpos = 0; rpos < RuleCount; rpos++) { Rule TestRule = (Rule)Ruleset[rpos]; TestRule.Active = reader.ReadBool(); // How many conditions are we dealing with? int ConCount = reader.ReadInt(); for (int cpos = 0; cpos < ConCount; cpos++) { // Match up each condition - they should all exist RuleCondition TestCon = (RuleCondition)TestRule.Conditions[cpos]; TestCon.Configurable = reader.ReadBool(); if (TestCon.Configurable == true) { TestCon.Quantity = reader.ReadInt(); TestCon.PropertyVal = reader.ReadString(); } } } } else { // New XML ruleset, serialized data is out of date, so just deserialize // and leave the default activisation + customization data. // for (int rpos = 0; rpos < RuleCount; rpos++) { reader.ReadBool(); int ConCount = reader.ReadInt(); for (int cpos = 0; cpos < ConCount; cpos++) { bool configurable = reader.ReadBool(); if (configurable) { reader.ReadInt(); reader.ReadString(); } } } } } switch (version) { case 2: // deserialize the properties added with version change goto case 1; case 1: break; } // Add the components //AddComponent( new TourneyStoneBase(),0,0,0); //AddComponent( new TourneyStoneRune(),0,0,0); }