Inheritance: MonoBehaviour
Exemple #1
0
        private void AssignTargets()
        {
            // Find player
            playerGO = GameObject.FindGameObjectWithTag("Player");
            PlayerController playerController = playerGO.GetComponent <PlayerController>();

            // Assign opponent to scripts
            enemyGO.GetComponent <CombatEffects>().SetTarget(playerGO);
            enemyGO.GetComponent <EnemyAI>().SetTarget(playerController);
            playerController.SetEnemy(enemyGO.GetComponent <EnemyController>());
            playerGO.GetComponent <CombatEffects>().SetTarget(enemyGO);
            GameObject followerGO = GameObject.FindGameObjectWithTag("Follower");

            if (followerGO != null)
            {
                followerGO.GetComponent <FollowerAI>().SetTarget(playerGO, enemyGO);
                followerGO.GetComponent <CombatEffects>().SetTarget(enemyGO);
            }

            // Check whether to display quest window
            QuestList questList = playerGO.GetComponent <QuestList>();

            if (questList.GetActiveQuestCount() > 0)
            {
                questWindow.SetActive(true);
            }

            // Activate battle
            introCoroutine = StartCoroutine(BeginBattle());
        }
 ///<summary> method proofs if the current quest is the one at which the barrricade should disappear</summary>
 ///<param name="currentTime">the current time of the quest</param>
 ///<param quest="currentQuest">the current quest that is running on the player</param>
 public void Proof(TimeOfQuest currentTime, QuestList currentQuest)
 {
     if (currentTime == this.time && currentQuest == this.quest)
     {
         Destroy(gameObject); //destroys the barricade when the quest and it's time matches to the conditions
     }
 }
Exemple #3
0
 public AvatarState(Dictionary serialized)
     : base(serialized)
 {
     name                     = ((Text)serialized["name"]).Value;
     characterId              = (int)((Integer)serialized["characterId"]).Value;
     level                    = (int)((Integer)serialized["level"]).Value;
     exp                      = (long)((Integer)serialized["exp"]).Value;
     inventory                = new Inventory((List)serialized["inventory"]);
     worldInformation         = new WorldInformation((Dictionary)serialized["worldInformation"]);
     updatedAt                = serialized["updatedAt"].ToLong();
     agentAddress             = new Address(((Binary)serialized["agentAddress"]).Value);
     questList                = new QuestList((Dictionary)serialized["questList"]);
     mailBox                  = new MailBox((List)serialized["mailBox"]);
     blockIndex               = (long)((Integer)serialized["blockIndex"]).Value;
     dailyRewardReceivedIndex = (long)((Integer)serialized["dailyRewardReceivedIndex"]).Value;
     actionPoint              = (int)((Integer)serialized["actionPoint"]).Value;
     stageMap                 = new CollectionMap((Dictionary)serialized["stageMap"]);
     serialized.TryGetValue((Text)"monsterMap", out var value2);
     monsterMap = value2 is null ? new CollectionMap() : new CollectionMap((Dictionary)value2);
     itemMap    = new CollectionMap((Dictionary)serialized["itemMap"]);
     eventMap   = new CollectionMap((Dictionary)serialized["eventMap"]);
     hair       = (int)((Integer)serialized["hair"]).Value;
     lens       = (int)((Integer)serialized["lens"]).Value;
     ear        = (int)((Integer)serialized["ear"]).Value;
     tail       = (int)((Integer)serialized["tail"]).Value;
     combinationSlotAddresses = serialized["combinationSlotAddresses"].ToList(StateExtensions.ToAddress);
     RankingMapAddress        = serialized["ranking_map_address"].ToAddress();
     if (serialized.TryGetValue((Text)"nonce", out var nonceValue))
     {
         Nonce = nonceValue.ToInteger();
     }
     PostConstructor();
 }
 private void Awake()
 {
     // Forcefully skip spawning follower
     convo     = GetComponent <AIConversant>();
     playerGO  = GameObject.FindGameObjectWithTag("Player");
     questList = playerGO.GetComponent <QuestList>();
 }
