public ChoiceMadeEvent(Guid gameId, int round, string playerId, Choice choice)
 {
     GameId = gameId;
     Round = round;
     PlayerId = playerId;
     Choice = choice;
 }
Example #2
0
        public void ReturnResult(Choice c, Result expected)
        {
            Game newGame = new Game();

            AlwaysPaperPlayer p1 = new AlwaysPaperPlayer("Paperboy");

            Player p2;

            switch (c)
            {
                case Choice.Paper:
                    p2 = new AlwaysPaperPlayer("Pboy2");
                    break;
                case Choice.Rock:
                    p2 = new AlwaysRockPlayer("Rockboy");
                    break;
                default:
                    p2 = new AlwaysScissorsPlayer("Edward");
                    break;

            }

            Result result = newGame.PlayRound(p1, p2);

            Assert.AreEqual(expected, result);
        }
        public OptimizationSettings()
        {
            this.commands = new ArrayListDataSet(this);

            //save command
            Command saveCmd = new Command();
            saveCmd.Description = "Save";
            saveCmd.Invoked += new EventHandler(saveCmd_Invoked);
            this.commands.Add(saveCmd);

            //cancel command
            Command cancelCmd = new Command();
            cancelCmd.Description = "Cancel";
            cancelCmd.Invoked += new EventHandler(cancelCmd_Invoked);
            this.commands.Add(cancelCmd);

            this.aMPM = new Choice(this);
            List<string> ampmlist = new List<string>();
            ampmlist.Add("AM");
            ampmlist.Add("PM");
            this.aMPM.Options = ampmlist;

            this.enableOptimization = new BooleanChoice(this);
            this.enableOptimization.Description = "Perform Optimization";
            this.enableOptimization.Value = true;
            this.optimizeNow = new Command();
            this.optimizeNow.Description = "Optimize Now";

            this.optimizationHour = new EditableText(this);
            this.optimizationHour.Value = "4";
            this.optimizationMinute = new EditableText(this);
            this.optimizationMinute.Value = "00";
        }
Example #4
0
    public static bool EditChoice(Dictionary<string, object> arguments)
    {
        Choice choice = new Choice();

        try
        {
            choice.choice = arguments["choice"].ToString();
            choice.Id = Convert.ToInt32(arguments["choice_id"]);
        }
        catch (Exception)
        {
            return false;
        }

        int surveyID = Convert.ToInt32(arguments["surveyID"]);
        int pollID = Convert.ToInt32(arguments["poll_id"]);

        (HttpContext.Current.Session["survey_" + surveyID] as Survey).Polls
            .Find(delegate(Poll curPoll) { return curPoll.Id == pollID; }).Choices
            .ForEach(delegate(Choice curChoice)
            {
                if (curChoice.Id == choice.Id)
                {
                    curChoice.choice = choice.choice;
                }
            });

        return true;
    }
Example #5
0
        public static Task Task(this string task, Choice? correct = null)
        {
            var rawProblem = task.Split(new[] { " A. " }, StringSplitOptions.RemoveEmptyEntries).First();
            var rawSolution = " A. " + task.Split(new[] { " A. " }, StringSplitOptions.RemoveEmptyEntries).Last();

            var rawSolutionTexts = rawSolution
                .Split(new[] { " A. ", " B. ", " C. ", " D. ", " E. " }, StringSplitOptions.RemoveEmptyEntries)
                .Where(text => !String.IsNullOrWhiteSpace(text))
                .ToArray();

            var rawSolutionChoices = Regex.Matches(rawSolution, @"[A-E]{1}\.\ ");

            var tmp = (from Match rawSolutionChoice in rawSolutionChoices select rawSolutionChoice.Value.ParseChoice()).ToList().Distinct().ToList();

            var choiceDictionary = new Dictionary<Choice, string>();
            for (var i = 0; i < rawSolutionTexts.Length; i++)
            {
                choiceDictionary.Add(tmp[i], rawSolutionTexts[i]);
            }

            return new Task
            {
                Category = Category.NotSet,
                Number = task.TaskNumber(),
                Problem = new Problem { Text = Regex.Replace(rawProblem, @"^[0-9]+\.\ +", "") },
                Solution = new SelectableSolution
                {
                    Choices = choiceDictionary,
                    Correct = new[] { correct ?? Choice.A }.ToList() }
            };
        }
Example #6
0
File: Questions.cs Project: 3-n/saq
 public DisplayChoiceData(ChoiceData choiceData, Choice? usersChoice)
 {
     Choice = choiceData.Choice;
     Text = choiceData.Text;
     IsCorrect = choiceData.IsCorrect;
     UsersChoice = usersChoice;
 }
        public ExtenderSettings()
        {
            this.commands = new ArrayListDataSet(this);

            //save command
            Command saveCmd = new Command();
            saveCmd.Description = "Save";
            saveCmd.Invoked += new EventHandler(saveCmd_Invoked);
            this.commands.Add(saveCmd);

            //cancel command
            Command cancelCmd = new Command();
            cancelCmd.Description = "Cancel";
            cancelCmd.Invoked += new EventHandler(cancelCmd_Invoked);
            this.commands.Add(cancelCmd);

            this.goToImpersonation = new Command();
            this.goToImpersonation.Description = "Impersonation";
            this.goToImpersonation.Invoked += new EventHandler(goToImpersonation_Invoked);

            this.goToTranscode = new Command();
            this.goToTranscode.Description = "Transcoding";
            this.goToTranscode.Invoked += new EventHandler(goToTranscode_Invoked);

            this.transcodingDelays = new Choice(this);

            this.SetupTranscodingOptions();
            this.SetupImpersonation();
            this.SetupTranscodingDelays();
        }
        public BackgroundSettings()
        {
            this.commands = new ArrayListDataSet(this);

            //save command
            Command saveCmd = new Command();
            saveCmd.Description = "Save";
            saveCmd.Invoked += new EventHandler(saveCmd_Invoked);
            this.commands.Add(saveCmd);

            //cancel command
            Command cancelCmd = new Command();
            cancelCmd.Description = "Cancel";
            cancelCmd.Invoked += new EventHandler(cancelCmd_Invoked);
            this.commands.Add(cancelCmd);

            this.transparancyOptions = new Choice(this);
            this.SetupTransparancyOptions();
            this.transparancyOptions.ChosenChanged += new EventHandler(transparancyOptions_ChosenChanged);

            this.rotationOptions = new Choice(this);
            this.SetupRotationOptions();

            this.enableCustomBackground = new BooleanChoice(this);
            this.enableCustomBackground.Description = "Enable Custom Background";
            this.enableCustomBackground.Value = Properties.Settings.Default.EnableMainPageBackDrop;
        }
    Temp()
    {
        topic = new List<DialogueNode>();

        topic.Add(new DialogueLine(0, "Hello"));
        topic.Add(new DialogueLine(1, "Mornin'"));
        topic.Add(new DialogueLine(0, "Who stole the cookie from the cookie jar?"));
        topic.Add(new DialogueLine(1, "You stole the cookie from the cookie jar.")); // id = 3
        topic.Add(new DialogueLine(0, "Who me?"));
        topic.Add(new DialogueLine(1, "Yes, you!"));
        topic.Add(new DialogueLine(0, "Couldn't be!"));
        topic.Add(new DialogueLine(1, "Then who?"));

        DialogueChoice dc = new DialogueChoice();
        Choice c = new Choice();
        c.SetText("No idea.");
        c.AddOutcome(new OutcomeJump(3));
        dc.AddChoice(c);
        c = new Choice();
        c.AddOutcome(new OutcomeMood(0, -10));
        c.SetText("I lied, it was me actually."); // Choices CAN have no outcome, dialogue continues from next line
        dc.AddChoice(c);
        c = new Choice();
        c.AddOutcome(new OutcomeEnd());
        c.SetText("*Run Away*");
        dc.AddChoice(c);

        topic.Add(dc);

        topic.Add(new DialogueLine(1, "As expected, I'll be a master detective in no time."));
        topic.Add(new DialogueLine(0, "A master without cookies that is."));
    }
 public void Choice_WhenCreated_OneChoiceInTheTable()
 {
     var choice = new Choice() { Label = "label", Value  = 10};
     db.Choices.InsertOnSubmit(choice);
     db.SubmitChanges();
     Assert.AreEqual(1, db.Choices.Count());
 }
