Пример #1
0
        public void Create_World_And_Hexes()
        {
            var race = new Race { Name = "Default Race" };
            var nation = new Nation { Name = "Default Nation", Race = race };
            var user = new User { Email = "*****@*****.**", FirstName = "Jamie", LastName = "Fraser", OpenId = "http://jamief00.myopenid.com/" };
            var world = new World { Height = 100, Width = 100, Name = "Default World" };
            var game = new Game { Name = "Default Game", Started = DateTime.Now, GameWorld = world};
            var gameSession = new GameSession { EnteredGame = DateTime.Now, Nation = nation, Game = game, User = user };

            using (var tran = _dataContext.WorldRepository.Session.BeginTransaction())
            {
                _dataContext.RaceRepository.Save(race);
                _dataContext.NationRepository.Save(nation);
                _dataContext.UserRepository.Save(user);
                _dataContext.GameRepository.Save(game);
                _dataContext.WorldRepository.Save(world);
                _dataContext.GameSessionRepository.Save(gameSession);

                for (var y = 1; y <= world.Width; y++)
                {
                    for (var x = 1; x <= world.Height; x++)
                    {
                        var hex = new Hex { World = world, HexType = HexType.Grass, X = x, Y = y };

                        _dataContext.HexRepository.Save(hex);
                    }
                }

                tran.Commit();
            }
        }
Пример #2
0
        public static GameSession CreateSession(User user, Race race)
        {
            var nation = new Nation { Name = "Default Nation", Race = race };
            var world = new World { Height = 100, Width = 100, Name = "Default World" };
            var game = new Game { Name = "Default Game", Started = DateTime.Now, GameWorld = world };
            var gameSession = new GameSession { EnteredGame = DateTime.Now, Nation = nation, Game = game, User = user };

            for (var y = 1; y <= world.Width; y++)
            {
                for (var x = 1; x <= world.Height; x++)
                {
                    world.AddHex(new Hex { World = world, HexType = HexType.Grass, X = x, Y = y });
                }
            }

            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());

            return gameSession;
        }
Пример #3
0
        public static GameSession CreateGameSession()
        {
            var race = new Race { Name = "Default Race", Description = "Test Race not used in the actual game."};
            var nation = new Nation { Name = "Default Nation", Race = race };
            var user = new User { Email = "*****@*****.**", FirstName = "Jamie", LastName = "Fraser", OpenId = "http://jamief00.mytestopenid.com/" };
            var world = new World { Height = 100, Width = 100, Name = "Default World" };
            var game = new Game { Name = "Default Game", Started = DateTime.Now, GameWorld = world};
            var gameSession = new GameSession { EnteredGame = DateTime.Now, Nation = nation, Game = game, User = user };

            for (var y = 1; y <= world.Width; y++)
            {
                for (var x = 1; x <= world.Height; x++)
                {
                    world.AddHex(new Hex { World = world, HexType = HexType.Grass, X = x, Y = y });
                }
            }

            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());
            nation.AddUnit(new Unit());

            return gameSession;
        }