Exemple #5
0
        public MainWindow()
        {
            InitializeComponent();

            quests = new QuestList();

            new TrinityMySqlDatabaseModule().OnInitialized(null);

            var db = new TrinityMysqlDatabaseProvider(new ConnectionSettingsProvider());

            View.DataContext = new QuestChainEditorViewModel(new QuestPicker(new DatabaseQuestsProvider(db)), quests);

            quests.OnAddedQuest += (sender, quest) =>
            {
                Update();
                quest.RequiredQuests.CollectionChanged += (sender2, e2) =>
                {
                    Update();
                };
            };
            quests.OnRemovedQuest += (sender, quest) => Update();
            Update();

            foreach (var q in quests)
            {
                q.RequiredQuests.CollectionChanged += (sender, e) =>
                {
                    Update();
                };
            }
        }
Exemple #6
0
        /// <summary>
        /// Removes the quest quietly.
        /// </summary>
        /// <param name="questToRemove">The quest to remove.</param>
        public void RemoveQuestQuiet(IQuest questToRemove)
        {
            if (questToRemove != null)
            {
                int index = QuestList.IndexOf(questToRemove);

                if (index < 0)
                {
                    return;
                }

                bool isCurrentQuest = questToRemove == SelectedQuest;

                QuestList.RemoveAt(index);

                if (isCurrentQuest)
                {
                    if (QuestList.Count <= index)
                    {
                        SelectedQuest = QuestList.LastOrDefault();
                    }
                    else
                    {
                        SelectedQuest = QuestList[index];
                    }

                    OnPropertyChanged(nameof(HasQuests));
                }
            }
        }
Exemple #7
0
        public void ExcludeTest()
        {
            //string lists
            var stringList = new QuestList <string>()
            {
                "a", "a", "b", "c"
            };

            var expected = new QuestList <string>()
            {
                "b", "c"
            };
            var actual = stringList.Exclude("a");

            Assert.IsTrue(actual.SequenceEqual(expected));

            //element lists
            var elList = new QuestList <Element>()
            {
                a, a, b, c
            };

            var expectedEList = new QuestList <Element>()
            {
                b, c
            };
            var actualEList = elList.Exclude(a);

            Assert.IsTrue(actualEList.SequenceEqual(expectedEList));
        }