Example #11
0
        public Setup()
        {
            LoadPlugins();
            AllTitlesProcessed = false;
            CurrentTitle = null;
            CurrentTitleIndex = 0;
            current = this;
            //_titleCollection.loadTitleCollection();
            _ImporterSelection = new Choice();
            List<string> _Importers = new List<string>();
            foreach (OMLPlugin _plugin in availablePlugins) {
                OMLApplication.DebugLine("[Setup] Adding " + _plugin.Name + " to the list of Importers");
                _Importers.Add(_plugin.Description);
            }

            _ImporterSelection.Options = _Importers;
            _ImporterSelection.ChosenChanged += delegate(object sender, EventArgs e)
            {
                OMLApplication.ExecuteSafe(delegate
                {
                    Choice c = (Choice)sender;
                    ImporterDescription = @"Notice: " + GetPlugin().SetupDescription();
                    OMLApplication.DebugLine("Item Chosed: " + c.Options[c.ChosenIndex]);
                });
            };
        }
Example #12
0
	void Awake(){
		paragraph = Game_Controller.a.getParagraph();
		PRG_Controller = gameObject.GetComponentInChildren<Question> ();
		PRG_STSC = gameObject.GetComponentInChildren<Choice> ();
		textCheck = (Typing_Input)FindObjectOfType (typeof(Typing_Input));
		realStatus (Game_Controller.gameDiff);
		textTyping = GetComponentsInChildren<TextMesh> ();
	}
Example #13
0
	void Awake(){
		setOfQuiz = Game_Controller.a.getQuestionAndAns();
		QnTPn = gameObject.GetComponentInChildren<Question> ();
		QnTPnC = gameObject.GetComponentInChildren<Choice> ();
		textCheck = (Typing_Input)FindObjectOfType (typeof(Typing_Input));
		realStatus (Game_Controller.gameDiff);
		textTyping = GetComponentsInChildren<TextMesh> ();
	}
Example #14
0
 public void Copy(Choice original)
 {
     wording = original.wording;
     lineReference = original.lineReference;
     actions = original.actions;
     reputations  = original.reputations;
     conversation  = original.conversation;
 }
Example #15
0
 void AssignChoice(Choice choice)
 {
     if (choice.direction == Choice.Direction.Left) {
       leftChoice = choice;
     } else {
       rightChoice = choice;
     }
 }
Example #16
0
        public static Choice GetWinner(Choice probablePlayerChoice)
        {
            if (probablePlayerChoice == Choice.scissors)
              {
            return Choice.rock;
              }

              return probablePlayerChoice + 1;
        }
Example #17
0
File: Choice.cs Project: britg/ptq
    public static Choice SwipeRight(string key, string label)
    {
        var c = new Choice();
        c.key = key;
        c.label = label;
        c.direction = Direction.Right;

        return c;
    }
	public void Submit(string choice)
	{
		if (choices.ContainsKey(choice))
		{
			ChoiceMade = choices[choice];
			GameToolBox.Instance.uiGameObject.multipleChoiceTrigger.GetComponent<MultipleChoicesUI>().Enable(false);
			ExecutePostTriggerObject();
		}
	}
 public void Question_CanHaveOneChoice()
 {
     var question = new Question() { QuestionText = "Question Text", QuestionCategory = "Category" };
     var choice = new Choice() { Label = "label", Value = -1 };
     var questionchoice = new QuestionChoice() { Question = question, Choice = choice, SortOrder = 1 };
     db.Questions.InsertOnSubmit(question);
     db.Choices.InsertOnSubmit(choice);
     db.QuestionChoices.InsertOnSubmit(questionchoice);
     Assert.AreEqual(1, question.QuestionChoices.Count);
 }
Example #20
0
    public bool Equals(Choice other)
    {
        if (other == null)
            return false;

        if (this._choiceName == other._choiceName)
            return true;
        else
            return false;
    }
        public AboutSettings()
        {
            System.Resources.ResourceManager RM = new System.Resources.ResourceManager("Library.Resources",System.Reflection.Assembly.GetExecutingAssembly());
            string creditsString = (string)RM.GetObject("Credits");
            byte[] byteArray = Encoding.ASCII.GetBytes(creditsString);
            MemoryStream stream = new MemoryStream(byteArray);
            //XmlTextReader reader = new XmlTextReader(stream);
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(stream);
            XPathNavigator nav = xDoc.CreateNavigator();
            XPathNodeIterator it = nav.Select("Credits/Developers/Person");

            this.CreditsText = "DEVELOPMENT TEAM:";
            while (it.MoveNext())
            {
                this.CreditsText += "\n" + it.Current.Value;
            }
            this.CreditsText += "\n\n";
            it = nav.Select("Credits/Contributors/Person");

            this.CreditsText += "COMPANIES AND INDIVIDUALS:";
            while (it.MoveNext())
            {
                this.CreditsText += "\n" + it.Current.Value;
            }
            this.CreditsText += "\n\n";
            it = nav.Select("Credits/Special/Person");

            this.CreditsText += "SPECIAL THANKS:";
            while (it.MoveNext())
            {
                this.CreditsText += "\n" + it.Current.Value;
            }

            string version=Assembly.GetExecutingAssembly().GetName().Version.ToString();

            this.AboutText = "Open Media Library (replace with image)\n\nVersion: " + version + " (Revision: " + OMLApplication.Current.RevisionNumber+")";
            this.AboutText += "\nCopyright © 2008, GNU General Public License v3";

            this.radioCommands = new Choice(this);
            ArrayListDataSet radioSet = new ArrayListDataSet();

            Command aboutCmd=new Command(this);
            aboutCmd.Description="About";
            radioSet.Add(aboutCmd);

            Command creditsCmd = new Command(this);
            creditsCmd.Description = "Credits";
            radioSet.Add(creditsCmd);

            //this.CreditsText = "this is a credit";

            this.radioCommands.Options = radioSet;
            this.radioCommands.ChosenChanged += new EventHandler(radioCommands_ChosenChanged);
        }
Example #22
0
 public Dialogue(int _id, string _text, Choice[] _choices = null, ChoiceEventArgs _CEA = null, string b = null, string db = null)
 {
     iD = _id;
     text = _text;
     choices = _choices;
     setbool = b;
     setDayBool = db;
     if (_CEA != null)
     {
         CEA = _CEA;
         Action += _CEA.ChoiceAction;
     }
 }
Example #23
0
        private void configureGraphDataNEW(Choice choice, Color c)
        {
            Series seriesLines;
            

            switch (choice)
            {
                case Choice.RPM:
                    seriesLines = _graph.Series.Add("RPM");
                    seriesLines.YValueMembers = "RPM";
                    break;
                case Choice.SPEED:
                    seriesLines = _graph.Series.Add("SPEED");
                    seriesLines.YValueMembers = "SPEED";
                    break;
                case Choice.DISTANCE:
                    seriesLines = _graph.Series.Add("DISTANCE");
                    seriesLines.YValueMembers = "DISTANCE";
                    break;
                case Choice.ACT_POWER:
                    seriesLines = _graph.Series.Add("ACT_POWER");
                    seriesLines.YValueMembers = "ACT_POWER";
                    break;
                case Choice.ENERGY:
                    seriesLines = _graph.Series.Add("ENERGY");
                    seriesLines.YValueMembers = "ENERGY";
                    break;
                case Choice.PULSE:
                    seriesLines = _graph.Series.Add("PULSE");
                    seriesLines.YValueMembers = "PULSE";
                    break;
                default:
                    seriesLines = _graph.Series.Add("Unknown");
                    seriesLines.YValueMembers = "DATE";
                    break;
            }
            
            seriesLines.XValueMember = "DATE";
            
            seriesLines.IsValueShownAsLabel = true;
            int i = _graph.ChartAreas.Count - 1;
            _graph.ChartAreas[i].AxisX.LabelStyle.Format = "HH:mm:ss";
            _graph.ChartAreas[i].AxisX.IsMarginVisible = true;
            //_graph.ChartAreas[i].AxisX.LabelStyle.Interval = 1;

            seriesLines.XValueType = ChartValueType.Time;
            
            seriesLines.Color = c;
            seriesLines.ChartType = SeriesChartType.Line;
        }
