/** * Deletes current gamestate (characters, explored map etc) and creates default data. * This will causes all characters, maps, etc to be lost */ public void Reset() { if (!CoM.GameDataLoaded) { throw new Exception("Can not reset save file until game data has been loaded."); } SpawnManager = new SpawnManager(); // Store. Store = new MDRStore(); Store.SetDefault(); GameStats.AddDefaultStats(); // Explored dungeon. ExploredDungeon = new MDRDungeon(); ExploredDungeon.Initialize(CoM.Dungeon.Width, CoM.Dungeon.Height, CoM.Dungeon.Floors); // characters and party CharacterList = loadFromStore <MDRCharacterLibrary>("DefaultCharacters"); PartyList = loadFromStore <MDRPartyLibrary>("DefaultParty"); Trace.Log("Save file reset."); _loaded = true; }
public GuiSellItemArea(int width, int height, MDRStore sourceStore) : base(width, height) { EnableBackground = false; Store = sourceStore; ItemSlot = new GuiInspectionSlot(); Add(ItemSlot, 0, 50); ItemSlot.Visible = false; dropHint = new GuiLabel("Drop Here"); dropHint.FontSize = 24; dropHint.FontColor = new Color(0.9f, 0.9f, 0.9f, 0.9f); Add(dropHint, 0, 0); createButons(); }
/** Restores game from save file. */ public void Load() { Util.Assert(CoM.GameDataLoaded, "Data must be loaded before loading a save file."); DateTime startTime = DateTime.Now; GameStats = loadFromStoreDefault <GameRecords>("GameStats"); Store = loadFromStoreDefault <MDRStore>("Store"); ExploredDungeon = loadFromStoreDefault <MDRDungeon>("ExploredDungeon"); CharacterList = loadFromStoreDefault <MDRCharacterLibrary>("Characters"); PartyList = loadFromStoreDefault <MDRPartyLibrary>("Parties"); SpawnManager = loadFromStoreDefault <SpawnManager>("SpawnData"); Trace.Log("Save file loading completed in " + (DateTime.Now - startTime).TotalMilliseconds.ToString("0.0") + "ms."); _loaded = true; UpdateCharacterRecords(true); }
/** Create the store ui */ //todo: remove sizes public GuiStore(MDRStore store, int width = 800, int height = 600) : base(width, height) { int splitWidth = (width / 2) + 50; const int HEADER_HEIGHT = 50; WindowStyle = GuiWindowStyle.ThinTransparent; StoreSelectedItemID = -1; Store = store; CanReceiveFocus = true; DragDropEnabled = true; // ----------------------------------------- // Main areas var mainArea = new GuiContainer(0, (int)ContentsBounds.height - HEADER_HEIGHT); mainArea.Align = GuiAlignment.Bottom; // ----------------------------------------- // Header var headerArea = new GuiContainer((int)ContentsBounds.width, HEADER_HEIGHT); headerArea.EnableBackground = true; headerArea.Style = Engine.GetStyleCopy("Frame"); headerArea.Y -= 4; headerArea.X -= 4; headerArea.Width += 8; modeButtons = new GuiRadioButtonGroup(); modeButtons.AddItem("Buy"); modeButtons.AddItem("Sell"); modeButtons.ButtonSize = new Vector2(120, 30); modeButtons.ButtonSpacing = 50; modeButtons.EnableBackground = false; headerArea.Add(modeButtons, 0, 0, true); modeButtons.OnValueChanged += delegate { _mode = (StoreMode)modeButtons.SelectedIndex; updateStoreMode(); }; Add(headerArea); Add(mainArea); // ----------------------------------------- // Item Info Area GuiPanel itemInfoPanel = new GuiPanel((int)ContentsBounds.width - splitWidth); itemInfoPanel.Align = GuiAlignment.Right; itemInfoPanel.EnableBackground = false; mainArea.Add(itemInfoPanel, -1, 1, true); itemInfoBackground = new GuiImage(0, 0, ResourceManager.GetSprite("Gui/InnerWindow")); itemInfoBackground.Align = GuiAlignment.Full; itemInfoBackground.Color = Colors.StoreItemInfoBackgroundColor; itemInfoPanel.Add(itemInfoBackground); SelectedItemInfo = new GuiItemToolTip(); SelectedItemInfo.EnableBackground = false; SelectedItemInfo.Align = GuiAlignment.Full; SelectedItemInfo.ShowAllInfo = true; itemInfoPanel.Add(SelectedItemInfo); // ----------------------------------------- // Item Buy Area buyItemArea = new GuiContainer(splitWidth, (int)ContentsBounds.height); buyItemArea.Align = GuiAlignment.Left; mainArea.Add(buyItemArea); itemListingScrollArea = new GuiScrollableArea(buyItemArea.Width, buyItemArea.Height, ScrollMode.VerticalOnly); buyItemArea.Add(itemListingScrollArea); filterItemsToggle = new GuiToggleButton(); filterItemsToggle.OnValueChanged += delegate { ShowOnlyUsableItems = filterItemsToggle.Value; }; mainArea.Add(filterItemsToggle, -10, -10); filterItemsToggle.Visible = false; buyButton = new GuiButton("Buy"); buyButton.OnMouseClicked += DoBuy; itemInfoPanel.Add(buyButton, 0, -30); notEnoughGold = new GuiLabel("No enough coins"); notEnoughGold.FontColor = new Color(0.5f, 0.5f, 0.5f, 0.9f); notEnoughGold.Visible = false; itemInfoPanel.Add(notEnoughGold, 0, -56); // ----------------------------------------- // item Sell area sellItemArea = new GuiSellItemArea((int)mainArea.ContentsBounds.width - splitWidth, (int)mainArea.ContentsBounds.height, store); sellItemArea.Align = GuiAlignment.Right; sellItemArea.OnSell += delegate { Mode = StoreMode.Buy; }; mainArea.Add(sellItemArea); // ----------------------------------------- CoM.Party.OnSelectedChanged += createStoreListings; store.OnInventoryChanged += createStoreListings; updateStoreMode(); createStoreListings(); }