Exemple #8
0
        /// <summary>
        /// Removes either the currently selected quest, or the quest specified
        /// in the provided parameter (if it can be found).
        /// </summary>
        /// <param name="parameter">Either an IQuest object or a string specifying
        /// the quest's DisplayName.  If null, will instead use the current
        /// SelectedQuest.</param>
        private void DoRemoveQuest(object?parameter)
        {
            if (GetThisQuest(parameter) is IQuest questToRemove)
            {
                int index = QuestList.IndexOf(questToRemove);

                if (index < 0)
                {
                    return;
                }

                QuestList.RemoveAt(index);

                if (QuestList.Count <= index)
                {
                    SelectedQuest = QuestList.LastOrDefault();
                }
                else
                {
                    SelectedQuest = QuestList[index];
                }

                var linkedQuestsToRemove = questToRemove.LinkedQuests.ToList();
                foreach (var linkedQuest in linkedQuestsToRemove)
                {
                    questToRemove.RemoveLinkedQuest(linkedQuest);
                }

                OnPropertyChanged("RemoveQuest");
                OnPropertyChanged(nameof(HasQuests));
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            quests = new QuestList();

            new TrinityMySqlDatabaseModule().OnInitialized(null);

            TrinityMySqlDatabaseProvider db = new(new DatabaseSettingsProvider(null), new DatabaseLogger(), new MockCoreVersion());

            ExampleQuestsProvider exampleQuestProvider = new();

            View.DataContext = new QuestChainEditorViewModel(new QuestPicker(exampleQuestProvider), quests);

            quests.OnAddedQuest += (sender, quest) =>
            {
                Update();
                quest.RequiredQuests.CollectionChanged += (sender2, e2) => { Update(); };
            };
            quests.OnRemovedQuest += (sender, quest) => Update();
            Update();

            foreach (Quest q in quests)
            {
                q.RequiredQuests.CollectionChanged += (sender, e) => { Update(); }
            }
            ;
        }
Exemple #10
0
 public void RunScript(string function, object[] parameters)
 {
     if ("updateExitLinks" == function)
     {
         var exitList            = new List <ObjectTypeExit>();
         QuestList <string> list = (QuestList <string>)parameters[0];
         foreach (string exit in list)
         {
             exitList.Add(new ObjectTypeExit(m_worldModel.Elements.Get(exit)));
         }
         PrintDataWithColor <ObjectTypeExit>(ConsoleColor.Red, function, exitList, delegate(ObjectTypeExit ote) { return(ote.m_direction.ToString()); });
     }
     else if ("updateCommandLinks" == function)
     {
         QuestList <string> list = (QuestList <string>)parameters[0];
         var commandList         = new List <ObjectTypeCommand>();
         foreach (string cmd in list)
         {
             commandList.Add(new ObjectTypeCommand(m_worldModel.Elements.Get(cmd)));
         }
         PrintDataWithColor <ObjectTypeCommand>(ConsoleColor.Red, function, commandList, delegate(ObjectTypeCommand otc) { return(otc.Element.Name); });
     }
     else if ("updateObjectLinks" == function)
     {
         var objs = ObjectTypeUtils.ConvertToObjectTypeDictionary((QuestDictionary <string>)parameters[0], m_worldModel, e => new ObjectTypeObject(e));
         PrintDataWithColor <ObjectTypeObject>(ConsoleColor.DarkYellow, function, objs.Values.ToList(), delegate(ObjectTypeObject otc) { return(otc.Element.Name); });
     }
     else
     {
         PrintDataWithColor <object>(ConsoleColor.Gray, function, parameters.ToList(), delegate(object i) { return(i.ToString()); });
     }
 }
Exemple #11
0
        public AvatarState(AvatarState avatarState) : base(avatarState.address)
        {
            if (avatarState == null)
            {
                throw new ArgumentNullException(nameof(avatarState));
            }

            name                     = avatarState.name;
            characterId              = avatarState.characterId;
            level                    = avatarState.level;
            exp                      = avatarState.exp;
            inventory                = avatarState.inventory;
            worldInformation         = avatarState.worldInformation;
            updatedAt                = avatarState.updatedAt;
            agentAddress             = avatarState.agentAddress;
            questList                = avatarState.questList;
            mailBox                  = avatarState.mailBox;
            blockIndex               = avatarState.blockIndex;
            dailyRewardReceivedIndex = avatarState.dailyRewardReceivedIndex;
            actionPoint              = avatarState.actionPoint;
            stageMap                 = avatarState.stageMap;
            monsterMap               = avatarState.monsterMap;
            itemMap                  = avatarState.itemMap;
            eventMap                 = avatarState.eventMap;
            hair                     = avatarState.hair;
            lens                     = avatarState.lens;
            ear                      = avatarState.ear;
            tail                     = avatarState.tail;
            combinationSlotAddresses = avatarState.combinationSlotAddresses;
            RankingMapAddress        = avatarState.RankingMapAddress;

            PostConstructor();
        }
Exemple #12
0
        public MainViewModel(QuestCollectionWrapper config, HttpClientHandler handler,
                             IPageProvider pageProvider, ITextResultsProvider textResults,
                             IErrorLogger errorLogger, Func <string, CompareInfo, CompareOptions, int> hashFunction)
        {
            ErrorLog.LogUsing(errorLogger);
            Agnostic.HashStringsUsing(hashFunction);

            if (config != null)
            {
                QuestList = config.QuestCollection;
                QuestList.Sort();
                SelectQuest(config.CurrentQuest);
            }
            else
            {
                QuestList = new QuestCollection();
                SelectQuest(null);
            }

            SetupNetwork(pageProvider, handler);
            SetupTextResults(textResults);

            AllVotesCollection  = new ObservableCollectionExt <string>();
            AllVotersCollection = new ObservableCollectionExt <string>();

            BuildCheckForNewRelease();
            BuildTally();
            BindVoteCounter();

            SetupCommands();
        }
Exemple #13
0
 public void NextDialogue()
 {
     dialogue.SetButtonsInactive();
     if (!isActiveQuest)
     {
         if (currentText + 1 > texts.Count)
         {
             dialogue.SetText(texts[++currentText]);
             dialogue.SetButtonYes(ButtonAction.Next);
         }
         else
         {
             dialogue.SetText(QuestList.GetNextDescription());
             dialogue.SetButtonYes(ButtonAction.AcceptQuest);
             dialogue.SetButtonNo(ButtonAction.Close);
         }
     }
     else
     {
         if (currentThankText + 1 > thankTexts.Count)
         {
             dialogue.SetText(thankTexts[++currentThankText]);
             dialogue.SetButtonYes(ButtonAction.Next);
         }
         else
         {
             FinishQuest();
         }
     }
 }
Exemple #14
0
        /// <summary>
        /// Removes either the currently selected quest, or the quest specified
        /// in the provided parameter (if it can be found).
        /// </summary>
        /// <param name="parameter">Either an IQuest object or a string specifying
        /// the quest's DisplayName.  If null, will instead use the current
        /// SelectedQuest.</param>
        private void DoRemoveQuest(object parameter)
        {
            int    index         = -1;
            IQuest questToRemove = GetThisQuest(parameter);

            if (questToRemove == null)
            {
                return;
            }

            index = QuestList.IndexOf(questToRemove);

            if (index < 0)
            {
                return;
            }

            QuestList.RemoveAt(index);

            if (QuestList.Count <= index)
            {
                SelectedQuest = QuestList.LastOrDefault();
            }
            else
            {
                SelectedQuest = QuestList[index];
            }

            OnPropertyChanged("RemoveQuest");
            OnPropertyChanged(nameof(HasQuests));
        }
Exemple #15
0
    public void PlayLog()
    {
        if (log.Count == 0)
        {
            box.SetActive(false);
            txt_holder.SetActive(false);
            Start();

            if (gameObject.tag.Equals("questr"))
            {
                QuestList.addRequiredQuest(quest_tag);
            }
            if (gameObject.tag.Equals("store"))
            {
                store_inventory_page.SetActive(true);
            }

            return;
        }
        box.SetActive(true);
        txt_holder.SetActive(true);
        string s = log.Dequeue();

        txt.text = s;
    }
Exemple #16
0
 private QuestList <T> ListCombine <T>(QuestList <T> list1, QuestList <T> list2)
 {
     if (list1 == null)
     {
         return(new QuestList <T>(list2));
     }
     return(list1.MergeLists(list2));
 }
Exemple #17
0
 private void SelectedQuest_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "DisplayName")
     {
         QuestList.Sort();
         OnPropertyChanged("RenameQuest");
     }
 }