Example #24
0
            private void Execute(TurnContext context, Choice choice)
            {
                switch (choice)
                {
                    case Choice.DrawCards:
                        context.ActivePlayer.DrawCards(3);
                        return;
                    case Choice.GainActions:
                        context.RemainingActions += 2;
                        return;
                }

                string error = string.Format("Choice of '{0}' invalid. ChoiceActivity shouldn't have allowed this to be called", choice);
                throw new Exception(error);
            }
        /// <summary>
        /// Gets all the possible choices for the current dialogue node
        /// </summary>
        /// <returns>An array of type Choice containing all the possible choices</returns>
        public Choice[] GetChoices()
        {
            List<Choice> choices = new List<Choice>();

            foreach (int id in dialogueLines[currentIndex].output)
            {
                Choice c = new Choice();
                c.id = id;
                c.dialogue = dialogueLines[id].dialogue;
                c.speaker = dialogueLines[id].speaker;
                c.userData = dialogueLines[id].userData;
                choices.Add(c);
            }

            return choices.ToArray();
        }
        public override IEffectHandle GetHandle(IGame game)
        {
            var startingHand = Player.Hand.Cards.ToList();
            //var choice = new ChooseToKeepStartingHand("If a player does not wish to keep their starting hand, they may take a single mulligan, by shuffling those 6 cards back into their deck and drawing 6 new cards.", game, Player, startingHand);

            var answers = new List<IAnswer>();
            answers.Add(new Answer<IGame, bool>("Yes, I want to keep my starting hand", game, true, (source, handle, item) => KeepStartingHand(handle)));
            answers.Add(new Answer<IGame, bool>("No, I will take a mulligan and draw a new starting hand", game, false, (source, handle, item) => DrawNewStartingHand(handle)));

            var text = string.Format("{0}, do you want to keep your starting hand?", Player.Name);
            var question = new Question<IGame>(text, game, Player, answers);

            var choice = new Choice<IGame>("If a player does not wish to keep their starting hand, they may take a single mulligan, by suffling those 6 cards back into their deck and drawing 6 new cards.", game, question);

            return new EffectHandle(this, choice);
        }
Example #27
0
		public override void Play(Player player)
		{
			base.Play(player);

			Choice choiceCard = new Choice("Reveal a card from your hand to return up to 2 to the Supply.", this, player.Hand, player);
			ChoiceResult resultCard = player.MakeChoice(choiceCard);

			if (resultCard.Cards.Count > 0)
			{
				Card revealedCard = resultCard.Cards[0];
				player.AddCardInto(DeckLocation.Revealed, player.RetrieveCardFrom(DeckLocation.Hand, revealedCard));
				player.AddCardInto(DeckLocation.Hand, player.RetrieveCardFrom(DeckLocation.Revealed, revealedCard));

				Supply supply = player._Game.Table.FindSupplyPileByCard(revealedCard);
				if (supply != null)
				{
					List<String> options = new List<string>() { "0", "1" };
					if (player.Hand[revealedCard.CardType].Count > 1)
						options.Add("2");
					Choice choice = new Choice("How many would you like to return to the Supply?", this, new CardCollection() { revealedCard }, options, player);
					ChoiceResult result = player.MakeChoice(choice);

					int numberToReturn = int.Parse(result.Options[0]);
					if (numberToReturn > 0)
					{
						CardCollection cardsToReturn = player.RetrieveCardsFrom(DeckLocation.Hand, revealedCard.CardType, numberToReturn);
						player.Lose(cardsToReturn);
						supply.AddTo(cardsToReturn);
					}

					player._Game.SendMessage(player, this, supply, numberToReturn);
				}

				IEnumerator<Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);
				enumerator.MoveNext();
				while (enumerator.MoveNext())
				{
					Player attackee = enumerator.Current;
					// Skip if the attack is blocked (Moat, Lighthouse, etc.)
					if (this.IsAttackBlocked[attackee])
						continue;

					if (supply != null && supply.CanGain() && supply.TopCard.Name == revealedCard.Name)
						attackee.Gain(supply);
				}
			}
		}
Example #28
0
    public int CompareTo(Choice a, Choice b)
    {
        if (a == Choice.NULL || b == Choice.NULL)
            return 0;

        if (a == b)
            return 0;

        if (a == Choice.PIERRE)
            return (b == Choice.FEUILLE) ? -1 : 1;

        if (a == Choice.FEUILLE)
            return (b == Choice.CISEAUX) ? -1 : 1;

        //if (a == Choice.CISEAUX)
            return (b == Choice.PIERRE) ? -1 : 1;
    }
Example #29
0
		public override void Play(Player player)
		{
			base.Play(player);
			player.Draw(3, DeckLocation.Revealed);

			IEnumerator<Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player);
			enumerator.MoveNext(); // Gets us... which we don't care about here.
			enumerator.MoveNext(); // Get the player to our left

			Player leftPlayer = enumerator.Current;
			Choice choice = new Choice(String.Format("Choose a card of {0}'s to discard", player), this, player.Revealed, player);
			ChoiceResult result = leftPlayer.MakeChoice(choice);
			// Discard the chosen card
			if (result.Cards.Count > 0)
				player.Discard(DeckLocation.Revealed, result.Cards[0]);
			player.AddCardsToHand(DeckLocation.Revealed);
		}
Example #30
0
    protected void OnItemCommandOccur(object sender, ListViewCommandEventArgs e)
    {
        try
        {
            SaveChanges();
            switch (e.CommandName)
            {
                case "AddItem":
                    Choice choice = new Choice(((TextBox)poll.FindControl("newAnswerTextBox")).Text);
                    choice.Id = GenerateChoiceID();
                    ((TextBox)poll.FindControl("newAnswerTextBox")).Text = String.Empty;
                    choices.Add(choice);
                    enableButtons = (choices.Count > 2) ? true : false;
                    BindData();
                    break;
                case "RemoveItem":
                    choices.Remove(choices.Find(delegate(Choice curChoice) { return curChoice.Id == Convert.ToInt32(e.CommandArgument); }));
                    enableButtons = (choices.Count > 2) ? true : false;
                    BindData();
                    break;
                case "SubmitWidget":
                    string question = ((TextBox)poll.FindControl("questionTextBox")).Text;
                    if (question == String.Empty)
                    {
                        throw new Exception("Question field can't be empty");
                    }

                    Poll newPoll = new Poll();
                    newPoll.Description = question;
                    newPoll.Choices = choices;
                    newPoll.Name = "WidgetPoll";

                    pollID = PollDAL.CreatePoll(newPoll);

                    resultWidget.Visible = true;
                    widgetSrc.InnerText = "<iframe style=\"border: solid 1px #A30313; width: 320px; height: 165px\" scrolling=\"auto\" src=\"PollWidget.aspx?poll_id=" + pollID.ToString() + "\"></iframe>";

                    break;
            }
        }
        catch (Exception exception)
        {
            errorLabel.Text = exception.Message;
        }
    }
