コード例 #1
0
        private IState InitializeStates()
        {
            var toBeContinued = new ToBeContinuedState();

            var dialogOptions = new List <IState>()
            {
                new DialogOptionState("Option 1 was chosen"),
                new DialogOptionState("Option 2 was chosen"),
                new DialogOptionState("Option 3 was chosen")
            };

            dialogOptions.ForEach(x => x.AddState(StandardCommands.ToBeContinued, toBeContinued));

            var dialogState = new DialogState();

            dialogState.AddState(StandardCommands.DialogOptionOne, dialogOptions[0]);
            dialogState.AddState(StandardCommands.DialogOptionTwo, dialogOptions[1]);
            dialogState.AddState(StandardCommands.DialogOptionThree, dialogOptions[2]);

            var meetingState = new MeetingState();

            meetingState.AddState(StandardCommands.OpenDialog, dialogState);
            meetingState.AddState(StandardCommands.AnotherOption, new SomeState());

            var startState = new StartState();

            startState.AddState(StandardCommands.MeetCharacter, meetingState);

            return(startState);
        }