public Questor(frmMain form1) { m_Parent = form1; _lastPulse = DateTime.MinValue; _random = new Random(); _salvage = new Salvage(); _defense = new Defense(); _combat = new Combat(); _traveler = new Traveler(); _unloadLoot = new UnloadLoot(); _agentInteraction = new AgentInteraction(); _arm = new Arm(); _missionController = new MissionController(); _drones = new Drones(); _panic = new Panic(); _storyline = new Storyline(); Settings.Instance.SettingsLoaded += SettingsLoaded; // State fixed on ExecuteMission State = QuestorState.Idle; _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; Cache.Instance.StopTimeSpecified = Program.stopTimeSpecified; _directEve.OnFrame += OnFrame; }
public static StorylineEditor OpenWindow(Storyline target, string title, bool focus, params System.Type[] desiredDockNextTo) { StorylineEditor window = GetWindow <StorylineEditor>(title, focus, desiredDockNextTo); window.target = target; return(window); }
public Questor() { _lastPulse = DateTime.MinValue; _random = new Random(); _salvage = new Salvage(); _defense = new Defense(); _combat = new Combat(); _traveler = new Traveler(); _unloadLoot = new UnloadLoot(); _agentInteraction = new AgentInteraction(); _arm = new Arm(); _missionController = new MissionController(); _drones = new Drones(); _panic = new Panic(); _storyline = new Storyline(); Settings.Instance.SettingsLoaded += SettingsLoaded; // State fixed on ExecuteMission State = QuestorState.Idle; _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; _directEve.OnFrame += OnFrame; }
protected override void AssertStoryline(Storyline model, StorylineNode node) { var(testStoryline, testNode) = GetTestStoryline(); AssertPropertiesAreEqual(testStoryline, model, nameof(model.Name), nameof(model.Description)); AssertPropertiesAreEqual(testNode, node, nameof(node.XPosition), nameof(node.YPosition)); }
private void OnSelectionChange() { Storyline selection = Selection.activeObject as Storyline; if (selection != null) { target = selection; } }
public static bool OnOpenAsset(int instanceID, int line) { Storyline asset = EditorUtility.InstanceIDToObject(instanceID) as Storyline; if (asset != null) { OpenWindow(asset); return(true); } return(false); }
public void SetUp() { storyline = new GameStoryline(); simpleQuest = new CleanseTheCellarsQuest(); // Simulate the existence of 10 rats GetRidOfRatsObjective.rats = 10; // Simulate the possession of 0 herbs Find10HerbsObjective.herbs = 0; }
/// <summary> /// This method will show detail of selected storyline. /// </summary> private void ShowStoryline(Storyline storyline) { if (storyline != null) { StoriesListBox.DataContext = storyline.Stories; StorylineGrid.DataContext = storyline; } StorylinesGrid.Visibility = Visibility.Collapsed; StorylineGrid.Visibility = Visibility.Visible; StoryGrid.Visibility = Visibility.Collapsed; StoriesGrid.Visibility = Visibility.Visible; WallGrid.Visibility = Visibility.Collapsed; }
protected override (Storyline model, StorylineNode node) GetTestStoryline() { var storyline = new Storyline() { Name = "StorylineName", Description = "StorylineDescription" }; var node = new StorylineNode() { Storyline = storyline, XPosition = 10, YPosition = 20 }; return(storyline, node); }
/// <summary> /// Initializes a new instance of the <see cref="Storyline"/> class. /// </summary> /// <param name="storyline">The <see cref="Storyline"/> for which to create this viewmodel.</param> /// <param name="xPosition">The X position of the viewmodel in the diagram.</param> /// <param name="yPosition">The Y position of the viewmodel in the diagram.</param> /// <param name="getIdForModelFunc">A function returning the Id for the provided model.</param> public StorylineViewModel(Storyline storyline, float xPosition, float yPosition, Func <object, Guid> getIdForModelFunc = null) : this(storyline, getIdForModelFunc) { XPosition = xPosition; YPosition = yPosition; }
/// <summary> /// Update the provided model with the values in this viewmodel. /// </summary> /// <param name="model">The model to update.</param> public void UpdateModel(Storyline model) { // Only set the properties we can set, so don't set shadow properties like the Id. model.Name = Name; model.Description = Description; }
public Questor(frmMain form1) { m_Parent = form1; _lastPulse = DateTime.MinValue; _random = new Random(); //_debugmodule = new DebugModule(); //_scoop = new Scoop(); _salvage = new Salvage(); _defense = new Defense(); _localwatch = new LocalWatch(); _scanInteraction = new ScanInteraction(); _combat = new Combat(); _traveler = new Traveler(); _unloadLoot = new UnloadLoot(); _agentInteraction = new AgentInteraction(); _arm = new Arm(); _courier = new CourierMission(); _switch = new SwitchShip(); _missionController = new MissionController(); _drones = new Drones(); _panic = new Panic(); _storyline = new Storyline(); Settings.Instance.SettingsLoaded += SettingsLoaded; // State fixed on ExecuteMission State = QuestorState.Idle; _directEve = new DirectEve(); Cache.Instance.DirectEve = _directEve; Cache.Instance.StopTimeSpecified = Program.stopTimeSpecified; Cache.Instance.MaxRuntime = Program.maxRuntime; Cache.Instance.StopTime = Program._stopTime; _questorStarted = DateTime.Now; _directEve.OnFrame += OnFrame; }
/// <summary> /// Constructs a collection of report rows based on the data content and the templates that describes the row. /// </summary> /// <param name="iContent">The content to be displayed in the row.</param> /// <param name="rowTemplate">The template that describes how the data is presented.</param> private void RecursivelyUpdateRow(IContent iContent, RowTemplate rowTemplate) { // Each IContent object has a unique key used to associate it with a report row. If a given report row has already has been mapped to the // IContent's key, then the contents of that row will be updated. Otherwise, a new row is created and associated with the IContent. ReportRow reportRow = null; if (iContent.Key != null && this.dictionary.TryGetValue(iContent.Key, out reportRow)) { // Any change to the location or the height of the row will be animated so long as the current or target location is visible. There is no // sense in animating the movement of invisible elements of the report. if (reportRow.Top != this.height || reportRow.Height != rowTemplate.Height) { // At this point it has been determined that the row has moved. An animation sequence will be created for those rows that appear in or // disappear from the viewport. Boolean isRowVisible = (this.viewport.Top <= reportRow.Top && reportRow.Top < this.viewport.Bottom) || (this.viewport.Top <= reportRow.Top + reportRow.Height && reportRow.Top + reportRow.Height < this.viewport.Bottom); Boolean willRowBeVisible = (this.viewport.Top <= this.height && this.height < this.viewport.Bottom) || (this.viewport.Top <= this.height + rowTemplate.Height && this.height + rowTemplate.Height < this.viewport.Bottom); // This creates a list of rows who's ZIndex must be set for the animation sequence. if (isRowVisible || willRowBeVisible) { // At this point the report row either is currently visible or will be visible and has been moved or resized. This means that the // visible part of the virtual document should be measured. Items that have become visible will need to be instantiated and items that // are no longer visible need to be recycled. this.isMeasurementRequired = true; // The ZIndex of this row is set such that the rows that move the greatest distance will appear to float above the ones that only move a little. This scheme // makes the movement appear more natural. reportRow.ZIndex = Math.Abs(reportRow.Ordinal - this.ordinal); // When all the report rows have been examined and the Z order of the visible rows set, this list is used to set the ZIndex of all the // graphical elements associated with this row. this.animatedRows.Add(reportRow); } // The order of the row in the report is used for setting graphical cues such as shading and Z order. reportRow.Ordinal = this.ordinal; // If the location occupied by this row has changed then an animation sequence is constructed to move a row from one place to another. If // the row isn't visible or is not going to be visible, then just the location is modified. if (reportRow.Top != this.height) { // This will move the row to its proper position in the virtual document. reportRow.Top = this.height; // The starting location is clipped by the visible part of the report. This prevents a row that is moved to a far distant place from // moving too fast to be seen on the screen. // HACK - This should be repaired when time permits. // Double startLocation = (reportRow.ActualTop < viewport.Top) ? viewport.Top - reportRow.Height : // (reportRow.ActualTop > viewport.Bottom) ? viewport.Bottom : reportRow.ActualTop; Double startLocation = reportRow.ActualTop; // The ending location is also clipped by the visible part of the report for the same reason. Without this code, rows appear to // disappear instantly from the screen instead of moving smoothly to the nearest edge. // HACK - This should be repaired when time permits. // Double endLocation = (reportRow.Top + reportRow.Height < viewport.Top) ? viewport.Top - reportRow.Height : // (reportRow.Top > viewport.Bottom) ? viewport.Bottom : reportRow.Top; Double endLocation = reportRow.Top; // This animates the movement of the row from its current position to the new position. If the row is no longer visible then any // animation that was associated with that row will be terminated. if (isRowVisible || willRowBeVisible) { DoubleAnimation topAnimation = new DoubleAnimation(); Storyline.SetTargetObject(topAnimation, reportRow); Storyline.SetTargetProperty(topAnimation, ReportRow.ActualTopProperty); topAnimation.From = startLocation; topAnimation.To = endLocation; topAnimation.Duration = this.reportGrid.Duration; this.storyline.Children.Add(topAnimation); } else { if (reportRow.HasAnimatedProperties) { reportRow.ApplyAnimationClock(ReportRow.ActualTopProperty, null); } reportRow.ActualTop = reportRow.Top; } } // If the height occupied by this row has changed then an animation sequence is constructed to resize the row. If the row isn't visible or // is not going to be visible, then the property is modified without an animation sequence. This saves the processor from doing work when // an element isn't visible. if (reportRow.Height != rowTemplate.Height) { // This sets the height of the row. reportRow.Height = rowTemplate.Height; // This will animate the change in the row's height from the current height to the new target height. if (isRowVisible || willRowBeVisible) { DoubleAnimation heightAnimation = new DoubleAnimation(); Storyline.SetTargetObject(heightAnimation, reportRow); Storyline.SetTargetProperty(heightAnimation, ReportRow.ActualHeightProperty); heightAnimation.From = reportRow.ActualHeight; heightAnimation.To = reportRow.Height; heightAnimation.Duration = this.reportGrid.Duration; this.storyline.Children.Add(heightAnimation); } else { if (reportRow.HasAnimatedProperties) { reportRow.ApplyAnimationClock(ReportRow.ActualHeightProperty, null); } reportRow.ActualHeight = reportRow.Height; } } } // A virtual method is used to copy the current content over the existing content. The event handlers will take // care of propagating the content and properties of the data to the screen elements. reportRow.IContent.Copy(iContent); // This indicates that the row is still in use and shouldn't be purged. reportRow.IsObsolete = false; } else { // This is where new rows are created to hold the given content and added to the report. reportRow = new ReportRow(); reportRow.IContent = iContent; this.dictionary.Add(iContent.Key, reportRow); // The order of the row in the report drives visual cues such as alternate line shading and Z order properties. reportRow.Ordinal = this.ordinal; // The target location and height are initialized here without animation. reportRow.Top = this.height; reportRow.Height = rowTemplate.Height; // The actual top and height used when rendering the rows. reportRow.ActualTop = reportRow.Top; reportRow.ActualHeight = reportRow.Height; // Rows that are added to the visible portion of the display will trigger the 'MeasureOverride' which will instantiate the new report elements. if ((this.viewport.Top <= reportRow.Top && reportRow.Top < this.viewport.Bottom) || (this.viewport.Top <= reportRow.Top + reportRow.Height && reportRow.Top + reportRow.Height < this.viewport.Bottom)) { this.isMeasurementRequired = true; } // The report row is really just a container for report cells. The System.Reflection library is used to rip apart the content and create // columns that are tightly bound to the type of data found in the incoming record. foreach (PropertyInfo propertyInfo in iContent.GetType().GetProperties()) { IContent childContent = propertyInfo.GetValue(iContent, null) as IContent; if (childContent != null) { string columnId; if (this.reportGrid.reportFieldCollection.ColumnIdMap.TryGetValue(childContent.GetType(), out columnId)) { ReportColumn reportColumn; if (this.reportGrid.reportColumnCollection.TryGetValue(columnId, out reportColumn)) { reportRow.Add(reportColumn, new ReportCell(childContent, reportColumn, reportRow)); } } } } } // This is used to keep track of the order of the row in the report. this.ordinal++; // This moves the virtual cursor up to the next available row in the virtual space. this.height += reportRow.Height; // The report can have any number of levels in the hierarchical arrangment or the rows. This will recurse into the template that defines the // outline of the report and generate any rows that can be matched to the templates that are children of the current template. The 'Path' property // on the template rows indicate which properties of the content row to follow when recursing. foreach (RowTemplate childRowDefinition in rowTemplate.Children) { PropertyInfo propertyInfo = iContent.GetType().GetProperty(childRowDefinition.Path); if (propertyInfo != null) { Object property = propertyInfo.GetValue(iContent, null); if (property is IEnumerable) { IEnumerable iEnumerable = property as IEnumerable; foreach (IContent childContent in iEnumerable) { RecursivelyUpdateRow(childContent, childRowDefinition); } } } } }
/// <summary> /// Sets the content that is displayed in the report. /// </summary> /// <param name="iContent">The data that is displayed in this report.</param> private Storyline FirstSegmentSetContent(Object sender, GenericEventArgs genericEventArgs) { // Extract the arguments for this animation from the current command on the queue. IContent iContent = (IContent)genericEventArgs.Arguments[0]; Duration duration = (Duration)genericEventArgs.Arguments[1]; // These fields keeps track of all the things that can change while recursing into the report hierarchy. this.animatedRows = new List <ReportRow>(); this.height = 0.0; this.isMeasurementRequired = false; this.ordinal = 0; this.viewport = this.reportGrid.reportCanvases[3].Viewport; // Updating a report can generate many animation effects: moving rows from one place to another, resizing them, etc. All these effects must be // driven of the same clock or the effect gets jumpy and hard to follow. The Storyline is nearly identical to a ParallelTimeline except that it // has some Attached properties to specify the target object and property and some methods to synchronize them all. this.storyline = new Storyline(); // This will find the root template for the report and start the recursive process that will expand the report hierarchy according to the structure // found in the XAML source. if (this.reportGrid.RowTemplates.Count > 0) { RecursivelyUpdateRow(iContent, this.reportGrid.RowTemplates[0]); } // When animating a large group of objects it is important to bring the objects to the front of the ZIndex that move the farthest. The ones that // move the least can appear behind the others. This allows the eye to follow the objects with the greatest amount of movement. foreach (ReportCanvas reportCanvas in this.reportGrid.reportCanvases) { reportCanvas.SetZIndex(this.animatedRows); } // When the recursion is finished and the report has been completely expanded, the running height variable that was used for the location of each // row can now be used as the height of the entire collection. Note that an internal method is used to set the value. Anyone can get the value of // the virtual height, but only this object can set it. this.SetValue(ReportRowCollection.HeightProperty, this.height); // A unique key is used to identify each row so it can persist from one update to the next. Purging rows that are no longer part of the content is // done by marking all of the persistent rows with an 'IsObsolete' flag. If a row persists from one update to the next, then this flag will be // reset as the data is transferred from the new content. If this flag is still set after the recursive update, it means that there is no // corresponding row in the new content and it should be removed from the report. Note that after the test is made for obsolescence, the flag // is reset for the next pass. This saves doing an extra iteration through all the rows on the next full content set. List <ReportRow> deletedRows = new List <ReportRow>(); foreach (ReportRow reportRow in this) { if (reportRow.IsObsolete) { if ((this.viewport.Top <= reportRow.Top && reportRow.Top < this.viewport.Bottom) || (this.viewport.Top <= reportRow.Top + reportRow.Height && reportRow.Top + reportRow.Height < this.viewport.Bottom)) { this.isMeasurementRequired = true; } deletedRows.Add(reportRow); } else { reportRow.IsObsolete = true; } } // The dictionary that holds the mappings between the content keys and the report rows can't be purged in the loop abovce because that would modify // the collection, so they need to be put into a temporary buffer and then they can be removed. foreach (ReportRow reportRow in deletedRows) { this.dictionary.Remove(reportRow.IContent.Key); foreach (ReportCanvas reportCanvas in this.reportGrid.reportCanvases) { reportCanvas.Remove(reportRow); } } // If any rows are added or removed from the viewport then the "MeasureOverride" will need to remove the obsolete graphic elements and add the new // ones using the virtual space layout computed here. if (this.isMeasurementRequired) { this.reportGrid.InvalidateMeasure(); } // The next TimelineSegment in the queue will be executed when this Timeline is finished. In this way, actions that // take a finite amount of time can be executed in an orderly sequence. return(this.storyline); }
public static StorylineEditor OpenWindow(Storyline target) { return(OpenWindow(target, "Storyline", true, typeof(SceneView))); }
public Task <DiagramViewModel> GetDiagramViewModelAsync(Guid id) { var dumas = new Author() { Name = "Alexandre Dumas" }; var edmond = new Character() { Name = "Edmond Dantés" }; edmond.Aliases.Add(new Alias() { Name = "Count of Monte Christo" }); edmond.Aliases.Add(new Alias() { Name = "Sinbad the Sailor" }); edmond.Aliases.Add(new Alias() { Name = "Abbé Busoni" }); edmond.Aliases.Add(new Alias() { Name = "Lord Wilmore" }); edmond.Authors.Add(dumas); var louis = new Character() { Name = "Louis Dantés" }; louis.Authors.Add(dumas); var mercedes = new Character() { Name = "Mercédès" }; mercedes.Aliases.Add(new Alias() { Name = "Countess Mercédès Mondego" }); mercedes.Aliases.Add(new Alias() { Name = "Mlle de Morcerf" }); mercedes.Authors.Add(dumas); var fernand = new Character { Name = "Fernand Mondego" }; fernand.Aliases.Add(new Alias() { Name = "Count de Morcerf" }); fernand.Authors.Add(dumas); var albert = new Character { Name = "Albert de Morcerf" }; albert.Authors.Add(dumas); var haydee = new Character { Name = "Haydée" }; haydee.Authors.Add(dumas); edmond.RelateTo(louis, "son of", true); edmond.RelateTo(mercedes, "engaged"); edmond.RelateTo(haydee, "owns", true); edmond.RelateTo(haydee, "loves"); mercedes.RelateTo(fernand, "married"); mercedes.RelateTo(albert, "mother of", true); fernand.RelateTo(albert, "father of", true); albert.RelateTo(edmond, "challenges to a duel", true); haydee.RelateTo(fernand, "exposes", true); var betrayal = new Storyline() { Name = "The Betrayal of Ali Pasha", Description = "Lorem Ipsum etc.", }; betrayal.Authors.Add(dumas); betrayal.Characters.Add(fernand); betrayal.Characters.Add(haydee); var haydeesIdentity = new PlotElement() { Name = "Haydée is Ali Pasha's daughter", Description = "Ali Pasha's daughter was sold into slavery and, after the death of her mother, the only surviving person to know of Ali's betrayer." }; haydeesIdentity.OwningCharacters.Add(haydee); var alisBetrayer = new PlotElement() { Name = "Fernand betrayed and murdered Ali Pasha.", Description = "Fernand was the officer who betrayed and murdered Ali Pasha. If this became public, it would cause a scandal." }; alisBetrayer.OwningCharacters.Add(fernand); alisBetrayer.NeedingCharacters.Add(haydee); betrayal.PlotElements.Add(haydeesIdentity); betrayal.PlotElements.Add(alisBetrayer); var diagram = new Diagram() { Name = "The Count of Monte Cristo" }; diagram.Characters.Add(edmond); diagram.Characters.Add(louis); diagram.Characters.Add(mercedes); diagram.Characters.Add(fernand); diagram.Characters.Add(albert); diagram.Characters.Add(haydee); diagram.Authors.Add(dumas); diagram.Storylines.Add(betrayal); diagram.PlotElements.Add(alisBetrayer); diagram.PlotElements.Add(haydeesIdentity); return(Task.FromResult(new DiagramViewModel(diagram))); }