Example #31
0
 public ChangeOfValue(Real newValue, StatusFlags statusFlags)
 {
     NewValue    = new Choice(1, newValue);
     StatusFlags = statusFlags;
 }
Example #32
0
 private void btnFillEllips_Click(object sender, EventArgs e)
 {
     select = Choice.FillEllips;
 }
Example #33
0
        /// <summary>
        /// Once we have a setting we need to process the corresponding value.
        /// </summary>
        /// <param name="sc">Step Context.</param>
        /// <returns>Dialog Turn Result.</returns>
        private async Task <DialogTurnResult> ProcessVehicleSettingsChange(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await Accessor.GetAsync(sc.Context);

            if (state.Changes.Any())
            {
                var settingValues = state.GetUniqueSettingValues();
                if (!settingValues.Any())
                {
                    // This shouldn't happen because the SettingFilter would just add all possible values to let the user select from them.
                    await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(VehicleSettingsResponses.VehicleSettingsOutOfDomain));

                    return(await sc.EndDialogAsync());
                }
                else
                {
                    // We have found multiple settings which we need to prompt the user to resolve
                    if (settingValues.Count() > 1)
                    {
                        string settingName = state.Changes.First().SettingName;

                        // If we have more than one setting name matching prompt the user to choose
                        var options = new PromptOptions()
                        {
                            Choices = new List <Choice>(),
                        };

                        for (var i = 0; i < settingValues.Count; ++i)
                        {
                            var item   = settingValues[i];
                            var choice = new Choice()
                            {
                                Value    = item,
                                Synonyms = new List <string> {
                                    (i + 1).ToString(), item
                                },
                            };
                            options.Choices.Add(choice);
                        }

                        BotResponse promptTemplate     = VehicleSettingsResponses.VehicleSettingsSettingValueSelectionPre;
                        var         promptReplacements = new StringDictionary {
                            { "settingName", settingName }
                        };
                        options.Prompt = sc.Context.Activity.CreateReply(promptTemplate, ResponseBuilder, promptReplacements);

                        var card = new HeroCard
                        {
                            Images = new List <CardImage> {
                                new CardImage(GetSettingCardImageUri("settingcog.jpg"))
                            },
                            Text    = options.Prompt.Text,
                            Buttons = options.Choices.Select(choice =>
                                                             new CardAction(ActionTypes.ImBack, choice.Value, value: choice.Value)).ToList(),
                        };

                        options.Prompt.Attachments.Add(card.ToAttachment());

                        return(await sc.PromptAsync(Actions.SettingValueSelectionPrompt, options));
                    }
                    else
                    {
                        // We only have one setting value so proceed to next step
                        return(await sc.NextAsync());
                    }
                }
            }
            else
            {
                // No setting value was understood
                await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(VehicleSettingsResponses.VehicleSettingsOutOfDomain));

                return(await sc.EndDialogAsync());
            }
        }
Example #34
0
    // Update is called once per frame
    void Update()
    {
        //choices
        Debug.Log(Screen.height);
        if (story.currentChoices.Count > numChoicesDisplayed && typing == false)
        {
            Choice choice = story.currentChoices[numChoicesDisplayed];
            Button button = CreateChoice(choice.text.Trim());

            button.onClick.AddListener(delegate { OnClickChoice(choice); });
            numChoicesDisplayed++;
            offset += offsetDelta;
            choicesButtons.Add(button.gameObject);//add buttons to the list
        }
        //text
        if (story.canContinue && typing == false)
        {
            typing = true;
            string text     = story.Continue().Trim();
            string thisKnot = "";
            foreach (string s in story.currentTags)
            {
                Debug.Log(s);
                if (s[0] == 'k')
                {
                    thisKnot = s.Split('_')[1];
                }
            }
            if (currentKnot == "")
            {
                currentKnot = thisKnot;
            }
            else if (currentKnot != thisKnot)
            {
                currentKnot = thisKnot;
                ResetScene();
            }
            ViewText(text);
            int numLines = Mathf.CeilToInt(text.Length / (float)maxLineLength);
            Debug.Log(numLines);
            if (offset < 420 * 1.5f)
            {
                offset += offsetDelta * 0.75f * numLines;
            }
            else
            {
                foreach (GameObject te in screenText)
                {
                    te.transform.position += new Vector3(0, offsetDelta);
                }
            }
            resetOffset = offset;
        }
        //typing
        if (typing)
        {
            if (Time.time > lastTyped + typeSpeed)
            {
                lastTyped      = Time.time;
                typeText.text += whatToType[0];
                if (whatToType.Length > 1)
                {
                    whatToType = whatToType.Substring(1);
                }
                else
                {
                    typing     = false;
                    typeText   = null;
                    whatToType = "";
                }
            }
            //lets you skip
            if (Input.GetKeyDown(KeyCode.Space))
            {
                typeText.text += whatToType;
                typing         = false;
                typeText       = null;
                whatToType     = "";
            }
        }
    }
Example #35
0
 private void btnTriangle_Click(object sender, EventArgs e)
 {
     select = Choice.Triangle;
 }
Example #36
0
    public Line(string _name)
    {
        StringTableCollection collection = LocalizationEditorSettings.GetStringTableCollection("Questline Dialogue");

        _textList = null;
        if (collection != null)
        {
            int             lineIndex     = 0;
            LocalizedString _dialogueLine = null;
            do
            {
                lineIndex++;
                string key = "L" + lineIndex + "-" + _name;
                if (collection.SharedData.Contains(key))
                {
                    SetActor(collection.SharedData.GetEntry(key).Metadata.GetMetadata <Comment>());
                    _dialogueLine = new LocalizedString()
                    {
                        TableReference = "Questline Dialogue", TableEntryReference = key
                    };
                    if (_textList == null)
                    {
                        _textList = new List <LocalizedString>();
                    }
                    _textList.Add(_dialogueLine);
                }
                else
                {
                    _dialogueLine = null;
                }
            } while (_dialogueLine != null);

            int    choiceIndex = 0;
            Choice choice      = null;
            do
            {
                choiceIndex++;
                string key = "C" + choiceIndex + "-" + _name;

                if (collection.SharedData.Contains(key))
                {
                    LocalizedString _choiceLine = new LocalizedString()
                    {
                        TableReference = "Questline Dialogue", TableEntryReference = key
                    };
                    choice = new Choice(_choiceLine);
                    choice.SetChoiceAction(collection.SharedData.GetEntry(key).Metadata.GetMetadata <Comment>());

                    if (_choices == null)
                    {
                        _choices = new List <Choice>();
                    }
                    _choices.Add(choice);
                }
                else
                {
                    choice = null;
                }
            } while (choice != null);
        }
        else
        {
            _textList = null;
        }
    }
