public void Load(string name) { var file = new GameFile($"Formations\\{name}.txt"); // Read the formation name and graphic file Name = file.ReadLine(); GraphicFilename = file.ReadLine(); // Read the SpecialTeams and Kickoff flag IsSpecialTeams = int.Parse(file.ReadLine()) == 1; IsKickoff = int.Parse(file.ReadLine()) == 1; // Read each player type and offset for (int i = 0; i < MAX_SIDE_PLAYERS; i++) { var p = file.ReadParams(); if (p.Count() < 2) { throw new Exception("ERROR::NOT ENOUGH PARAMS FOR OFFSETS IN FORMATION FILE"); } this.DepthType[i] = int.Parse(p[0]); this.DepthPos[i] = int.Parse(p[1]); p = file.ReadParams(); if (p.Count() < 2) { throw new Exception("ERROR::NOT ENOUGH PARAMS FOR OFFSETS IN FORMATION FILE"); } this.OffsetWX[i] = float.Parse(p[0]); this.OffsetWY[i] = float.Parse(p[1]); } }
public void Load(string name) { var file = new GameFile($"Plays\\{name}.txt"); // Read the play name & graphic file this.Name = file.ReadLine(); this.GraphicFilename = file.ReadLine(); // Load each player data for (int i = 0; i < MAX_SIDE_PLAYERS; i++) { // Read the player type var p = file.ReadParams(); if (p.Count() < 9) { throw new Exception("ERROR :: NOT ENOUGH PARAMS FOR PLAYER TYPE IN PLAY FILE"); } this.PlayerFlags[i] = new PlayerObjFlags(); this.PlayerFlags[i].Passer = bool.Parse(p[0]); this.PlayerFlags[i].Receiver = bool.Parse(p[1]); this.PlayerFlags[i].IsDefReceiver = bool.Parse(p[2]); this.PlayerFlags[i].Blocker = bool.Parse(p[3]); this.PlayerFlags[i].Rusher = bool.Parse(p[4]); this.PlayerFlags[i].Kicker = bool.Parse(p[5]); this.PlayerFlags[i].Punter = bool.Parse(p[6]); this.PlayerFlags[i].Placeholder = bool.Parse(p[7]); this.PlayerFlags[i].IsDefBallHolder = bool.Parse(p[8]); // Read each prehike action this.PreHikeActions[i] = new GameActions(); var numActions = int.Parse(file.ReadLine()); for (int ii = 0; ii < numActions; ii++) { var actionParams = file.ReadParams(); if (actionParams.Count() < 5) { throw new Exception("ERROR :: NOT ENOUGH PARAMS FOR PRE HIKE ACTION IN PLAY FILE"); } this.PreHikeActions[i].PushEnd( int.Parse(actionParams[0]), int.Parse(actionParams[1]), float.Parse(actionParams[2]), float.Parse(actionParams[3]), float.Parse(actionParams[4])); } // Read each post action this.PostHikeActions[i] = new GameActions(); numActions = int.Parse(file.ReadLine()); for (int ii = 0; ii < numActions; ii++) { var actionParams = file.ReadParams(); if (actionParams.Count() < 5) { throw new Exception("ERROR :: NOT ENOUGH PARAMS FOR POST HIKE ACTION IN PLAY FILE"); } this.PostHikeActions[i].PushEnd( int.Parse(actionParams[0]), int.Parse(actionParams[1]), float.Parse(actionParams[2]), float.Parse(actionParams[3]), float.Parse(actionParams[4])); } } }