public bool IsQuestValid(IQuest quest) { bool isValid = true; var xml = new XmlDocument(); xml.LoadXml(quest.WholeQuestXml); var names = new XmlNamespaceManager(xml.NameTable); names.AddNamespace("x", "http://www.martinvseticka.eu/SoTh"); XmlNodeList nodes = xml.SelectNodes("/x:SokobanQuest/x:Round/x:GameObjects/*", names); XmlValidator xmlValidator = new XmlValidator(); xmlValidator.AddSchema(null, Sokoban.View.GameDocsComponents.Properties.Resources.QuestSchema); // main schema // We have to prevent to adding a schema twice to the collection of schemas (to xmlValidator) // Therefore we use Dictonary and then we extract each schema exactly once. Dictionary<string, string> schemas = new Dictionary<string, string>(); // schemas from plugins foreach (XmlNode node in nodes) { schemas[node.Name] = gameRepository.PluginService.GetPluginSchema(node.Name); } foreach (KeyValuePair<string, string> pair in schemas) { xmlValidator.AddSchema(null, pair.Value); } isValid = xmlValidator.IsValid(quest.WholeQuestXml); questValidationErrorMessage = (isValid) ? "" : xmlValidator.GetErrorMessage(); return isValid; }
public void Accept(IQuest quest, Action<QuestAcceptStatus, IQuest> callback) { Misc.CheckNotNull(quest); Misc.CheckNotNull(callback); callback = CallbackUtils.ToOnGameThread<QuestAcceptStatus, IQuest>(callback); var convertedQuest = quest as NativeQuest; if (convertedQuest == null) { GooglePlayGames.OurUtils.Logger.e("Encountered quest that was not generated by this IQuestClient"); callback(QuestAcceptStatus.BadInput, null); return; } mManager.Accept(convertedQuest, response => { if (response.RequestSucceeded()) { callback(QuestAcceptStatus.Success, response.AcceptedQuest()); } else { callback(FromAcceptStatus(response.ResponseStatus()), null); } }); }
public void Update(IQuest quest, ref World world, GameTime gameTime) { if (_foundItem) { Announcer.Instance.Announce("You find the cursed doll and complete your quest!", MessageTypes.QuestInformation); quest.QuestCompleted(); } }
public Game(IQuest quest, GameMode gameMode, GameDisplayType gameDisplayType, INetworkService networkService, IUserInquirer userInquirer) { this.quest = quest; this.gameDisplayType = gameDisplayType; this.gameMode = gameMode; this.networkService = networkService; this.userInquirer = userInquirer; if (this.quest == null) throw new NotValidQuestException("Quest is not valid"); }
public void Update(IQuest quest, ref World world, GameTime gameTime) { if (_targetKilled) { Announcer.Instance.Announce("You destroy the plant and complete your quest!", MessageTypes.QuestInformation); quest.QuestCompleted(); } else if (_targetSpotted == false) { if (world.CanPlayerSeeWorldIndex(_target.WorldIndex)) { Announcer.Instance.Announce("The great beast lurks before you. Your moment of victory is at hand!", MessageTypes.QuestInformation); _targetSpotted = true; } } }
private static void UpdateWpfItem(StackPanel item_line, IQuest vm) { item_line.Children.Clear(); if (vm.Type == Model.Voc) { VocWpfController.AddIntoThis(vm as VocVM, item_line); } else if (vm.Type == Model.Pron) { PronWpfController.AddIntoThis(vm as PronVM, item_line); } else if (vm.Type == Model.Spell) { SpellWpfController.AddIntoThis(vm as SpellVM, item_line); } }
// Initialise quests public void InitQuests() { // Set the number of quests and initialise the quests array numberOfQuests = iQuests.Length; quests = new IQuest[numberOfQuests]; // List of quests List <IQuest> selectedQuests = new List <IQuest>(); // Select quests while (selectedQuests.Count < numberOfQuests - 1) { // Random quest IQuest iQuest = iQuests[Random.Range(0, quests.Length - 1)]; // Add selected quest if (!selectedQuests.Contains(iQuest)) { selectedQuests.Add(iQuest); } } // Copy to array selectedQuests.CopyTo(quests); // Initialise the initial quest and quest itmes InitQuestController(); // Set the last gamemode as exit quests[numberOfQuests - 1] = iQuests[iQuests.Length - 1]; // Set the number of game quests GameDataManager.instance.NumberOfQuests(numberOfQuests); // Assign the game quests names for (int i = 0; i < quests.Length; i++) { GameDataManager.instance.SetQuestNames(i, quests[i].QuestName()); } Debug.Log("QUEST - INIT - COMPLETE"); // Initialise the civillian InitCivillian(); }
/// <summary> /// Tries to finish a quest for the owner. /// </summary> /// <param name="quest">The quest to turn in.</param> /// <returns>True if the quest was successfully turned in; false if the owner did not have the <paramref name="quest"/> /// in their active quest list, if the quest was invalid, or if they did not have the requirements needed /// to finish the quest.</returns> public bool TryFinishQuest(IQuest <TCharacter> quest) { // Make sure they even have this in their active quests if (!_activeQuests.Contains(quest)) { return(false); } // Check for the finish requirements if (!quest.FinishRequirements.HasRequirements(Owner)) { return(false); } // Ensure there is room to give them the reward(s) if (!quest.Rewards.CanGive(Owner)) { NotifyCannotGiveQuestRewards(quest); return(false); } Debug.Assert(quest.Repeatable || !HasCompletedQuest(quest), "Uh-oh, this user has already completed this quest!"); // Remove from the active quests and give the rewards var removed = _activeQuests.Remove(quest); Debug.Assert(removed); // Add the quest to the completed quests list _completedQuests.Add(quest); quest.Rewards.Give(Owner); // Raise events OnQuestFinished(quest); if (QuestFinished != null) { QuestFinished.Raise(this, EventArgsHelper.Create(quest)); } return(true); }
public QuestGiver(string name, Point2D position, string iddleAnimationPath, int framesForIddleAnimation, IQuest quest, string initialText, string completedText, int offsetFromTopForInitial, int offsetFromTopForCompleted, int heightForText, int experienceOnFinish) : base(name, position, new Rectangle2D((int)position.X + Constant.PeasantWidth / 2, (int)position.Y, Constant.PeasantWidth, Constant.DefaultHeighForEverything)) { this.IddleAnimation = new FrameAnimation( iddleAnimationPath, framesForIddleAnimation); this.AnimationSpeed = 0.1f; this.IddleAnimation.IsActive = true; this.Quest = quest; this.InitialTextOnly = initialText; this.CompletedTextOnly = completedText; this.Position = position; this.InitialText = new Text(this.InitialTextOnly, false, (int)this.Position.X, (int)this.Position.Y - offsetFromTopForInitial, Constant.QuestGiverTextWidth, heightForText, Constant.QuestGiverTextDelayInMilliseconds, Color.White, false, Constant.QuestFontPath); this.CompletedText = new Text(this.CompletedTextOnly, false, (int)this.Position.X, (int)this.Position.Y - offsetFromTopForCompleted, Constant.QuestGiverTextWidth, heightForText, Constant.QuestGiverTextDelayInMilliseconds, Color.White, false, Constant.QuestFontPath); this.ExperienceOnFinish = experienceOnFinish; }
public GameDeskControl Add(IQuest quest, GameMode gameMode) { if (GameViews.Count == 1) { if (GameViews[0] is Introduction) { GameViews.RemoveAt(0); } } GameDeskControl doc = new GameDeskControl(quest, gameMode, userInquirer); doc.Title = quest.Name; doc.InfoTip = doc.Title; doc.ContentTypeDescription = ""; doc.Closing += new EventHandler<CancelEventArgs>(doc_Closing); doc.Closed += new EventHandler(doc_Closed); doc.InfoPanel.SizeChanged += new SizeChangedEventHandler(doc.ResizeInfoPanel); doc.SetSounds(this.isSoundOn); GameViews.Add(doc); doc.Resize(GamesDocumentPane.ActualWidth, GamesDocumentPane.ActualHeight); //this.SelectedIndex = GameViews.Count - 1; this.SetActiveGameChanged(doc); return doc; }
public void ShowSpecificQuestUI(IQuest quest, Action<QuestUiResult, IQuest, IQuestMilestone> callback) { Misc.CheckNotNull(quest); Misc.CheckNotNull(callback); callback = CallbackUtils.ToOnGameThread<QuestUiResult, IQuest, IQuestMilestone>(callback); var convertedQuest = quest as NativeQuest; if (convertedQuest == null) { GooglePlayGames.OurUtils.Logger.e("Encountered quest that was not generated by this IQuestClient"); callback(QuestUiResult.BadInput, null, null); return; } mManager.ShowQuestUI(convertedQuest, FromQuestUICallback(callback)); }
private void AcceptQuest(IQuest toAccept) { Debug.Log("Accepting Quest: " + toAccept); PlayGamesPlatform.Instance.Quests.Accept(toAccept, (QuestAcceptStatus status, IQuest quest) => { if (status == QuestAcceptStatus.Success) { statusText.text = "Quest Accepted: " + quest.Name; } else { statusText.text = "Quest Accept Failed: " + status; } }); }
void World_DoneWithQuest(IQuest sender) { _quests.Remove(sender); }
public IGameMatch QuestSelected(int leaguesID, int roundsID, IQuest quest, GameMode gameMode) { return QuestSelected(leaguesID, roundsID, quest, gameMode, null); // IConnection == null }
internal void ShowQuestsAndEventsUi() { if (mQuest != null) { mStatus = "Selected Quest: " + mQuest.Id + "\n"; } if (mQuestMilestone != null) { mStatus += "Selected Milestone: " + mQuestMilestone.Id; } DrawStatus(); DrawTitle("Quests and Events"); if (GUI.Button(CalcGrid(0, 1), "Fetch All Events")) { SetStandBy("Fetching All Events"); PlayGamesPlatform.Instance.Events.FetchAllEvents( DataSource.ReadNetworkOnly, (status, events) => { mStatus = "Fetch All Status: " + status + "\n"; mStatus += "Events: [" + string.Join(",", events.Select(g => g.Id).ToArray()) + "]"; events.ForEach(e => Logger.d("Retrieved event: " + e.ToString())); EndStandBy(); }); } else if (GUI.Button(CalcGrid(1, 1), "Fetch Event")) { SetStandBy("Fetching Event"); PlayGamesPlatform.Instance.Events.FetchEvent( DataSource.ReadNetworkOnly, Settings.Event, (status, fetchedEvent) => { mStatus = "Fetch Status: " + status + "\n"; if (fetchedEvent != null) { mStatus += "Event: [" + fetchedEvent.Id + ", " + fetchedEvent.Description + "]"; Logger.d("Fetched event: " + fetchedEvent.ToString()); } EndStandBy(); }); } else if (GUI.Button(CalcGrid(0, 2), "Increment Event")) { PlayGamesPlatform.Instance.Events.IncrementEvent(Settings.Event, 10); } if (GUI.Button(CalcGrid(1, 2), "Fetch Open Quests")) { FetchQuestList(QuestFetchFlags.Open); } else if (GUI.Button(CalcGrid(0, 3), "Fetch Upcoming Quests")) { FetchQuestList(QuestFetchFlags.Upcoming); } else if (GUI.Button(CalcGrid(1, 3), "Fetch Accepted Quests")) { FetchQuestList(QuestFetchFlags.Accepted); } else if (GUI.Button(CalcGrid(0, 4), "Show All Quests UI")) { SetStandBy("Showing all Quest UI"); mQuest = null; mQuestMilestone = null; PlayGamesPlatform.Instance.Quests.ShowAllQuestsUI(HandleQuestUI); } else if (GUI.Button(CalcGrid(1, 4), "Show Quest UI")) { if (mQuest == null) { mStatus = "Could not show Quest UI - no quest selected"; } else { PlayGamesPlatform.Instance.Quests.ShowSpecificQuestUI(mQuest, HandleQuestUI); } } else if (GUI.Button(CalcGrid(0, 5), "Fetch Quest")) { if (mQuest == null) { mStatus = "Could not fetch Quest - no quest selected"; } else { SetStandBy("Fetching Quest"); PlayGamesPlatform.Instance.Quests.Fetch( DataSource.ReadNetworkOnly, mQuest.Id, (status, quest) => { mStatus = "Fetch Quest Status: " + status + "\n"; mQuest = quest; Logger.d("Fetched quest " + quest); EndStandBy(); }); } } else if (GUI.Button(CalcGrid(1, 5), "Accept Quest")) { if (mQuest == null) { mStatus = "Could not accept Quest - no quest selected"; } else { SetStandBy("Accepting quest"); PlayGamesPlatform.Instance.Quests.Accept( mQuest, (status, quest) => { mStatus = "Accept Quest Status: " + status + "\n"; mQuest = quest; Logger.d("Accepted quest " + quest); EndStandBy(); }); } } else if (GUI.Button(CalcGrid(0, 6), "Claim Milestone")) { if (mQuestMilestone == null) { mStatus = "Could not claim milestone - no milestone selected"; } else { SetStandBy("Claiming milestone"); PlayGamesPlatform.Instance.Quests.ClaimMilestone( mQuestMilestone, (status, quest, milestone) => { mStatus = "Claim milestone Status: " + status + "\n"; mQuest = quest; mQuestMilestone = milestone; Logger.d("Claim quest: " + quest); Logger.d("Claim milestone: " + milestone); EndStandBy(); }); } } if (GUI.Button(CalcGrid(1, 6), "Back")) { mUi = Ui.Main; } }
internal void HandleQuestUI(QuestUiResult result, IQuest quest, IQuestMilestone milestone) { mStatus = "Show UI Status: " + mStatus + "\n"; Logger.d("UI Status: " + result); if (quest != null) { mQuest = quest; mStatus += "User wanted to accept quest " + quest.Id; Logger.d("User Accepted quest " + quest.ToString()); } else if (milestone != null) { mQuestMilestone = milestone; mStatus += "User wanted to claim milestone " + milestone.Id; Logger.d("Claimed milestone " + milestone.ToString()); Logger.d("Completion data: " + System.Text.ASCIIEncoding.Default.GetString(milestone.CompletionRewardData)); } EndStandBy(); }
internal void FetchQuestList(QuestFetchFlags flags) { SetStandBy("Fetching Quests, flags: " + flags); PlayGamesPlatform.Instance.Quests.FetchMatchingState( DataSource.ReadNetworkOnly, flags, (status, quests) => { mStatus = "Fetch Status: " + status + "\n"; mStatus += "Quests: [" + string.Join(",", quests.Select(g => g.Id).ToArray()) + "]"; if (quests.Count != 0) { mQuest = quests[0]; } quests.ForEach(q => Logger.d("Retrieved quest: " + q.ToString())); EndStandBy(); }); }
public void Add(IQuest quest) { GameDeskControl doc = new GameDeskControl(quest); doc.Title = quest.Name; doc.InfoTip = "Info tipo for " + doc.Title; doc.ContentTypeDescription = ""; doc.Closing += new EventHandler<CancelEventArgs>(doc_Closing); doc.Closed += new EventHandler(doc_Closed); doc.InfoPanel.SizeChanged+=new SizeChangedEventHandler(doc.ResizeInfoPanel); GameViews.Add(doc); doc.Resize(GamesDocumentPane.ActualWidth, GamesDocumentPane.ActualHeight); }
public QuestionController(IQuest question) { _Question = question; }
public IGameMatch QuestSelected(int leaguesID, int roundsID, IQuest quest, GameMode gameMode) { // TODO add params return this.Add(quest, gameMode); }
public IGameMatch QuestSelected(int leaguesID, int roundsID, IQuest quest, GameMode gameMode, IConnection connection) { bool wasOpened = true; IGameMatch gameMatch = null; string errorMesssage = ""; //try //{ gameMatch = this.gameManager.QuestSelected(leaguesID, roundsID, quest, gameMode); //} /* catch (PluginLoadFailedException e) { errorMesssage = "The league cannot be loaded. There's a problem in plugin: " + e.Message; wasOpened = false; } catch (NotValidQuestException e) { errorMesssage = "The league you've chosen cannot be run. More information in Console."; consolePane.ErrorMessage(ErrorMessageSeverity.Medium, "GameManager", "The league you've chosen cannot be run. Additional message: " + e.Message); wasOpened = false; } catch (Exception e) { errorMesssage = "The league you've chosen cannot be run. More information in Console."; consolePane.ErrorMessage(ErrorMessageSeverity.Medium, "GameManager", "The league you've chosen cannot be run. Additional message: " + e.Message); wasOpened = false; }*/ if (wasOpened == false) { MessageBoxShow(errorMesssage); } if (wasOpened == true && gameMode == GameMode.TwoPlayers) { if (connection != null) { try { gameMatch.SetNetworkConnection(connection); } catch (InvalidStateException e) { MessageBoxShow("Error in setting up network game occured: " + e.Message); } } else { InitConnection ic = new InitConnection(leaguesID, roundsID, ProfileRepository.Instance, consolePane, this, gameMatch); ic.Owner = this; ic.Closing += new System.ComponentModel.CancelEventHandler(modalWindow_Closing); ic.Show(); } return gameMatch; } else { return null; } }
public void QuestCompleted(IQuest quest, World world) { Announcer.Instance.Announce("You receive an item for your hard work.", MessageTypes.QuestInformation); _itemToReward.Get(world.Player); }