Exemplo n.º 1
0
    /// <summary>Populate the narrative panel with the given data object.</summary>
    /// <param name="panelInfo">Data needed for a branch panel.</param>
    private void PopulateBranchPanel(BranchPanelInfo panelInfo)
    {
        // Get relevant properties
        var mergeProp = panelInfo.Properties.GetOrDefault(Property.Merge, "true");

        _ = bool.TryParse(mergeProp, out bool merge);
        var interruptProp = panelInfo.Properties.GetOrDefault(Property.Interrupt, "false");

        _ = bool.TryParse(interruptProp, out bool interrupt);
        var splitProp = panelInfo.Properties.GetOrDefault(Property.Split, "true");

        _ = bool.TryParse(splitProp, out bool canSplitParty);

        var conditionalBranches = new List <ConditionalBranch>();

        foreach (var branchData in panelInfo.Branches)
        {
            var branch = new Branch {
                PlaybackOrder = branchData.playbackOrder
            };
            branch.OnBranch.AddListener(players => StoryboardQueue.Enqueue(branchData.next, players, interrupt, merge));
            conditionalBranches.Add(new ConditionalBranch {
                Condition = branchData.condition,
                Data      = branch
            });
        }

        branchPanel.BranchControl.CanSplitParty       = canSplitParty;
        branchPanel.BranchControl.ConditionalBranches = conditionalBranches;
    }
Exemplo n.º 2
0
    /// <summary>Populate the decision panel with the given data object.</summary>
    /// <param name="panelInfo">Data needed for a decision panel.</param>
    private void PopulateDecisionPanel(DecisionPanelInfo panelInfo)
    {
        // Get relevant properties
        var mergeProp = panelInfo.Properties.GetOrDefault(Property.Merge, "true");

        _ = bool.TryParse(mergeProp, out bool merge);
        var interruptProp = panelInfo.Properties.GetOrDefault(Property.Interrupt, "false");

        _ = bool.TryParse(interruptProp, out bool interrupt);

        // Clear out existing options.
        decisionPanel.Control.Decisions.Clear();
        foreach (var decisionData in panelInfo.Decisions)
        {
            // Create a concrete panel decision from the given data.
            var branch = new Branch(
                decisionData.order,
                players => StoryboardQueue.Enqueue(decisionData.next, players, interrupt, merge)
                );
            var panelDecision = new DecisionControlData {
                OptionText = decisionData.text,
                Condition  = decisionData.condition,
                Data       = branch
            };
            // Add to the decision list.
            decisionPanel.Control.Decisions.Add(panelDecision);
        }
    }
Exemplo n.º 3
0
        /// <summary>
        /// Reveals data points using a storyboard.
        /// </summary>
        /// <param name="dataPoints">The data points to change the state of.
        /// </param>
        /// <param name="dataPointCount">The number of data points in the sequence.</param>
        /// <param name="newState">The state to change to.</param>
        private void StaggeredStateChange(IEnumerable <DataPoint> dataPoints, int dataPointCount, DataPointState newState)
        {
            if (PlotArea == null || dataPointCount == 0)
            {
                return;
            }

            Storyboard stateChangeStoryBoard = new Storyboard();

            dataPoints.ForEachWithIndex((dataPoint, count) =>
            {
                // Create an Animation
                ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
                Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
                Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, new PropertyPath("State"));

                // Create a key frame
                DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
                discreteObjectKeyFrame.Value = newState;

                // Create the specified animation type
                switch (AnimationSequence)
                {
                case AnimationSequence.Simultaneous:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.Zero;
                    break;

                case AnimationSequence.FirstToLast:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPointCount));
                    break;

                case AnimationSequence.LastToFirst:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPointCount - count - 1) / dataPointCount));
                    break;
                }

                // Add the Animation to the Storyboard
                objectAnimationUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame);
                stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
            });
            stateChangeStoryBoard.Duration = new Duration(AnimationSequence.Simultaneous == AnimationSequence ?
                                                          TimeSpan.FromTicks(1) :
                                                          TimeSpan.FromMilliseconds(1001));

            _storyBoardQueue.Enqueue(
                stateChangeStoryBoard,
                (sender, args) =>
            {
                stateChangeStoryBoard.Stop();
            });
        }
        /// <summary>
        /// Reveals data points using a storyboard.
        /// </summary>
        /// <param name="dataPoints">The data points to change the state of.
        /// </param>
        /// <param name="newState">The state to change to.</param>
        private void StaggeredStateChange(IList <DataPoint> dataPoints, DataPointState newState)
        {
            if (PlotArea == null || dataPoints.Count == 0)
            {
                return;
            }

            string     guid = Guid.NewGuid().ToString();
            Storyboard stateChangeStoryBoard = new Storyboard();

            stateChangeStoryBoard.Completed +=
                (sender, args) =>
            {
                PlotArea.Resources.Remove(guid);
            };

            dataPoints.ForEachWithIndex((dataPoint, count) =>
            {
                // Create an Animation
                ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
                Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
                Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, new PropertyPath("State"));

                // Create a key frame
                DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
                discreteObjectKeyFrame.Value = newState;

                // Create the specified animation type
                switch (AnimationSequence)
                {
                case AnimationSequence.Simultaneous:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.Zero;
                    break;

                case AnimationSequence.FirstToLast:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPoints.Count));
                    break;

                case AnimationSequence.LastToFirst:
                    discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPoints.Count - count - 1) / dataPoints.Count));
                    break;
                }

                // Add the Animation to the Storyboard
                objectAnimationUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame);
                stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
            });

            _storyBoardQueue.Enqueue(stateChangeStoryBoard);
        }
Exemplo n.º 5
0
 public void EnqueueUri(List <int> owningPlayers) => StoryboardQueue.Enqueue(Uri, owningPlayers, Interrupt, Merge);
Exemplo n.º 6
0
 public void EnqueueUri() => StoryboardQueue.Enqueue(Uri, Interrupt, Merge);
Exemplo n.º 7
0
 public void EnqueueBoard(List <int> owningPlayers) => StoryboardQueue.Enqueue(StoryboardPrefab, owningPlayers, Interrupt, Merge);
Exemplo n.º 8
0
 public void EnqueueBoard() => StoryboardQueue.Enqueue(StoryboardPrefab, Interrupt, Merge);
Exemplo n.º 9
0
 /// <summary>
 /// Adds a new instantiation of the referenced storyboard to the queue.
 /// </summary>
 /// <param name="players">A list of all players (by number) that should own the new board.</param>
 /// <param name="storyboard">A GameObject with the Storyboard component.</param>
 public void Queue(List <int> players, Storyboard storyboard)
 {
     StoryboardQueue.Enqueue(storyboard, players);
 }