CreateGame() публичный Метод

public CreateGame ( string gameDir, GameOptions options ) : IGame
gameDir string
options GameOptions
Результат IGame
Пример #1
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.Name = "SMain";

            var path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "save");

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            var gameDir = path;

            bool cleanSaves = true;

            SaveManager saveManager = new SaveManager(gameDir);

            Guid save = Guid.Empty;

            if (cleanSaves)
            {
                saveManager.DeleteAll();
            }
            else
            {
                save = saveManager.GetLatestSaveFile();
            }

            var   gf = new GameFactory();
            IGame game;

            if (save == Guid.Empty)
            {
                game = gf.CreateGame(gameDir,
                                     new GameOptions()
                {
                    Mode       = GameMode.Fortress,
                    Map        = GameMap.Fortress,
                    TickMethod = WorldTickMethod.Simultaneous
                });
            }
            else
            {
                game = gf.LoadGame(gameDir, save);
            }

            var keyThread = new Thread(KeyMain);

            keyThread.Start(game);

            game.Run(null);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.Name = "SMain";

            var path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "save");

            if (!System.IO.Directory.Exists(path))
                System.IO.Directory.CreateDirectory(path);

            var gameDir = path;

            bool cleanSaves = true;

            SaveManager saveManager = new SaveManager(gameDir);

            Guid save = Guid.Empty;

            if (cleanSaves)
                saveManager.DeleteAll();
            else
                save = saveManager.GetLatestSaveFile();

            var gf = new GameFactory();
            IGame game;

            if (save == Guid.Empty)
                game = gf.CreateGame(gameDir,
                    new GameOptions()
                    {
                        Mode = GameMode.Fortress,
                        Map = GameMap.Fortress,
                        TickMethod = WorldTickMethod.Simultaneous
                    });
            else
                game = gf.LoadGame(gameDir, save);

            var keyThread = new Thread(KeyMain);
            keyThread.Start(game);

            game.Run(null);
        }
Пример #3
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.Name = "SMain";

            var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
            path = System.IO.Path.Combine(path, "Dwarrowdelf", "save");
            if (!System.IO.Directory.Exists(path))
                System.IO.Directory.CreateDirectory(path);

            var gameDir = path;

            bool cleanSaves = true;

            SaveManager saveManager = new SaveManager(gameDir);

            Guid save = Guid.Empty;

            if (cleanSaves)
                saveManager.DeleteAll();
            else
                save = saveManager.GetLatestSaveFile();

            var gf = new GameFactory();
            GameEngine game;

            if (save == Guid.Empty)
                game = (GameEngine)gf.CreateGame(gameDir, GameMode.Fortress, GameMap.Fortress);
            else
                game = (GameEngine)gf.LoadGame(gameDir, save);

            var keyThread = new Thread(KeyMain);
            keyThread.Start(game);

            game.Run(null);
        }