Exemple #18
0
 public Character() {
     Equipment = new ItemList(27);
     Inventory = new ItemList(63);
     Storage = new ItemList(70);
     Quests = new QuestList();
     ArchivedDigimon = new uint[40];
     DigimonList = new Digimon[3];
 }
Exemple #19
0
 public string ShowMenu(string caption, QuestList <string> options, bool allowCancel)
 {
     if (m_worldModel.Version >= WorldModelVersion.v540)
     {
         throw new Exception("The 'ShowMenu' function is not supported for games written for Quest 5.4 or later. Use the 'show menu' script command instead.");
     }
     return(m_worldModel.DisplayMenu(caption, options, allowCancel, false));
 }
Exemple #20
0
        public AvatarState(Address address,
                           Address agentAddress,
                           long blockIndex,
                           TableSheets sheets,
                           GameConfigState gameConfigState,
                           string name = null) : base(address)
        {
            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            this.name         = name ?? string.Empty;
            characterId       = GameConfig.DefaultAvatarCharacterId;
            level             = 1;
            exp               = 0;
            inventory         = new Inventory();
            worldInformation  = new WorldInformation(blockIndex, sheets.WorldSheet, GameConfig.IsEditor);
            updatedAt         = DateTimeOffset.UtcNow;
            this.agentAddress = agentAddress;
            questList         = new QuestList(
                sheets.QuestSheet,
                sheets.QuestRewardSheet,
                sheets.QuestItemRewardSheet,
                sheets.EquipmentItemRecipeSheet,
                sheets.EquipmentItemSubRecipeSheet
                );
            mailBox         = new MailBox();
            this.blockIndex = blockIndex;
            actionPoint     = gameConfigState.ActionPointMax;
            stageMap        = new CollectionMap();
            monsterMap      = new CollectionMap();
            itemMap         = new CollectionMap();
            const QuestEventType createEvent = QuestEventType.Create;
            const QuestEventType levelEvent  = QuestEventType.Level;

            eventMap = new CollectionMap
            {
                new KeyValuePair <int, int>((int)createEvent, 1),
                new KeyValuePair <int, int>((int)levelEvent, level),
            };
            combinationSlotAddresses = new List <Address>(CombinationSlotCapacity);
            for (var i = 0; i < CombinationSlotCapacity; i++)
            {
                var slotAddress = address.Derive(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        CombinationSlotState.DeriveFormat,
                        i
                        )
                    );
                combinationSlotAddresses.Add(slotAddress);
            }
            UpdateGeneralQuest(new[] { createEvent, levelEvent });
            UpdateCompletedQuest();

            PostConstructor();
        }
