public static EditWorldTemplateForm ShowDialogue(Window window, WorldTemplate _template, CloseEvent closeFunction = null, string category = null, ISkinFile file = null) { var form = new EditWorldTemplateForm(); form.Initialize(_template, closeFunction, "Edit World-Template", true, true, category, file); form.Show(window); return(form); }
public static WorldTemplate GetWorldGenerationParameters( AsyncRPGDataContext context, int game_id) { WorldTemplate worldTemplate = new WorldTemplate(); Games[] game = (from g in context.Games where g.GameID == game_id select g).ToArray <Games>(); worldTemplate.dungeon_size = (GameConstants.eDungeonSize)(game[0].DungeonSize); worldTemplate.dungeon_difficulty = (GameConstants.eDungeonDifficulty)(game[0].DungeonDifficulty); return(worldTemplate); }
public override void AddedToContainer() { base.AddedToContainer(); var builder = new FieldBuilder(); builder.BuildSessionStart(this); var templateNameTextField = builder.AddTextField("Template Name: "); var worldTypesComboBox = builder.AddComboBoxField("World Type: "); var worldTypeList = Globals.GetAllTypesDeriving(typeof(IWorld), Assembly.GetExecutingAssembly()); worldTypesComboBox.Items.AddRange(worldTypeList.Select(s => s.Name)); worldTypesComboBox.Index = 0; builder.AddResizableButtonField("OK", delegate(object sender) { if (worldTypesComboBox.Index == -1) { AlertForm.ShowDialogue(Parent, null, "Select a world type."); } else { Result = new WorldTemplate(); Result.TemplateName = templateNameTextField.Text; Result.World = (IWorld)Activator.CreateInstance(worldTypeList[worldTypesComboBox.Index]); EditWorldTemplateForm.ShowDialogue(Parent, Result); Close(); } }); builder.BuildSessionEnd(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); CanResizeFormVertically = false; }
public bool ValidateDungeons(Command command) { bool success = true; string result = SuccessMessages.GENERAL_SUCCESS; RoomTemplateSet roomTemplateSet = new RoomTemplateSet(); MobTypeSet mobTypeSet = new MobTypeSet(); MobSpawnTableSet mobSpawnTableSet = new MobSpawnTableSet(); int game_id_min = 0; int game_id_max = 100000; // Int32.MaxValue; This will take ~100 days to finish all 2 billion dungeons string connection_string = ""; string dumpGeometryPath = ""; if (command.HasArgumentWithName("C")) { connection_string = command.GetTypedArgumentByName <CommandArgument_String>("C").ArgumentValue; } else { _logger.WriteLine("DungeonValidator: Missing expected connection string parameter"); success = false; } if (command.HasArgumentWithName("G")) { game_id_min = command.GetTypedArgumentByName <CommandArgument_Int32>("G").ArgumentValue; game_id_max = game_id_min; } else { _logger.WriteLine("DungeonValidator: No game id given, evaluating all possible game ids"); } if (game_id_min == game_id_max && command.HasArgumentWithName("D")) { dumpGeometryPath = command.GetTypedArgumentByName <CommandArgument_String>("D").ArgumentValue; } _logger.WriteLine("Validating layouts for game_ids {0} to {1}", game_id_min, game_id_max); // Get the room templates from the DB if (success && !roomTemplateSet.Initialize(connection_string, out result)) { _logger.WriteLine(string.Format("DungeonValidator: Failed to load the room templates from the DB: {0}", result)); success = false; } // Get the mob type set from the DB if (success && !mobTypeSet.Initialize(connection_string, out result)) { _logger.WriteLine(string.Format("DungeonValidator: Failed to load the mob types from the DB: {0}", result)); success = false; } // Get the mob spawn templates from the DB if (success && !mobSpawnTableSet.Initialize(connection_string, mobTypeSet, out result)) { _logger.WriteLine(string.Format("DungeonValidator: Failed to load the mob spawn tables from the DB: {0}", result)); success = false; } if (success) { DateTime startTime = DateTime.Now; // Test all possible world size configurations for each desired game id WorldTemplate[] worldTemplates = new WorldTemplate[] { new WorldTemplate(GameConstants.eDungeonSize.small, GameConstants.eDungeonDifficulty.normal), new WorldTemplate(GameConstants.eDungeonSize.medium, GameConstants.eDungeonDifficulty.normal), new WorldTemplate(GameConstants.eDungeonSize.large, GameConstants.eDungeonDifficulty.normal), }; for (int game_id = game_id_min; success && game_id <= game_id_max; ++game_id) { foreach (WorldTemplate worldTemplate in worldTemplates) { DungeonLayout layout = new DungeonLayout(game_id, worldTemplate, roomTemplateSet, mobSpawnTableSet); // Create the initial set of rooms for the world if (!layout.BuildRoomLayout(out result)) { _logger.WriteLine( string.Format("DungeonValidator: Failed to generate dungeon layout, game_id:{0}, size:{1}", game_id, worldTemplate.dungeon_size)); _logger.WriteLine(result); success = false; } // Verify that this is a valid dungeon if (success) { Dictionary <int, Portal> portalIdToPortalMap = BuildPortalIdMap(layout); // Verify that all portals are connected correctly success &= VerifyRoomPortals(layout, portalIdToPortalMap); // Verify that every room is accessible to every other room success &= VerifyRoomAccessibility(layout, portalIdToPortalMap); // Verify monster spawners success &= VerifyMobSpawners(layout); } // Dump the generated layout to a .obj file if (dumpGeometryPath.Length > 0) { DumpLayoutGeometry(dumpGeometryPath, layout); } } if (game_id_max > game_id_min) { if ((game_id % 1000) == 0) { TimeSpan elapsed = DateTime.Now.Subtract(startTime); int percent_complete = 100 * (game_id - game_id_min) / (game_id_max - game_id_min); _logger.Write("\r[{0:c}] {1}/{2} {3}%", elapsed, game_id - game_id_min, game_id_max - game_id_min, percent_complete); } } } // Write out a new line after the timing info _logger.WriteLine(); } return(success); }
public void Initialize(WorldTemplate _template, CloseEvent closeFunction = null, string title = null, bool resizable = false, bool isDialog = true, string category = null, ISkinFile file = null) { template = _template; base.Initialize(closeFunction, title, resizable, isDialog, category, file); }
public override void AddedToContainer() { base.AddedToContainer(); CloseButtonOn = false; columnListBox = new ColumnListBox(); columnListBox.Initialize(1); AddDrawBox(columnListBox); columnListBox.SetIntOrStringSort(false); columnListBox.SetColumnName(0, "Name"); columnListBox.Width = 200; columnListBox.Height = 200; columnListBox.ItemDoubleClicked += delegate(object sender, ColumnListBox.ListBoxRow item, int index) { WorldTemplate template = null; foreach (var g in EditorData.WorldTemplates) { if (g.TemplateName == (string)item.Values[0]) { template = g; } } string oldName = template.TemplateName; EditWorldTemplateForm.ShowDialogue(Parent, template, delegate(object _sender) { foreach (var g in EditorData.WorldTemplates) { if (g.TemplateName == template.TemplateName && g != template) { AlertForm.ShowDialogue(Parent, null, "There is a template with that name already."); template.TemplateName = oldName; } } ReloadListBox(); }); }; ReloadListBox(); var createTemplateButton = new ResizableButton(); createTemplateButton.Initialize(); AddDrawBox(createTemplateButton); createTemplateButton.Title = "Create New Template"; createTemplateButton.FitToText(); Push.ToTheBottomSideOf(createTemplateButton, columnListBox, 3, Push.VerticalAlign.Left); createTemplateButton.Width = 200; createTemplateButton.Click += delegate(object sender) { CreateWorldTemplateForm.ShowDialogue(Parent, delegate(object _sender) { var dialogue = (CreateWorldTemplateForm)_sender; if (dialogue.Result != null) { bool nameExists = false; foreach (var t in EditorData.WorldTemplates) { if (t.TemplateName == dialogue.Result.TemplateName) { AlertForm.ShowDialogue(Parent, null, "A template called: \"" + dialogue.Result.TemplateName + "\" already exists"); nameExists = true; } } if (!nameExists) { EditorData.WorldTemplates.Add(dialogue.Result); ReloadListBox(); } } }); }; var deleteTemplateButton = new ResizableButton(); deleteTemplateButton.Initialize(); AddDrawBox(deleteTemplateButton); deleteTemplateButton.Title = "Delete Template"; deleteTemplateButton.FitToText(); Push.ToTheBottomSideOf(deleteTemplateButton, createTemplateButton, 3, Push.VerticalAlign.Left); deleteTemplateButton.Width = 200; deleteTemplateButton.Click += delegate(object sender) { if (columnListBox.SelectedRow != null) { var findName = (string)columnListBox.SelectedRow.Values[0]; foreach (var g in EditorData.WorldTemplates) { if (g.TemplateName == findName) { EditorData.WorldTemplates.Remove(g); ReloadListBox(); break; } } } }; var editTemplateButton = new ResizableButton(); editTemplateButton.Initialize(); AddDrawBox(editTemplateButton); editTemplateButton.Title = "Edit Template"; editTemplateButton.FitToText(); Push.ToTheBottomSideOf(editTemplateButton, deleteTemplateButton, 3, Push.VerticalAlign.Left); editTemplateButton.Width = 200; editTemplateButton.Click += delegate(object sender) { if (columnListBox.SelectedRow == null) { return; } WorldTemplate template = null; foreach (var g in EditorData.WorldTemplates) { if (g.TemplateName == (string)columnListBox.SelectedRow.Values[0]) { template = g; } } string oldName = template.TemplateName; EditWorldTemplateForm.ShowDialogue(Parent, template, delegate(object _sender) { foreach (var g in EditorData.WorldTemplates) { if (g.TemplateName == template.TemplateName && g != template) { AlertForm.ShowDialogue(Parent, null, "There is a template with that name already."); template.TemplateName = oldName; } } ReloadListBox(); }); }; var okButton = new ResizableButton(); okButton.Initialize(); AddDrawBox(okButton); okButton.Title = "OK"; okButton.FitToText(); Push.ToTheBottomSideOf(okButton, editTemplateButton, 3, Push.VerticalAlign.Left); okButton.Width = 200; okButton.Click += delegate(object sender) { EditorData.Save(Globals.EditorDataSaveDir); Close(); }; Wrap(); columnListBox.Alignment = DrawBoxAlignment.GetFull(); createTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); deleteTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); editTemplateButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); okButton.Alignment = DrawBoxAlignment.GetLeftRightBottom(); X = (Parent.Width / 2) - (Width / 2); Y = (Parent.Height / 2) - (Height / 2); }