private static void DoControls(string FileName, ref PlayerControlerConfigInfo configinfo) { System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(configinfo.GetType()); bool existstest = File.Exists(FileName); using (FileStream stream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { if (existstest) { configinfo = (PlayerControlerConfigInfo)ser.Deserialize(stream); } else { ser.Serialize(stream, configinfo); } } }
public void InitControlerConfigs() { player1config = new PlayerControlerConfigInfo(); player1config.MoveForward = Key.UpArrow; player1config.RotateRight = Key.RightArrow; player1config.RotateLeft = Key.LeftArrow; player1config.PrimaryAction = Key.Return; player1config.SecondaryAction = Key.RightShift; player1config.TargetSelection = Key.Slash; DoControls(SuperMeleePaths.ConfigDir + "Player1KeyConfig.xml", ref player1config); player2config = new PlayerControlerConfigInfo(); player2config.MoveForward = Key.E; player2config.RotateRight = Key.F; player2config.RotateLeft = Key.S; player2config.PrimaryAction = Key.A; player2config.SecondaryAction = Key.W; player2config.TargetSelection = Key.Z; DoControls(SuperMeleePaths.ConfigDir + "Player2KeyConfig.xml", ref player2config); }