public void CalculateChoices(ConversationStage s)
        {
            ChoicesColumn1.Clear();
            ChoicesColumn2.Clear();
            ChoicesColumn3.Clear();
            int current = 0;

            foreach (var choice in s.Choices)
            {
                var script = new ScriptWrapper(choice.ChoiceVisibility);
                var result = script.Execute();
                if (result == null || result == true)
                {
                    if (current == 0)
                    {
                        ChoicesColumn1.Add(new KeyValuePair <int, string>(choice.Target, choice.ChoiceText));
                    }
                    if (current == 1)
                    {
                        ChoicesColumn2.Add(new KeyValuePair <int, string>(choice.Target, choice.ChoiceText));
                    }
                    if (current == 2)
                    {
                        ChoicesColumn3.Add(new KeyValuePair <int, string>(choice.Target, choice.ChoiceText));
                    }
                    current = (current + 1) % 3;
                }
            }
        }
Beispiel #2
0
        static TestData()
        {
            //MainViewModel.MainViewModelStatic.ItemClasses.Add(Editor.ObjectTypes.ItemClass.GetBaseItemClass());
            TestScript = new Script();
            TestScript.ScriptLines.Clear();
            TestScript.ScriptLines.Add(new Comment {
                CommentText = "test comment"
            });
            TestScript.ScriptLines.Add(new Comment {
                CommentText = "another test comment"
            });
            TestCondition1 = new Conditional(TestScript);
            TestCondition1.ThenStatement.AddBeforeSelected(new Comment {
                CommentText = "Test Conditional Comment"
            });
            TestCondition1.ElseStatement.AddBeforeSelected(new Comment {
                CommentText = "Test Else Comment"
            });
            TestConditionNested = new Conditional(TestScript);
            TestConditionChild  = new Conditional(TestScript);
            TestConditionChild.ThenStatement.AddBeforeSelected(new Comment {
                CommentText = "Another comment"
            });
            TestConditionChild.ElseStatement.AddBeforeSelected(new Comment {
                CommentText = "Another else comment"
            });
            TestConditionNested.ThenStatement.AddBeforeSelected(TestConditionChild);
            TestConditionChild = new Conditional(TestScript);
            TestScript.ScriptLines.Add(TestCondition1);
            TestScript.ScriptLines.Add(TestConditionNested);
            TestScript.ScriptLines.Add(new Blank());
            TestComment = new Comment {
                CommentText = "This is my comment."
            };
            TestDisplayText = new DisplayText {
                Text = "The room is dark and reeks of old milk.\n\nThere is an unlit chandalier."
            };
            TestAddText = new AddText {
                Text = "A fresh, crisp, tasty looking apple."
            };
            TestRoom                         = new Room();
            TestRoom.RoomName                = "Test Room";
            TestRoom.Description             = "Test Room Description";
            TestRoom.HasPlaintextDescription = false;
            TestRoom.RoomID                  = new Guid("{1CF2C7E6-276C-4678-951C-2D1B1F239620}");
            TestRoom.RoomDescriptionScript   = TestScript;

            TestScriptRoom                         = new Room();
            TestScriptRoom.RoomName                = "Test Room";
            TestScriptRoom.Description             = "Test Room Description";
            TestScriptRoom.HasPlaintextDescription = true;
            TestScriptRoom.RoomID                  = new Guid("{1CF2C7E6-276C-4678-951C-2D1B1F239620}");
            TestScriptRoom.RoomDescriptionScript   = TestScript;

            TestInteractable = new Interactable();

            TestInteractable.InteractableName      = "Bookshelf";
            TestInteractable.DefaultDisplayName    = "Old Bookshelf";
            TestInteractable.CanExamine            = true;
            TestInteractable.CanExamineUsesScript  = true;
            TestInteractable.CanInteract           = true;
            TestInteractable.CanInteractUsesScript = false;
            Script testIntCanExScript = new Script();

            testIntCanExScript.AddBeforeSelected(new Comment {
                CommentText = "Test Can Examine Script"
            });
            Script testIntCanInScript = new Script();

            testIntCanInScript.AddBeforeSelected(new Comment {
                CommentText = "Test Can Interact Script"
            });
            Script testIntExScript = new Script();

            testIntExScript.AddBeforeSelected(new Comment {
                CommentText = "Test Examine Script"
            });
            Script testIntInScript = new Script();

            testIntInScript.AddBeforeSelected(new Comment {
                CommentText = "Test Interaction Script"
            });
            TestInteractable.ExamineScript     = testIntExScript;
            TestInteractable.InteractScript    = testIntInScript;
            TestInteractable.CanInteractScript = testIntCanInScript;
            TestInteractable.CanExamineScript  = testIntCanExScript;
            TestInteractable.GroupName         = "Furniture";

            TestInteractableGroup = MainViewModel.MainViewModelStatic.InteractableGroups.FirstOrDefault();

            TestRoom.DefaultInteractables.Add(new InteractableRef(TestInteractable.InteractableID));

            TestDateTimeVariable                 = new Variable();
            TestDateTimeVariable.IsDateTime      = true;
            TestDateTimeVariable.DefaultDateTime = new DateTime(2015, 1, 30, 10, 20, 5);
            TestDateTimeVariable.Name            = "Test Date Time";

            TestStringVariable               = new Variable();
            TestStringVariable.IsString      = true;
            TestStringVariable.DefaultString = "Test Data";
            TestStringVariable.Name          = "Test String";

            TestNumberVariable               = new Variable();
            TestNumberVariable.IsNumber      = true;
            TestNumberVariable.DefaultNumber = 5;
            TestNumberVariable.Name          = "Test Number";

            TestSetVariable = new SetVariable();
            TestSetVariable.SelectedVariable = new VarRef(TestNumberVariable.Id);
            //var testParent = new ItemClass() { Name = "Item" };
            //MainViewModel.MainViewModelStatic.ItemClasses.Add(TestItemClass);
            TestItemClass = new ItemClass {
                Name = "Clothing", ParentClass = ItemClass.GetBaseItemClass()
            };
            TestItemClass.ItemProperties.Add(new Variable {
                Name = "Slot", IsString = true, DefaultString = "Body"
            });
            TestItemClass.ItemProperties.Add(new Variable {
                Name = "Weight", IsNumber = true, DefaultNumber = 40
            });
            //MainViewModel.MainViewModelStatic.ItemClasses.Add(TestItemClass);
            var testChild1 = new ItemClass()
            {
                Name = "Shirts", ParentClass = TestItemClass
            };
            var testChild2 = new ItemClass()
            {
                Name = "Pants", ParentClass = TestItemClass
            };
            var testChild3 = new ItemClass()
            {
                Name = "Underwear", ParentClass = TestItemClass
            };
            var testChild4 = new ItemClass()
            {
                Name = "Food", ParentClass = TestItemClass
            };

            testChild4.ParentClass = TestItemClass.ParentClass;
            var testItem = new Item()
            {
                ItemClassParent = TestItemClass, DefaultName = "Helmet"
            };

            var testItem2 = new Item()
            {
                ItemClassParent = TestItemClass, DefaultName = "Bracers"
            };
            var testItem3 = new Item()
            {
                ItemClassParent = TestItemClass, DefaultName = "Apple"
            };

            testItem3.ItemClassParent = TestItemClass.ParentClass;

            TestItemClass.SelectedProperty = TestItemClass.ItemProperties.First();
            testItem2.ItemName             = "BasicBracers";
            testItem2.IsEquipment          = true;

            testItem2.SelectedProperty = testItem.ItemProperties.First();
            TestItem = testItem2;

            TestAddItem = new AddItemToInventory {
                ItemReference = new ItemRef(testItem.ItemID)
            };

            TestGetProperty = new GetItemProperty {
                VarRef = new VarRef(TestStringVariable.Id), SelectedItemClass = TestItemClass
            };
            TestGetProperty.SelectedProperty = TestGetProperty.SelectedItemClass.ItemProperties.First();
            TestSetProperty = new SetItemProperty {
                VarRef = new VarRef(TestStringVariable.Id), SelectedItemClass = TestItemClass
            };
            TestSetProperty.SelectedProperty = TestSetProperty.SelectedItemClass.ItemProperties.First();

            Settings1 = new PlayerSettings();
            Settings1.PlayerDescription.AddBeforeSelected(new AddText {
                Text = "You are a {{Age}} year old {{Gender}}"
            });
            PlayerStatistic testHunger = new PlayerStatistic {
                Label = "Hunger"
            };

            testHunger.DisplayCondition.AddBeforeSelected(new ReturnFalse());
            testHunger.AssociatedVariable        = new VarRef(TestNumberVariable.Id);
            testHunger.IsProgressBar             = true;
            testHunger.HighWarning               = false;
            testHunger.LowWarning                = true;
            testHunger.MaximumValueVariable      = true;
            testHunger.MaximumValueVariableValue = new VarRef(TestNumberVariable.Id);
            PlayerStatistic testSpecies = new PlayerStatistic {
                Label = "Species"
            };

            testSpecies.Label = "Species";
            testSpecies.AssociatedVariable = new VarRef(TestNumberVariable.Id);
            testSpecies.IsPlaintext        = true;

            Settings1.PlayerStatistics.Add(testHunger);
            Settings1.PlayerStatistics.Add(testSpecies);
            Settings1.SelectedStatistic = testHunger;
            Settings1.EquipmentSlots.Add(new EquipmentSlot {
                Name = "Body"
            });
            Settings1.EquipmentSlots.Add(new EquipmentSlot {
                Name = "Legs"
            });
            Settings1.EquipmentSlots.Add(new EquipmentSlot {
                Name = "Wrists"
            });
            Settings1.EquipmentSlots.Add(new EquipmentSlot {
                Name = "Feet"
            });
            Settings1.EquipmentSlots.Add(new EquipmentSlot {
                Name = "Head"
            });
            Settings1.SelectedEquipmentSlot = Settings1.EquipmentSlots.First();
            testItem2.EquipmentRef.OccupiesSlots.Add(Settings1.SelectedEquipmentSlot);
            TestCommonEvent = new CommonEvent();
            //TestCommonEvent.Name = "Test";
            //TestCommonEvent.EventType = CommonEvent.CommonEventTypes.First();


            TestConversation               = new Conversation();
            TestConversation.Name          = "Test";
            TestConversation.StartingStage = 10;
            ConversationStage TestStage1 = new ConversationStage();

            TestStage1.StageName = "Test Intro Point";
            TestStage1.StageAction.AddBeforeSelected(new DisplayText {
                Text = "Test Stuff"
            });
            TestStage1.StageId = 10;
            TestStage1.Choices.Add(new ConversationChoice()
            {
                ChoiceText = "Choice 1", Target = 20
            });
            TestStage1.Choices.Add(new ConversationChoice()
            {
                ChoiceText = "Choice 2", Target = 30
            });
            ConversationStage TestStage2 = new ConversationStage();

            TestStage2.StageName = "Stage #2";
            ConversationStage TestStage3 = new ConversationStage();

            TestStage3.StageName = "Stage #3";
            TestStage2.StageId   = 20;
            TestStage3.StageId   = 30;

            TestConversation.Stages.Add(TestStage1);
            TestConversation.Stages.Add(TestStage2);
            TestConversation.SelectedStage = TestStage1;
            TestConversation.Stages.Add(TestStage3);
            TestStage1.SelectedChoice = TestStage1.Choices.First();
            TestStage1.SelectedChoice.ChoiceVisibility.AddBeforeSelected(new ReturnTrue());


            //var tempRooms = new System.Collections.ObjectModel.ObservableCollection<Room>();
            //tempRooms.Add(TestData.TestRoom);
            //MainViewModel.MainViewModelStatic.Zones.Add(new Zone { ZoneName = "Test", Rooms = tempRooms });

            //TestArray.IsNumber = true;
            //TestArray.Name = "Test";
            //TestArray.Group = "Test Group";
            TestStatusEffect      = new StatusEffect();
            TestStatusEffect.Name = "Sample Status Effect";
            TestStatusEffect.OnInitialize.AddBeforeSelected(new Comment {
                CommentText = "On Initialize Script"
            });
            TestStatusEffect.OnMove.AddBeforeSelected(new Comment {
                CommentText = "On Move Script"
            });
            TestStatusEffect.OnStack.AddBeforeSelected(new Comment {
                CommentText = "On Stack Script"
            });
            TestStatusEffect.OnFinish.AddBeforeSelected(new Comment {
                CommentText = "On Finish Script"
            });
            TestStatusEffect.CheckIfCleared.AddBeforeSelected(new Comment {
                CommentText = "Check If Cleared Script"
            });
            TestStatusEffect.CanOccurMultipleTimes = false;
            TestStatusEffect.Arguments.Add(new StatusEffectValue {
                Name = "Duration", IsNumber = true
            });
            TestStatusEffect.Arguments.Add(new StatusEffectValue {
                Name = "Text Test", IsString = true
            });
            TestStatusEffect.SelectedArgument = TestStatusEffect.Arguments.Last();

            //AddStatusEffectTest = new AddStatusEffect();
            //AddStatusEffectTest.AssociatedEffect = new GenericRef<StatusEffect>((id) => TestStatusEffect, (statusEffect) => TestStatusEffect.Id) { Ref = TestStatusEffect.Id };
            //AddStatusEffect.UpdateAllArguments(TestStatusEffect);
        }