示例#1
0
        private GameOptions GetReplayGameOptions()
        {
            string replayFilePath = Directory.GetFiles(Application.persistentDataPath + Path.DirectorySeparatorChar + "Game Logs" + Path.DirectorySeparatorChar)[0];

            // ReSharper disable once AssignNullToNotNullAttribute
            Directory.CreateDirectory(Path.GetDirectoryName(replayFilePath));
            string[]          replayFileLines = File.ReadAllLines(replayFilePath);
            var               gameLog         = new GameLog(replayFileLines);
            List <GamePlayer> gamePlayers     = gameLog.GetPlayerNames().Select(p => new GamePlayer
            {
                Name       = p,
                Characters = gameLog.GetCharacterNames(p).Select(CharacterFactory.Create).ToList()
            }).ToList();
            var gameOptions = new GameOptions
            {
                Map       = Stuff.Maps.Single(m => m.Name == gameLog.GetMapName()),
                Players   = gamePlayers,
                UIManager = UIManager.Instance,
                Type      = GameType.Replay,
                GameLog   = gameLog
            };

            gameOptions.Players.ForEach(p =>
            {
                p.Characters.ForEach(c => c.Owner = p);
                p.HasSelectedCharacters           = true;
            });
            return(gameOptions);
        }