Ejemplo n.º 1
0
        private void OnProgressChanged(Player player, QuestLogEntry entry, int index, int progress)
        {
            // We can choose to give rewards here when all requirements have suddenly been met
            var step = entry.CurrentStep;

            // Update the user about their progress
            var progressUpdate = new ServerQuestProgressUpdate(entry.QuestInfo.QuestId, index, progress);
            player.Client.Send(progressUpdate);

            entry.Quest.Script.OnQuestStepCompleted(player, step);

            if (step.IsRequirementsMet(player, entry.Progress))
            {
                if (!entry.IsLastStep)
                {
                    // Advance the step and take any requirements
                    step.TakeRequirements(player);
                    entry.AdvanceStep();

                    var message = new ServerSendGameMessagePacket(GameMessage.QuestLogUpdated, new List<string>() { entry.Quest.Name });
                    player.Client.Send(message);

                    var questUpdate = new ServerSendQuestListPacket(player.QuestLog);
                    player.Client.Send(questUpdate);

                }

                    // If is last step, only advance if we can give reward
                else
                {
                    var canGiveRewards = entry.Quest.CanGiveReward(player);

                    if (canGiveRewards)
                    {
                        step.TakeRequirements(player);
                        entry.AdvanceStep();
                    }

                    else
                    {
                        // Let them know for some reason the rewards were not met
                        var message = new ServerSendGameMessagePacket(GameMessage.QuestCannotGiveReward);
                        player.Client.Send(message);
                    }

                }

            }

            // If there's no more steps possible to get through, give the reward
            if (entry.CurrentStep == null)
            {
                // Attempt to complete the quest
                var success = entry.Quest.TryCompleteQuest(player);

                if (success)
                {
                    var message = new ServerSendGameMessagePacket(GameMessage.QuestCompleted, new List<string>() { entry.Quest.Name});
                    player.Client.Send(message);

                    var questUpdate = new ServerSendQuestListPacket(player.QuestLog);
                    player.Client.Send(questUpdate);
                }

                else
                {
                    var message = new ServerSendGameMessagePacket(GameMessage.QuestCannotGiveReward);
                    player.Client.Send(message);
                }

            }
        }
Ejemplo n.º 2
0
 private void QuestLogOnQuestAccepted(QuestLogEntry entry)
 {
     OnAcceptedQuest(this);
     entry.Quest.Script.OnQuestStarted(this);
 }
Ejemplo n.º 3
0
 protected virtual void OnProgressUpdate(QuestLogEntry entry, int index, int progress)
 {
     QuestLogProgressEvent handler = ProgressUpdate;
     if (handler != null) handler(entry, index, progress);
 }