Esempio n. 1
0
        public Npc(NpcTemplate npcTemplate)
            : base(npcTemplate.Sprite)
        {
            Name = npcTemplate.Name;

            // Persist
            _npcTemplate = npcTemplate;

            Quests = new List<Quest>();
            foreach (var questEntry in _npcTemplate.Quests)
            {
                var quest = new Quest(questEntry);
                Quests.Add(quest);
            }
        }
Esempio n. 2
0
        public QuestLogEntry(Quest quest, UserQuestInfo questInfo)
        {
            _quest = quest;
            _questInfo = questInfo;

            if (_questInfo.State == QuestState.InProgress)
            {
                // Add an entry for each current requirement
                for (int i = 0; i < CurrentStep.Requirements.Count; i++)
                    _requirementProgress.Add(0);

                // Copy over the new values of our quest tracking
                for (int i = 0; i < _questInfo.RequirementProgress.Count; i++)
                    _requirementProgress[i] = _questInfo.RequirementProgress[i].Progress;
            }
        }
Esempio n. 3
0
        public bool CanPlayerGetQuest(Quest quest, Player player)
        {
            // If the player has the quest completed already, decline
            foreach (var entry in player.QuestLog)
            {
                if (entry.Quest.QuestId == quest.QuestId && entry.State != QuestState.Available)
                    return false;
            }

            // Check if the player
            foreach (var requirement in quest.StartRequirements)
            {
                if (!requirement.HasRequirements(player, 0))
                    return false;
            }

            // The player can flag this quest up
            return true;
        }
Esempio n. 4
0
 public void Init(Quest quest)
 {
     _quest = quest;
 }
Esempio n. 5
0
 /// <summary>
 /// Attempts to finish a quest that a player is attempting to turn in.
 /// </summary>
 /// <param name="quest"></param>
 /// <param name="player"></param>
 /// <returns></returns>
 public bool TryFinishQuest(Quest quest, Player player)
 {
     throw new NotImplementedException();
 }
Esempio n. 6
0
        /// <summary>
        /// Gives a player a quest. If the quest was already completed, it will be marked as in progress once again.
        /// If the quest has not been seen before, it will be marked as such.
        /// </summary>
        /// <param name="quest"></param>
        /// <param name="player"></param>
        public void GivePlayerQuest(Quest quest, Player player)
        {
            // Attempt to give a quest to the player
            player.QuestLog.TryAddQuest(quest);

            // Send a notification to let them know
            var message = new ServerSendGameMessagePacket(GameMessage.NewQuest);
            player.Client.Send(message);

            Logger.Instance.Info("{0} has been given the quest {1} [#{2}]", player.Name, quest.Name, quest.QuestId);
        }