Example #37
0
        static void Main(string[] args)
        {
            var ogre = new MTGLib.MTGObject.BaseCardAttributes()
            {
                name     = "Onakke Ogre",
                manaCost = new ManaCost(
                    2, ManaSymbol.Red
                    ),
                power     = 4,
                toughness = 2,
                cardTypes = new HashSet <MTGLib.MTGObject.CardType> {
                    MTGLib.MTGObject.CardType.Creature
                },
                subTypes = new HashSet <MTGLib.MTGObject.SubType> {
                    MTGLib.MTGObject.SubType.Ogre, MTGLib.MTGObject.SubType.Warrior
                }
            };

            var knight = new MTGObject.BaseCardAttributes()
            {
                name     = "Fireborn Knight",
                manaCost = new ManaCost(
                    ManaSymbol.HybridBoros,
                    ManaSymbol.HybridBoros,
                    ManaSymbol.HybridBoros,
                    ManaSymbol.HybridBoros
                    ),
                power     = 2,
                toughness = 3,
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Creature
                },
                subTypes = new HashSet <MTGObject.SubType> {
                    MTGObject.SubType.Human, MTGObject.SubType.Knight
                },
                // double strike goes here
                activatedAbilities = new List <ActivatedAbility>
                {
                    new ActivatedAbility(
                        new CostEvent.CostGen[]
                    {
                        () => { return(EventContainerPayManaCost.Auto(new ManaCost(
                                                                          ManaSymbol.HybridBoros,
                                                                          ManaSymbol.HybridBoros,
                                                                          ManaSymbol.HybridBoros,
                                                                          ManaSymbol.HybridBoros
                                                                          ))); }
                    },
                        new EffectEvent.Effect[]
                    {
                        (source, targets, callback) =>
                        {
                            MTG mtg_ = MTG.Instance;

                            mtg_.continuousEffects.Add(
                                new ContinuousEffect(
                                    source,
                                    ContinuousEffect.Duration.EndOfTurn,
                                    new ContinuousEffect.DurationData
                            {
                                turn = mtg_.turn.turnCount
                            },
                                    new Modification[]
                            {
                                new PowerMod
                                {
                                    value       = 1,
                                    operation   = Modification.Operation.Add,
                                    specificOID = source
                                },
                                new ToughnessMod
                                {
                                    value       = 1,
                                    operation   = Modification.Operation.Add,
                                    specificOID = source
                                }
                            }
                                    )
                                );
                        }
                    }
                        )
                }
            };

            var landfall = new MTGObject.BaseCardAttributes()
            {
                name      = "Landfall Enchantment",
                manaCost  = new ManaCost(),
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Enchantment
                },
                triggeredAbilities = new List <TriggeredAbility>
                {
                    new TriggeredAbility <MoveZoneEvent>(
                        (source, mtgevent) =>
                    {
                        if (mtgevent.newZone != MTG.Instance.battlefield)
                        {
                            return(false);
                        }
                        var trigobj   = MTG.Instance.objects[mtgevent.oid];
                        var sourceobj = MTG.Instance.objects[source];
                        return(trigobj.attr.controller == sourceobj.attr.controller);
                    },
                        new EffectEvent.Effect[]
                    {
                        (source, targets, callback) =>
                        {
                            var damage = 1;
                            var target = targets[0].SetTargets[0];
                            callback(new DealDamageEvent(source, target, damage));
                        }
                    },
                        new Target[] { Target.AnyTarget }
                        )
                }
            };

            var island = new MTGLib.MTGObject.BaseCardAttributes()
            {
                name      = "Island",
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Land
                },
                superTypes = new HashSet <MTGObject.SuperType> {
                    MTGObject.SuperType.Basic
                },
                subTypes = new HashSet <MTGObject.SubType> {
                    MTGObject.SubType.Island
                },
                activatedAbilities = new List <ActivatedAbility>
                {
                    new ManaAbility(
                        new CostEvent.CostGen[]
                    {
                        () => { return(new TapSelfCostEvent()); }
                    },
                        new EffectEvent.Effect[] {
                        (source, targets, callback) => {
                            int controller = MTG.Instance.objects[source].attr.controller;
                            callback(EventContainerAddMana.Auto(source, controller, ManaSymbol.Blue));
                        }
                    }
                        )
                }
            };
            var mountain = new MTGLib.MTGObject.BaseCardAttributes()
            {
                name      = "Mountain",
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Land
                },
                superTypes = new HashSet <MTGObject.SuperType> {
                    MTGObject.SuperType.Basic
                },
                subTypes = new HashSet <MTGObject.SubType> {
                    MTGObject.SubType.Mountain
                },
                activatedAbilities = new List <ActivatedAbility>
                {
                    new ManaAbility(
                        new CostEvent.CostGen[]
                    {
                        () => { return(new TapSelfCostEvent()); }
                    },
                        new EffectEvent.Effect[] {
                        (source, targets, callback) => {
                            int controller = MTG.Instance.objects[source].attr.controller;
                            callback(EventContainerAddMana.Auto(source, controller, ManaSymbol.Red));
                        }
                    }
                        )
                }
            };

            var crab = new MTGLib.MTGObject.BaseCardAttributes()
            {
                name     = "Wishcoin Crab",
                manaCost = new ManaCost(
                    3, ManaSymbol.Blue
                    ),
                power     = 2,
                toughness = 5,
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGLib.MTGObject.CardType.Creature
                },
                subTypes = new HashSet <MTGObject.SubType> {
                    MTGLib.MTGObject.SubType.Crab
                }
            };

            var izzetSignet = new MTGObject.BaseCardAttributes()
            {
                name      = "Izzet Signet",
                manaCost  = new ManaCost(2),
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Artifact
                },
                activatedAbilities = new List <ActivatedAbility>
                {
                    new ManaAbility(
                        new CostEvent.CostGen[]
                    {
                        () => { return(new TapSelfCostEvent()); },
                        () => { return(EventContainerPayManaCost.Auto(new ManaCost(1))); }
                    },
                        new EffectEvent.Effect[]
                    {
                        (source, targets, callback) =>
                        {
                            int controller = MTG.Instance.objects[source].attr.controller;
                            callback(EventContainerAddMana.Auto(source, controller, ManaSymbol.Red, ManaSymbol.Blue));
                        }
                    }
                        )
                }
            };

            var bolt = new MTGObject.BaseCardAttributes()
            {
                name      = "Lightning Bolt",
                manaCost  = new ManaCost(ManaSymbol.Red),
                cardTypes = new HashSet <MTGObject.CardType> {
                    MTGObject.CardType.Instant
                },
                spellAbilities = new List <ResolutionAbility>
                {
                    new ResolutionAbility(
                        new EffectEvent.Effect[]
                    {
                        (source, targets, callback) =>
                        {
                            var damage = 3;
                            var target = targets[0].SetTargets[0];
                            callback(new DealDamageEvent(source, target, damage));
                        }
                    },
                        new Target[] { Target.AnyTarget }
                        )
                }
            };

            var lib1 = new List <MTGLib.MTGObject.BaseCardAttributes>();
            var lib2 = new List <MTGLib.MTGObject.BaseCardAttributes>();

            for (int i = 0; i < 26; i++)
            {
                lib1.Add(mountain);
                lib2.Add(island);
            }

            for (int i = 0; i < 17; i++)
            {
                lib1.Add(ogre);
                lib1.Add(landfall);
                lib2.Add(crab);
                lib2.Add(izzetSignet);
            }

            var mtg = new MTG(lib1, lib2);

            mtg.Start();

            BoardViewer boardViewer       = new BoardViewer();
            Thread      boardViewerThread = new Thread(boardViewer.Run);

            boardViewerThread.Name = "Board Viewer Thread";
            boardViewerThread.Start();
            boardViewer.Update(mtg);

            Thread gameLoopThread = new Thread(mtg.GameLoop);

            gameLoopThread.Name = "Game Loop Thread";
            gameLoopThread.Start();

            while (true)
            {
                mtg.ChoiceNewEvent.WaitOne();
                boardViewer.Update(mtg);

                Choice choice = mtg.CurrentUnresolvedChoice;

                if (choice is PriorityChoice cast)
                {
                    if (cast.Options.Count == 1)
                    {
                        Console.WriteLine("Single choice - autoresolving.");
                        cast.Resolve(new List <PriorityOption>(cast.Options));
                    }
                }

                if (!choice.Resolved)
                {
                    choice.ConsoleResolve();
                }

                mtg.ResolveChoice(choice);
            }
        }
        /// <summary>
        /// Once we have a setting we need to process the corresponding value.
        /// </summary>
        /// <param name="sc">Step Context.</param>
        /// <returns>Dialog Turn Result.</returns>
        private async Task <DialogTurnResult> ProcessVehicleSettingsChange(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await Accessor.GetAsync(sc.Context);

            if (state.Changes.Any())
            {
                var settingValues = state.GetUniqueSettingValues();
                if (!settingValues.Any())
                {
                    // This shouldn't happen because the SettingFilter would just add all possible values to let the user select from them.
                    await sc.Context.SendActivityAsync(ResponseManager.GetResponse(VehicleSettingsResponses.VehicleSettingsMissingSettingValue));

                    return(await sc.EndDialogAsync());
                }
                else
                {
                    // We have found multiple setting values, which we need to prompt the user to resolve
                    if (settingValues.Count() > 1)
                    {
                        string settingName = state.Changes.First().SettingName;
                        var    setting     = this.settingList.FindSetting(settingName);

                        // If an image filename is provided we'll use it otherwise fall back to the generic car one
                        string imageName = setting.ImageFileName ?? FallbackSettingImageFileName;

                        // If we have more than one setting value matching, prompt the user to choose
                        var options = new PromptOptions()
                        {
                            Choices = new List <Choice>(),
                        };

                        for (var i = 0; i < settingValues.Count; ++i)
                        {
                            var           item     = settingValues[i];
                            List <string> synonyms = new List <string>();
                            synonyms.Add(item);
                            synonyms.Add((i + 1).ToString());
                            synonyms.AddRange(settingList.GetAlternativeNamesForSettingValue(settingName, item));
                            var choice = new Choice()
                            {
                                Value    = item,
                                Synonyms = synonyms,
                            };
                            options.Choices.Add(choice);
                        }

                        var promptReplacements = new StringDictionary {
                            { "settingName", settingName }
                        };
                        options.Prompt = ResponseManager.GetResponse(VehicleSettingsResponses.VehicleSettingsSettingValueSelection, promptReplacements);

                        var card = new ThumbnailCard
                        {
                            Text   = options.Prompt.Text,
                            Images = new List <CardImage> {
                                new CardImage(GetSettingCardImageUri(imageName))
                            },
                            Buttons = options.Choices.Select(choice =>
                                                             new CardAction(ActionTypes.ImBack, choice.Value, value: choice.Value)).ToList(),
                        };

                        options.Prompt.Attachments.Add(card.ToAttachment());

                        // Default Text property is clumsy for speech
                        options.Prompt.Speak = $"{options.Prompt.Text} {GetSpeakableOptions(options.Choices)}";

                        return(await sc.PromptAsync(Actions.SettingValueSelectionPrompt, options));
                    }
                    else
                    {
                        // We only have one setting value so proceed to next step
                        return(await sc.NextAsync());
                    }
                }
            }
            else
            {
                // No setting value was understood
                await sc.Context.SendActivityAsync(ResponseManager.GetResponse(VehicleSettingsResponses.VehicleSettingsOutOfDomain));

                return(await sc.EndDialogAsync());
            }
        }
        /// <summary>
        /// Top level processing, is the user trying to check or change a setting?.
        /// </summary>
        /// <param name="sc">Step Context.</param>
        /// <param name="cancellationToken">Cancellation Token.</param>
        /// <returns>Dialog Turn Result.</returns>
        public async Task <DialogTurnResult> ProcessSetting(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await Accessor.GetAsync(sc.Context, () => new AutomotiveSkillState());

            var luisResult = state.VehicleSettingsLuisResult;
            var topIntent  = luisResult?.TopIntent().intent;

            switch (topIntent.Value)
            {
            case Luis.VehicleSettings.Intent.VEHICLE_SETTINGS_CHANGE:
            case Luis.VehicleSettings.Intent.VEHICLE_SETTINGS_DECLARATIVE:

                // Perform post-processing on the entities, if it's declarative we indicate for special processing (opposite of the condition they've expressed)
                settingFilter.PostProcessSettingName(state, topIntent.Value == Luis.VehicleSettings.Intent.VEHICLE_SETTINGS_DECLARATIVE ? true : false);

                // Perform content logic and remove entities that don't make sense
                settingFilter.ApplyContentLogic(state);

                var settingNames = state.GetUniqueSettingNames();
                if (!settingNames.Any())
                {
                    // missing setting name
                    await sc.Context.SendActivityAsync(ResponseManager.GetResponse(VehicleSettingsResponses.VehicleSettingsMissingSettingName));

                    return(await sc.EndDialogAsync());
                }
                else if (settingNames.Count() > 1)
                {
                    // If we have more than one setting name matching prompt the user to choose
                    var options = new PromptOptions()
                    {
                        Choices = new List <Choice>(),
                    };

                    for (var i = 0; i < settingNames.Count; ++i)
                    {
                        var           item     = settingNames[i];
                        List <string> synonyms = new List <string>();
                        synonyms.Add(item);
                        synonyms.Add((i + 1).ToString());
                        synonyms.AddRange(settingList.GetAlternativeNamesForSetting(item));
                        var choice = new Choice()
                        {
                            Value    = item,
                            Synonyms = synonyms,
                        };
                        options.Choices.Add(choice);
                    }

                    options.Prompt = ResponseManager.GetResponse(VehicleSettingsResponses.VehicleSettingsSettingNameSelection);

                    var card = new ThumbnailCard
                    {
                        Images = new List <CardImage> {
                            new CardImage(GetSettingCardImageUri(FallbackSettingImageFileName))
                        },
                        Text    = options.Prompt.Text,
                        Buttons = options.Choices.Select(choice =>
                                                         new CardAction(ActionTypes.ImBack, choice.Value, value: choice.Value)).ToList(),
                    };

                    options.Prompt.Attachments.Add(card.ToAttachment());

                    // Default Text property is clumsy for speech
                    options.Prompt.Speak = $"{options.Prompt.Text} {GetSpeakableOptions(options.Choices)}";

                    return(await sc.PromptAsync(Actions.SettingNameSelectionPrompt, options));
                }
                else
                {
                    // Only one setting detected so move on to next stage
                    return(await sc.NextAsync());
                }

            case Luis.VehicleSettings.Intent.VEHICLE_SETTINGS_CHECK:
                await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply("The skill doesn't support checking vehicle settings quite yet!"));

                return(await sc.EndDialogAsync(true, cancellationToken));

            default:
                await sc.Context.SendActivityAsync(ResponseManager.GetResponse(VehicleSettingsResponses.VehicleSettingsOutOfDomain));

                return(await sc.EndDialogAsync(true, cancellationToken));
            }
        }
