private void button1_Click(object sender, EventArgs e) { var mg = new MapGen(); mg.NewMap(); pictureBox1.Refresh(); var db = new DbDataContext(); co = db.CelestialObjects.ToList(); }
public static RegisterResponse Register(string login, string password) { using (var t = new TransactionScope()) { var db = new DbDataContext(); var user = db.SpringAccounts.SingleOrDefault(x => x.Name == login); if (user == null) return RegisterResponse.NotValidSpringLogin; if (user.Players != null) return RegisterResponse.AlreadyRegistered; if (db.SpringAccounts.Any(x => x.UserCookie == user.UserCookie && x.Players != null)) return RegisterResponse.IsSmurf; if (user.Password != SpringAccount.HashPassword(password)) return RegisterResponse.NotValidSpringPassword; // create player and assign to smallest alliance var player = new Player() { IsActive = true, StarSystem = db.StarSystems.OrderBy(x => x.Players.Where(y => y.IsActive).Count()).First() }; user.Players = player; player.MothershipName = player.SpringAccount.Name + "'s mothership"; // create his planet var mg = new MapGen(); var hisPlanet = mg.CreateHomeworld(player.StarSystem.CelestialObject); hisPlanet.Name = player.SpringAccount.Name + "'s home"; hisPlanet.Player = player; player.StarSystem.CelestialObject.ChildCelestialObjects.Add(hisPlanet); hisPlanet.UpdateIncomeInfo(); db.SubmitChanges(); var e = db.AddEvent(EventType.Player, "{0} joined the {1}", player.Name, player.StarSystem.Name); e.Connect(player); e.Connect(hisPlanet); db.MarkDirty(); db.SubmitChanges(); t.Complete(); return RegisterResponse.Ok; } }