Exemple #21
0
 /// <summary>
 /// Adds the quest quietly.
 /// </summary>
 /// <param name="questToAdd">The quest to add.</param>
 public void AddQuestQuiet(IQuest questToAdd)
 {
     if (questToAdd != null)
     {
         QuestList.Add(questToAdd);
         QuestList.Sort();
         OnPropertyChanged(nameof(HasQuests));
     }
 }
Exemple #22
0
 // Use this for initialization
 void Start()
 {
     questText.SetActive(false);
     isDisplayed = false;
     player      = GameObject.FindGameObjectWithTag("Player");
     text        = GameObject.FindGameObjectWithTag("Dialogue").GetComponent <Text>();
     isAccepted  = false;
     questList   = GameObject.FindGameObjectWithTag("UiManager").GetComponent <QuestList>();
 }
Exemple #23
0
 private void OnEnable()
 {
     list                  = (QuestList)target;
     GetTarget             = new SerializedObject(list);
     List_Prop             = GetTarget.FindProperty("Quests");
     QuestFoldouts         = new List <bool>();
     ObjectiveListFoldouts = new List <List <bool> >();
     ObjectiveListSizes    = new List <int>();
 }
        public async void Start(Canvas Tela)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                //Debug.WriteLine("Criando HuD");
                // Interface
                interfaceManager = new InterfaceManager(Tela);
                //Debug.WriteLine("HuD Criada");

                // Carregando itens
                Encyclopedia.LoadEncyclopedia();
                QuestList.LoadQuests();

                // Criar o scenario e instanciar o player
                scene = new LevelScene(interfaceManager.CanvasChunck01);

                // Banco de dados
                //Debug.WriteLine("Carregando banco de dados");
                QuestList.LoadQuests();
                Encyclopedia.LoadNPC();
                CraftingEncyclopedia.LoadCraftings();
                // Quests
                player._Questmanager.ReceiveNewQuest(QuestList.allquests[1]);
                player._Questmanager.ReceiveNewQuest(QuestList.allquests[2]);
                player._Questmanager.actualQuest = player._Questmanager.allQuests[1];

                // Criando HuD
                interfaceManager.GenerateHUD();

                // Crafting
                CraftingStation = new Crafting();

                player._Inventory.AddToBag(new Slot(2, 90));
                player._Inventory.AddToBag(new Slot(13, 1));
                player._Inventory.AddToBag(new Slot(21, 1));
                player._Inventory.AddToBag(new Slot(22, 1));
                player._Inventory.AddToBag(new Slot(23, 1));
                player._Inventory.AddToBag(new Slot(24, 1));
                player._Inventory.AddToBag(new Slot(18, 2));

                foreach (Mob mob in mobs)
                {
                    mob.Start();
                }
                // Update
                TUpdate = new Task(Update);
                TUpdate.Start();
            });

            // Carrega interface



            // Draw
            //TDraw = new Task(Draw);
            //TDraw.Start();
        }