Example #40
0
 public Choice Choose()
 {
     this.ppot = (Choice)Between(1, 3);
     return(this.ppot);
 }
Example #41
0
 void chooseStoryChoice(Choice choice)
 {
     story.ChooseChoiceIndex(choice.index);
     refreshUI();
 }
Example #42
0
 /**
  * Constructor from given details.
  * <p>
  * Exactly one of the parameters must be not <code>null</code>.</p>
  *
  * @param type the choice type to apply to the name.
  * @param name the general name.
  * @throws ArgumentException if type is invalid.
  */
 public Target(
     Choice type,
     GeneralName name)
     : this(new DerTaggedObject((int)type, name))
 {
 }
Example #43
0
 private void btnSqure_Click(object sender, EventArgs e)
 {
     select = Choice.Squre;
 }
Example #44
0
 private void btnLine_Click(object sender, EventArgs e)
 {
     select = Choice.Line;
 }
Example #45
0
 private void btnBrush_Click(object sender, EventArgs e)
 {
     select = Choice.Brush;
 }
Example #46
0
 // When we click the choice button, tell the story to choose that choice!
 void OnClickChoiceButton(Choice choice)
 {
     story.ChooseChoiceIndex(choice.index);
     RefreshView();
 }
Example #47
0
 public Choice(Choice choice)
 {
     _response     = choice.Response;
     _nextDialogue = choice.NextDialogue;
     _actionType   = ActionType;
 }
Example #48
0
 public bool BaseMethod()
 {
     return(Choice.Choose(
                new Option <bool>(new Probability(0.8), true),
                new Option <bool>(new Probability(0.2), false)));
 }
