public Player(GameSession session, Account account, PlayerDto dto) { Session = session; Account = account; _tutorialState = dto.TutorialState; _level = dto.Level; _totalExperience = (uint)dto.TotalExperience; _pen = (uint)dto.PEN; _ap = (uint)dto.AP; _coins1 = (uint)dto.Coins1; _coins2 = (uint)dto.Coins2; Settings = new PlayerSettingManager(this, dto); DenyManager = new DenyManager(this, dto); Mailbox = new Mailbox(this, dto); LicenseManager = new LicenseManager(this, dto); Inventory = new Inventory(this, dto); CharacterManager = new CharacterManager(this, dto); RoomInfo = new PlayerRoomInfo(); DeathMatch = new DMStats(this, dto); TouchDown = new TDStats(this, dto); Chasser = new ChaserStats(this, dto); BattleRoyal = new BRStats(this, dto); CaptainMode = new CPTStats(this, dto); Mission = new WeeklyMission(this, dto); RandomShop = new RandomShopInfo[2]; }
/// <summary> /// Saves all pending changes to the database /// </summary> public void Save() { using (var db = GameDatabase.Open()) { if (NeedsToSave) { db.Update(new PlayerDto { Id = (int)Account.Id, TutorialState = TutorialState, Level = Level, TotalExperience = (int)TotalExperience, PEN = (int)PEN, AP = (int)AP, Coins1 = (int)Coins1, Coins2 = (int)Coins2, CurrentCharacterSlot = CharacterManager.CurrentSlot }); NeedsToSave = false; } Settings.Save(db); Inventory.Save(db); CharacterManager.Save(db); LicenseManager.Save(db); DenyManager.Save(db); Mailbox.Save(db); } }
/// <summary> /// Saves all pending changes to the database /// </summary> public void Save(bool createScope) { var scope = createScope ? new DataAccessScope() : null; try { if (NeedsToSave) { var plrRef = GameDatabase.Instance.Players.GetReference((int)Account.Id); plrRef.TutorialState = TutorialState; plrRef.Level = Level; plrRef.TotalExperience = (int)TotalExperience; plrRef.PEN = (int)PEN; plrRef.AP = (int)AP; plrRef.Coins1 = (int)Coins1; plrRef.Coins2 = (int)Coins2; plrRef.CurrentCharacterSlot = CharacterManager.CurrentSlot; NeedsToSave = false; } Inventory.Save(); CharacterManager.Save(); LicenseManager.Save(); DenyManager.Save(); Mailbox.Save(); scope?.Complete(); } finally { scope?.Dispose(); } }
public Player(GameSession session, Account account, PlayerDto dto) { Session = session; Account = account; _tutorialState = dto.TutorialState; _level = dto.Level; _totalExperience = (uint)dto.TotalExperience; _pen = (uint)dto.PEN; _ap = (uint)dto.AP; _coins1 = (uint)dto.Coins1; _coins2 = (uint)dto.Coins2; Settings = new PlayerSettingManager(this, dto); DenyManager = new DenyManager(this, dto); Mailbox = new Mailbox(this, dto); LicenseManager = new LicenseManager(this, dto); Inventory = new Inventory(this, dto); CharacterManager = new CharacterManager(this, dto); RoomInfo = new PlayerRoomInfo(); }