Exemplo n.º 1
0
        public void NextStage()
        {
            ushort tokunlocked = (ushort)Stage.Objectives.First().Objective.TokCompleted;

            foreach (uint Plr in ActivePlayers)
            {
                Player targPlayer = Player.GetPlayer(Plr);
                if (targPlayer != null)
                {
                    if (tokunlocked > 0)
                    {
                        targPlayer.TokInterface.AddTok(tokunlocked);
                    }
                }
            }

            Stage.Cleanup();
            int nextStageId = Stage.Number + 1;

            EvtInterface.RemoveEvent(Failed);

            foreach (PQuestStage sStage in Stages)
            {
                if (sStage.Number == nextStageId)
                {
                    Stage = sStage;
                    Stage.Reset();
                    _stageTimeEnd = TCPManager.GetTimeStamp() + ((Stage.Time > 0 ? Stage.Time : TIME_EACH_STAGE));
                    if (sStage.Objectives.First().Objective.Type != (byte)Objective_Type.QUEST_PROTECT_UNIT)
                    {
                        EvtInterface.AddEvent(Failed, (Stage.Time > 0 ? Stage.Time : TIME_EACH_STAGE) * 1000, 1);
                    }

                    foreach (uint Plr in ActivePlayers)
                    {
                        Player targPlayer = Player.GetPlayer(Plr);
                        if (targPlayer != null)
                        {
                            SendCurrentStage(targPlayer);
                            if (Stage.Number > 1)
                            {
                                targPlayer.AddInfluence((ushort)Info.ChapterId, 250);
                            }
                        }
                    }
                    return;
                }
            }

            End();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the public quest's objectives and stages.
        /// </summary>
        /// <param name="info"></param>
        public PublicQuest(PQuest_Info info)
            : this()
        {
            Info          = info;
            Name          = info.Name;
            ActivePlayers = new List <uint>();
            Players       = new Dictionary <uint, ContributionInfo>();
            Stages        = new List <PQuestStage>();

            foreach (PQuest_Objective obj in info.Objectives)
            {
                // Create a new public quest stage for this objective, if one did not previously exist.
                bool exists = Stages.Any(x => x.StageName == obj.StageName);

                if (!exists)
                {
                    PQuestStage stage = new PQuestStage
                    {
                        StageName   = obj.StageName,
                        Number      = Stages.Count,
                        Description = obj.Description,
                        Time        = obj.Time
                    };
                    Stages.Add(stage);
                }

                // Assign this objective to its public quest stage.
                foreach (PQuestStage stage in Stages)
                {
                    if (stage.StageName == obj.StageName)
                    {
                        PQuestObjective objective = new PQuestObjective
                        {
                            Quest       = this,
                            Objective   = obj,
                            ObjectiveID = obj.Guid,
                            Count       = 0
                        };
                        stage.AddObjective(objective);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Start()
        {
            if (_started || _ended)
            {
                return;
            }

            foreach (PQuestStage sStage in Stages)
            {
                try
                {
                    if (sStage.Number == 0)
                    {
                        Stage = sStage;
                        Stage.Reset();
                        foreach (uint Plr in ActivePlayers)
                        {
                            Player targPlayer = Player.GetPlayer(Plr);
                            if (targPlayer != null)
                            {
                                SendCurrentStage(targPlayer);
                            }
                        }
                        break;
                    }
                }
                catch
                {
                    continue;
                }
            }

            #if DEBUG
            Log.Success("PQuest", "Starting Quest " + Info.Name);
            #endif

            _started = true;
        }