Example #49
0
        public async Task <DialogTurnResult> AfterUpdateStartTime(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var state = await Accessor.GetAsync(sc.Context);

                if (sc.Result != null)
                {
                    state.Events = sc.Result as List <EventModel>;
                }

                if (state.Events.Count == 0)
                {
                    // should not doto this part. add log here for safe
                    await HandleDialogExceptions(sc, new Exception("Unexpect zero events count"));

                    return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
                }
                else
                if (state.Events.Count > 1)
                {
                    var options = new PromptOptions()
                    {
                        Choices = new List <Choice>(),
                    };

                    for (var i = 0; i < state.Events.Count; i++)
                    {
                        var item   = state.Events[i];
                        var choice = new Choice()
                        {
                            Value    = string.Empty,
                            Synonyms = new List <string> {
                                (i + 1).ToString(), item.Title
                            },
                        };
                        options.Choices.Add(choice);
                    }

                    var cards = new List <Card>();
                    foreach (var item in state.Events)
                    {
                        cards.Add(new Card()
                        {
                            Name = item.OnlineMeetingUrl == null ? "CalendarCardNoJoinButton" : "CalendarCard",
                            Data = item.ToAdaptiveCardData(state.GetUserTimeZone())
                        });
                    }

                    options.Prompt = ResponseManager.GetCardResponse(
                        UpdateEventResponses.MultipleEventsStartAtSameTime,
                        cards);

                    return(await sc.PromptAsync(Actions.EventChoice, options));
                }
                else
                {
                    return(await sc.EndDialogAsync(true));
                }
            }
            catch (SkillException ex)
            {
                await HandleDialogExceptions(sc, ex);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
            catch (Exception ex)
            {
                await HandleDialogExceptions(sc, ex);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
        }
Example #50
0
        /// <summary>
        /// Top level processing, is the user trying to check or change a setting?.
        /// </summary>
        /// <param name="sc">Step Context.</param>
        /// <param name="cancellationToken">Cancellation Token.</param>
        /// <returns>Dialog Turn Result.</returns>
        public async Task <DialogTurnResult> ProcessSetting(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await Accessor.GetAsync(sc.Context);

            // Ensure we don't have state from a previous instantiation
            state.Changes.Clear();
            state.Entities.Clear();

            var luisResult = state.VehicleSettingsLuisResult;
            var topIntent  = luisResult?.TopIntent().intent;

            switch (topIntent.Value)
            {
            case VehicleSettings.Intent.VEHICLE_SETTINGS_CHANGE:
            case VehicleSettings.Intent.VEHICLE_SETTINGS_DECLARATIVE:

                // Process the LUIS result and add entities to the State accessors for ease of access
                if (luisResult.Entities.AMOUNT != null)
                {
                    state.Entities.Add(nameof(luisResult.Entities.AMOUNT), luisResult.Entities.AMOUNT);
                }

                if (luisResult.Entities.INDEX != null)
                {
                    state.Entities.Add(nameof(luisResult.Entities.INDEX), luisResult.Entities.INDEX);
                }

                if (luisResult.Entities.SETTING != null)
                {
                    state.Entities.Add(nameof(luisResult.Entities.SETTING), luisResult.Entities.SETTING);
                }

                if (luisResult.Entities.TYPE != null)
                {
                    state.Entities.Add(nameof(luisResult.Entities.TYPE), luisResult.Entities.TYPE);
                }

                if (luisResult.Entities.UNIT != null)
                {
                    state.Entities.Add(nameof(luisResult.Entities.UNIT), luisResult.Entities.UNIT);
                }

                if (luisResult.Entities.VALUE != null)
                {
                    state.Entities.Add(nameof(luisResult.Entities.VALUE), luisResult.Entities.VALUE);
                }

                // Perform post-processing on the entities, if it's declarative we indicate for special processing (opposite of the condition they've expressed)
                settingFilter.PostProcessSettingName(state, topIntent.Value == VehicleSettings.Intent.VEHICLE_SETTINGS_DECLARATIVE ? true : false);

                // Perform content logic and remove entities that don't make sense
                settingFilter.ApplyContentLogic(state);

                var settingNames = state.GetUniqueSettingNames();
                if (!settingNames.Any())
                {
                    // missing setting name
                    await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(VehicleSettingsResponses.VehicleSettingsMissingSettingName));

                    return(await sc.EndDialogAsync());
                }
                else if (settingNames.Count() > 1)
                {
                    // If we have more than one setting name matching prompt the user to choose
                    var options = new PromptOptions()
                    {
                        Choices = new List <Choice>(),
                    };

                    for (var i = 0; i < settingNames.Count; ++i)
                    {
                        var item   = settingNames[i];
                        var choice = new Choice()
                        {
                            Value    = item,
                            Synonyms = new List <string> {
                                (i + 1).ToString(), item
                            },
                        };
                        options.Choices.Add(choice);
                    }

                    var card = new HeroCard
                    {
                        Images = new List <CardImage> {
                            new CardImage(GetSettingCardImageUri("settingcog.jpg"))
                        },
                        Text    = "Please choose from one of the available settings shown below",
                        Buttons = options.Choices.Select(choice =>
                                                         new CardAction(ActionTypes.ImBack, choice.Value, value: choice.Value)).ToList(),
                    };

                    options.Prompt = (Activity)MessageFactory.Attachment(card.ToAttachment());

                    return(await sc.PromptAsync(Actions.SettingNameSelectionPrompt, options));
                }
                else
                {
                    // Only one setting detected so move on to next stage
                    return(await sc.NextAsync());
                }

            case VehicleSettings.Intent.VEHICLE_SETTINGS_CHECK:
                await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply("The skill doesn't support checking vehicle settings quite yet!"));

                return(await sc.EndDialogAsync(true, cancellationToken));

            default:
                await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(VehicleSettingsResponses.VehicleSettingsOutOfDomain));

                return(await sc.EndDialogAsync(true, cancellationToken));
            }
        }
Example #51
0
    void RefreshCanvas()
    {
        //Reset text
        displayed_speaker.text = current_dialog.speaker.ToString();
        displayed_text.text    = "";
        current_pos            = 0;

        next_dialog = null;

        if (current_dialog.next.Length > 1)
        {
            for (int i = 0; i < current_dialog.next.Length && !next_dialog; i++)
            {
                Choice c = current_dialog.next[i];
                if (c.successStory == has_success_story && string.IsNullOrEmpty(c.name))
                {
                    next_dialog = c.dialogBox;
                }
            }
        }
        else if (current_dialog.next.Length == 1 && string.IsNullOrEmpty(current_dialog.next[0].name))
        {
            next_dialog = current_dialog.next[0].dialogBox;
        }

        if (string.IsNullOrEmpty(current_dialog.content))
        {
            go_to_next = true;
        }

        //GetComponent<Image>().sprite = current_dialog.background;


        //Change sprite and music
        if (current_dialog.speaker == Characters.Protagonist)
        {
            character.sprite = ResourcesManager.instance.getSpriteForEmotion(current_dialog.emotion);
        }
        //music.clip = ResourcesManager.instance.GetAudioClipForEmotion(current_dialog.emotion);

        /*
         * bool hasSuccessStory = false;
         *
         * }*/

        //Choice management
        Button[] choice_buttons = GetComponentsInChildren <Button>(true);
        Debug.Log("Number of chhoices : " + choice_buttons.Length);
        for (int i = 0; i < choice_buttons.Length; i++)
        {
            choice_buttons[i].gameObject.SetActive(false);
        }
        if (next_dialog == null && (current_dialog.next.Length > 1 || (current_dialog.next.Length == 1 && !string.IsNullOrEmpty(current_dialog.next[0].name))))
        {
            for (int i = 0; i < current_dialog.next.Length; i++)
            {
                Choice choice = current_dialog.next[i];
                Debug.Log("BONJOUR " + choice.successStory + " et " + has_success_story);
                if (choice.successStory == has_success_story || !choice.successStory)
                {
                    Debug.Log("Salut");
                    Button b = choice_buttons[i];
                    b.name = choice.name;
                    b.GetComponentInChildren <Text>().text = choice.name;

                    if (b.GetComponentInChildren <Text>().cachedTextGenerator.lineCount > 1)
                    {
                        b.image.sprite = box_large;
                    }
                    else
                    {
                        b.image.sprite = box_small;
                    }

                    b.gameObject.SetActive(true);
                    b.onClick.AddListener(delegate { next_dialog = choice.dialogBox; go_to_next = true; });// changeDialog(choice.dialogBox);});
                }
            }
        }
    }