Exemple #25
0
 public City()
 {
     this.InitializeComponent();
     QuestList.LoadQuestList();
     this.NavigationCacheMode           = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
     Window.Current.CoreWindow.KeyDown += SkillAsync;
     song.Source = MediaSource.CreateFromUri(new System.Uri("ms-appx:///Assets/Musicas/City.mp3"));
     song.Play();
 }
        public override void Execute(Context c)
        {
            if ((m_parameters.Parameters == null || m_parameters.Parameters.Count == 0) && m_paramFunction == null)
            {
                m_worldModel.RunProcedure(m_procedure);
            }
            else
            {
                Parameters paramValues = new Parameters();
                Element    proc        = m_worldModel.Procedure(m_procedure);

                QuestList <string> paramNames = proc.Fields[FieldDefinitions.ParamNames];

                int paramCount = m_parameters.Parameters.Count;
                if (m_paramFunction != null)
                {
                    paramCount++;
                }

                if (paramCount > paramNames.Count)
                {
                    throw new Exception(string.Format("Too many parameters passed to {0} function - {1} passed, but only {2} expected",
                                                      m_procedure,
                                                      paramCount,
                                                      paramNames.Count));
                }

                if (m_worldModel.Version >= WorldModelVersion.v520)
                {
                    // Only check for too few parameters for games for Quest 5.2 or later, as previous Quest versions
                    // would ignore this (but would usually still fail when the function was run, as the required
                    // variable wouldn't exist)

                    if (paramCount < paramNames.Count)
                    {
                        throw new Exception(string.Format("Too few parameters passed to {0} function - only {1} passed, but {2} expected",
                                                          m_procedure,
                                                          paramCount,
                                                          paramNames.Count));
                    }
                }

                int cnt = 0;
                foreach (IFunction <object> f in m_parameters.Parameters)
                {
                    paramValues.Add((string)paramNames[cnt], f.Execute(c));
                    cnt++;
                }

                if (m_paramFunction != null)
                {
                    paramValues.Add((string)paramNames[cnt], m_paramFunction);
                }

                m_worldModel.RunProcedure(m_procedure, paramValues, false);
            }
        }
Exemple #27
0
 public QuestList<Element> AllCommands()
 {
     QuestList<Element> result = new QuestList<Element>();
     foreach (Element item in m_worldModel.GetAllObjects())
     {
         if (item.Type == ObjectType.Command)
             result.Add(item);
     }
     return result;
 }
 public QuestChainEditorViewModel(IQuestPicker picker, QuestList quests)
 {
     GraphViewModel = new GraphViewModel(picker, quests);
     //GraphViewModel.AddElement(new NodeViewModel("Spare Parts Up In Here!"), 10000, 10000);
     //GraphViewModel.AddElement(new NodeViewModel("In Defense of Krom'gar Fortress"), 10100, 10000);
     //GraphViewModel.AddElement(new NodeViewModel("Eyes and Ears: Malaka'jin"), 10200, 10000);
     //GraphViewModel.AddElement(new NodeViewModel("Da Voodoo: Stormer Heart"), 10300, 10000);
     //GraphViewModel.AddElement(new NodeViewModel("Da Voodoo: Ram Horns"), 10300, 10000);
     //GraphViewModel.AddElement(new NodeViewModel("Da Voodoo: Resonite Crystal"), 10300, 10000);
 }
Exemple #29
0
        public QuestList<Element> AllTurnScripts()
        {
            QuestList<Element> result = new QuestList<Element>();

            foreach (Element item in m_worldModel.GetAllObjects().Where(o => o.Type == ObjectType.TurnScript))
            {
                result.Add(item);
            }
            return result;
        }
        public override void displayPlayer(PlayerInfo _pInfo)
        {
            string output = "";

            output += new ClientInfoList(_pInfo, _options).DisplayShort(_sep);
            output += _sep;
            output += new QuestList(_pInfo, _options).Display(_sep);

            SendOutput(output);
        }
Exemple #31
0
        public QuestList <Element> AllTurnScripts()
        {
            QuestList <Element> result = new QuestList <Element>();

            foreach (Element item in m_worldModel.GetAllObjects().Where(o => o.Type == ObjectType.TurnScript))
            {
                result.Add(item);
            }
            return(result);
        }
    void Start()
    {
        panelTransform = GameObject.Find("QuestsUI/Panel").GetComponent <RectTransform>();
        panel          = GameObject.Find("QuestsUI/Panel");
        questTitle     = GameObject.Find("QuestsUI/Panel/Description");
        background     = GameObject.Find("QuestsUI/Background");

        list       = this.GetComponent <QuestList>();
        targetlist = this.GetComponent <QuestListTarget>();
    }
Exemple #33
0
        public void Setup()
        {
            m_worldModel = new WorldModel();

            m_object = m_worldModel.GetElementFactory(ElementType.Object).Create("object");
            var list = new QuestList<object> {"string1"};
            var dictionary = new QuestDictionary<object> {{"key1", "nested string"}};
            list.Add(dictionary);
            m_object.Fields.Set("list", list);
            m_object.Fields.Resolve(null);
        }
Exemple #34
0
        public void ExcludeTest()
        {
            //string lists
            var stringList = new QuestList<string>() { "a", "a", "b", "c" };

            var expected = new QuestList<string>() { "b", "c" };
            var actual = stringList.Exclude("a");
            Assert.IsTrue(actual.SequenceEqual(expected));

            //element lists
            var elList = new QuestList<Element>() { a, a, b, c };

            var expectedEList = new QuestList<Element>() { b, c };
            var actualEList = elList.Exclude(a);
            Assert.IsTrue(actualEList.SequenceEqual(expectedEList));
        }
Exemple #35
0
        protected override object ConvertField(Element e, string fieldName, object value)
        {
            if (fieldName == "steps")
            {
                QuestList<string> steps = (QuestList<string>)value;
                QuestList<string> result = new QuestList<string>();

                foreach (string step in steps)
                {
                    if (step.StartsWith("assert:"))
                    {
                        string expr = step.Substring(7);
                        Expression expression = new Expression(expr, e.Loader);
                        result.Add("assert:" + expression.Save());
                    }
                    else
                    {
                        result.Add(step);
                    }
                }
                return result;
            }
            return value;
        }
Exemple #36
0
 public string ShowMenu(string caption, QuestList<string> options, bool allowCancel)
 {
     return m_worldModel.DisplayMenu(caption, options, allowCancel);
 }
Exemple #37
0
 public void RecordWalkthrough(string name, IEnumerable<string> steps)
 {
     if (!steps.Any()) return;
     StartTransaction(string.Format("Add {0} walkthrough steps", steps.Count()));
     Element walkthrough = m_worldModel.Elements.Get(ElementType.Walkthrough, name);
     QuestList<string> newSteps = new QuestList<string>(steps);
     // TO DO: Use MergeLists
     walkthrough.Fields[FieldDefinitions.Steps] = walkthrough.Fields[FieldDefinitions.Steps] + newSteps;
     EndTransaction();
 }
Exemple #38
0
        public IEditableList<string> CreateNewEditableList(string parent, string attribute, string item, bool useTransaction)
        {
            if (useTransaction)
            {
                WorldModel.UndoLogger.StartTransaction(string.Format("Set '{0}' {1} to '{2}'", parent, attribute, item));
            }
            Element element = (parent == null) ? null : m_worldModel.Elements.Get(parent);

            QuestList<string> newList = new QuestList<string>();

            if (item != null) newList.Add(item);

            if (element != null)
            {
                element.Fields.Set(attribute, newList);

                // setting an element field will clone the value, so we want to return the new list
                newList = element.Fields.GetAsType<QuestList<string>>(attribute);
            }

            EditableList<string> newValue = new EditableList<string>(this, newList);

            if (useTransaction)
            {
                WorldModel.UndoLogger.EndTransaction();
            }

            return newValue;
        }