Example #52
0
 private void btnRhom_Click(object sender, EventArgs e)
 {
     select = Choice.Rhom;
 }
    // Parses a text
    private static DialogueText parseText(XmlNode _node)
    {
        // Local variables
        int             textID             = -1;
        int             nextTextID         = -1;
        string          exitValue          = "";
        string          funcValueShowParts = "";
        DialogueText    text       = null;
        XmlNode         xmlNode    = null;
        XmlNode         xmlNodeAtt = null;
        TextPart        part       = null;
        Choice          choice     = null;
        List <TextPart> partList   = new List <TextPart>();
        List <Choice>   choiceList = new List <Choice>();

        // Get attribute: id
        xmlNodeAtt = _node.Attributes.GetNamedItem("id");
        if (xmlNodeAtt == null)
        {
            Debug.LogError("Dialogue texts need IDs!");
            return(null);
        }
        textID = int.Parse(xmlNodeAtt.Value);

        // Get attribute: next text ID
        xmlNodeAtt = _node.Attributes.GetNamedItem("nextText");
        if (xmlNodeAtt != null)
        {
            nextTextID = int.Parse(xmlNodeAtt.Value);
        }

        // Get attribute: exit value
        xmlNodeAtt = _node.Attributes.GetNamedItem("exit");
        if (xmlNodeAtt != null)
        {
            exitValue = xmlNodeAtt.Value;
        }

        // Get attribute: show parts
        xmlNodeAtt = _node.Attributes.GetNamedItem("showParts");
        if (xmlNodeAtt != null)
        {
            funcValueShowParts = xmlNodeAtt.Value;
        }

        // Find first text/choice node
        xmlNode = _node.FirstChild;
        if (xmlNode == null)
        {
            Debug.LogError("No text-parts or choices has been found!");
            return(null);
        }

        // Parse all text-parts/choices
        do
        {
            // Skipable?
            if (isNodeSkipable(xmlNode) == false)
            {
                // Text-part?
                if (xmlNode.Name.Equals("part") == true)
                {
                    // Parse
                    part = parseTextPart(xmlNode);
                    if (part == null)
                    {
                        return(null);
                    }

                    // Add to list
                    partList.Add(part);
                }

                // Choice?
                else if (xmlNode.Name.Equals("choice") == true)
                {
                    // Parse
                    choice = parseChoice(xmlNode);
                    if (choice == null)
                    {
                        return(null);
                    }

                    // Add to list
                    choiceList.Add(choice);
                }

                // Unknown (exclude known standard strings)
                else
                {
                    Debug.LogWarning("Unknown XML node with a text (" + xmlNode.Name + ")");
                }
            }

            // Next sibling
            xmlNode = xmlNode.NextSibling;
        }while (xmlNode != null);

        // Create text
        text = new DialogueText(textID, nextTextID, exitValue, funcValueShowParts, choiceList, partList);

        return(text);
    }
Example #54
0
 private void btnPencil_Click(object sender, EventArgs e)
 {
     select = Choice.Pen;
 }
        public IHttpActionResult PostChoice([FromODataUri] string formId, [FromODataUri] string questionId, [FromBody] Choice choice)
        {
            choice.Id         = Guid.NewGuid().ToString();
            choice.FormId     = formId;
            choice.QuestionId = questionId;

            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(new TableEntityAdapter <Choice>(choice, formId, choice.Id));

            // Execute the operation.
            ChoiceTable.Execute(insertOperation);

            return(Created(choice));
        }
    // Parses a choice
    private static Choice parseChoice(XmlNode _node)
    {
        // Local variables
        string                  text         = "";
        int                     choiceID     = -1;
        string                  nextTextID   = "";
        string                  exitValue    = "";
        string                  enabledValue = "";
        DynamicScriptRef        scriptRef    = null;
        List <DynamicScriptRef> scriptRefs   = new List <DynamicScriptRef>();
        Choice                  choice       = null;
        XmlNode                 xmlNode      = null;
        XmlNode                 xmlNodeAtt   = null;

        // Get attribute: id
        xmlNodeAtt = _node.Attributes.GetNamedItem("id");
        if (xmlNodeAtt == null)
        {
            Debug.LogError("Choices need IDs!");
            return(null);
        }
        choiceID = int.Parse(xmlNodeAtt.Value);

        // Get attribute: next text ID
        xmlNodeAtt = _node.Attributes.GetNamedItem("nextText");
        if (xmlNodeAtt != null)
        {
            nextTextID = xmlNodeAtt.Value;
        }

        // Get attribute: exit value
        xmlNodeAtt = _node.Attributes.GetNamedItem("exit");
        if (xmlNodeAtt != null)
        {
            exitValue = xmlNodeAtt.Value;
        }

        // Get attribute: enabled
        xmlNodeAtt = _node.Attributes.GetNamedItem("enabled");
        if (xmlNodeAtt != null)
        {
            enabledValue = xmlNodeAtt.Value;
        }

        // Find first text/choice node
        xmlNode = _node.FirstChild;
        if (xmlNode != null)
        {
            // Parse all data, script references
            do
            {
                // Skipable?
                if (isNodeSkipable(xmlNode) == false)
                {
                    // Data?
                    if (xmlNode.Name.Equals("data") == true)
                    {
                        // Get text
                        text = xmlNode.InnerText;
                    }

                    // Script reference?
                    else if (xmlNode.Name.Equals("refscript") == true)
                    {
                        // Parse
                        scriptRef = parseDynamicScriptReference(xmlNode);
                        if (scriptRef == null)
                        {
                            return(null);
                        }

                        // Add to list
                        scriptRefs.Add(scriptRef);
                    }

                    // Unknown (exclude known standard strings)
                    else
                    {
                        Debug.LogWarning("Unknown XML node with a text (" + xmlNode.Name + ")");
                    }
                }

                // Next sibling
                xmlNode = xmlNode.NextSibling;
            }while (xmlNode != null);
        }

        // Get text
        if (text == null || text.Length == 0)
        {
            text = _node.InnerText;
        }
        if (text == null || text.Length == 0)
        {
            Debug.LogError("Choices need text!");
            return(null);
        }

        // Create choice
        choice = new Choice(choiceID, text, nextTextID, exitValue, enabledValue, scriptRefs);

        return(choice);
    }
Example #57
0
 // When we click the choice button, tell the story to choose that choice!
 void OnClickChoiceButton(Choice choice)
 {
     auso.PlayOneShot(sentSound);
     story.ChooseChoiceIndex(choice.index);
     RefreshView();
 }
Example #58
0
 public ChangeOfValue(BitString newValue, StatusFlags statusFlags)
 {
     NewValue    = new Choice(0, newValue);
     StatusFlags = statusFlags;
 }
Example #59
0
 public RequestedCertificate(
     Choice type,
     byte[]  certificateOctets)
     : this(new DerTaggedObject((int)type, new DerOctetString(certificateOctets)))
 {
 }
Example #60
0
 private void btnFillCircle_Click(object sender, EventArgs e)
 {
     select = Choice.FillCircle;
 }