Esempio n. 1
0
        public override void Stop()
        {
            EndAction?.Stop();
            EndAction = null;

            var chrList = Maps.SelectMany(m => m.Characters).ToList();

            foreach (var chr in chrList)
            {
                chr.Inventory.TakeItem(JewelItem, (short)chr.Inventory.ItemAmountAvailable(JewelItem));
                chr.ChangeMap(ExitMap.ID);
            }

            foreach (var map in Maps)
            {
                map.Mobs.Clear();
                map.Reactors.Clear();
                map.DropPool.Clear();

                map.TimerEndTime = MasterThread.CurrentTime;
                map.OnEnter      = null;
                map.OnExit       = null;
                map.OnTimerEnd   = null;
            }

            EventHelper.CloseAllPortals(Maps);

            base.Stop();
        }
Esempio n. 2
0
 public void AddRepeatingAction(RepeatingAction pAction)
 {
     AddCallback((a) =>
     {
         _repeatingActions.Add(pAction);
     });
 }
Esempio n. 3
0
 public override void Start(bool joinDuringEvent = false)
 {
     LobbyMap.Characters.ToList().ForEach(c => c.ChangeMap(LobbyMapId, LobbyMap.SpawnPoints[0]));
     EventHelper.OpenAllPortals(Maps);
     EventHelper.ApplyTimer(Maps, EventTimeLimitSeconds);
     End = RepeatingAction.Start("FitnessWatcher", Stop, EventTimeLimitSeconds * 1000, 0);
     base.Start(joinDuringEvent);
 }
            /// <summary>
            /// Create a new Repeating Action
            /// </summary>
            /// <param name="pName">Unique identifier for this action</param>
            /// <param name="pAction">Logic that is ran</param>
            /// <param name="start">Amount of milliseconds delay for first run</param>
            /// <param name="repeat">Amount of milliseconds between each run. Use 0 to have a one-time action.</param>
            /// <param name="pEndCondition">When this returns true, the repeating action will be deregistered.</param>
            public static RepeatingAction Start(string pName, Action <long> pAction, long start, long repeat,
                                                Func <bool> pEndCondition = null)
            {
                var x = new RepeatingAction(pName, pAction, start, repeat, pEndCondition);

                x.Start();
                return(x);
            }
Esempio n. 5
0
 public override void Stop()
 {
     End?.Stop();
     End = null;
     EventHelper.WarpEveryone(Maps, LoseMapId);
     EventHelper.ResetTimer(Maps);
     base.Stop();
 }
Esempio n. 6
0
 public void StopEarly()
 {
     curQuestion?.Stop();
     curQuestion = null;
     EventHelper.WarpEveryone(QuizMap, LoseMapId);
     QuizMap.ChatEnabled = true;
     QuizMap.PortalsOpen = true;
     base.Stop();
 }
Esempio n. 7
0
        private void AskQuestion()
        {
            QuizData Question = questions.Last();

            Program.MainForm.LogDebug("Asking question.... Answer: " + Question.Answer);
            questions.RemoveAt(questions.Count - 1);
            QuizMap.SendPacket(OXPackets.QuizQuestion(true, Question.QuestionPage, Question.QuestionIdx));
            curQuestion = RepeatingAction.Start("Quiz - " + (questions.Count - 1) + " - question", t => CheckAnswer(Question), 30 * 1000, 0);
        }
Esempio n. 8
0
 public override void Stop()
 {
     curQuestion?.Stop();
     curQuestion = null;
     EventHelper.WarpEveryone(QuizMap, WinMapId);
     QuizMap.ChatEnabled = true;
     QuizMap.PortalsOpen = true;
     base.Stop();
 }
Esempio n. 9
0
        public RepeatingAction StartRepeatingAction(string id, Action action, int delay = 1000, bool manage = true)
        {
            RepeatingAction task = new RepeatingAction(action, id, delay);

            if (manage)
            {
                Tasks.Add(task);
            }
            return(task);
        }
Esempio n. 10
0
        public override void Stop()
        {
            Program.MainForm.LogDebug("Stopping." + Environment.StackTrace);
            End?.Stop();
            End = null;

            List <Character> Winners;
            List <Character> Losers;

            if (SnowballMap.GetWinner() == SnowballEventState.MAPLE_WIN)
            {
                Winners = MapleTeam.ToList();
                Losers  = StoryTeam.ToList();
            }
            else
            {
                Winners = StoryTeam.ToList();
                Losers  = MapleTeam.ToList();
            }

            _log.Info("Total players: " + (Winners.Count + Losers.Count));
            _log.Info("Winners: " + string.Join(", ", Winners.Select(x => x.Name)));
            _log.Info("Losers: " + string.Join(", ", Losers.Select(x => x.Name)));

            Winners.ForEach(c =>
            {
                MapPacket.MapEffect(c, 4, "Coconut/Victory", true);
                MapPacket.MapEffect(c, 3, "event/coconut/victory", true);
            });
            Losers.ForEach(c =>
            {
                MapPacket.MapEffect(c, 4, "Coconut/Failed", true);
                MapPacket.MapEffect(c, 3, "event/coconut/lose", true);
            });

            RepeatingAction.Start("snowball warper", e =>
            {
                Winners.ForEach(c => c.ChangeMap(WinMapId));
                Losers.ForEach(c => c.ChangeMap(LoseMapId));
                SnowballMap.TimerEndTime = MasterThread.CurrentTime;
                MapleTeam.Clear();
                StoryTeam.Clear();
                SnowballMap.Reset();
                base.Stop();
            }, 10 * 1000, 0);
        }
Esempio n. 11
0
        public override void Start(bool joinDuringEvent = false)
        {
            foreach (var map in Maps)
            {
                map.PortalsOpen = true;
                map.StartTimer(EventRuntimeSeconds);
            }

            foreach (var chr in HubMap.Characters.ToList())
            {
                //start everyone in same location
                chr.ChangeMap(HubMap.ID, HubMap.Portals["join00"]);
            }

            EndAction = RepeatingAction.Start("FTJWatcher", Stop, EventRuntimeSeconds * 1000, 0);

            base.Start(joinDuringEvent);
        }
Esempio n. 12
0
        /// <summary>
        /// This function removes an repeating action synchronously from the list.
        /// </summary>
        /// <param name="pName">Name of the Repeating Action</param>
        /// <param name="pOnRemoved">Callback when the removal is performed.</param>
        public void RemoveRepeatingAction(string pName, Action <DateTime, string, bool> pOnRemoved)
        {
            RepeatingAction action = _repeatingActions.First((a) => { return(a.Name == pName); });

            if (pOnRemoved == null)
            {
                return;
            }
            if (action == null)
            {
                pOnRemoved(CurrentDate, pName, false);
            }
            else
            {
                AddCallback((a) =>
                {
                    pOnRemoved(a, pName, _repeatingActions.Remove(action)); // Sync
                });
            }
        }
Esempio n. 13
0
        private KPQ(Character pLeader, IEnumerable <Character> pParty)
        {
            startTime = MasterThread.CurrentTime;
            PartyId   = pLeader.PartyID;
            _leader   = pLeader;
            _party    = pParty;

            ropes = new List <bool>(4)
            {
                true, true, true, false
            };
            kittens = new List <bool>(5)
            {
                true, true, true, false, false
            };
            barrels = new List <bool>(6)
            {
                true, true, true, false, false, false
            };
            questions      = new Dictionary <int, Tuple <string, int> >();
            _bonusTimerSet = false;

            ropes.Shuffle();
            kittens.Shuffle();
            barrels.Shuffle();
            _party.ForEach(m => questions.Add(m.ID, StageOneQuestions.RandomElement()));

            Maps.ForEach(m => m.PQPortalOpen = false);
            Maps.ForEach(m => m.DropPool.Clear());

            KingSlimeMap.Mobs.Clear();
            Stage5MobGen.ForEach(mgi => KingSlimeMap.SpawnMob(mgi.ID, mgi, new Pos(mgi.X, mgi.Y), mgi.Foothold));

            _watcher = KPQWatcher();
            _watcher.Start();

            _log.Info($"Started KPQ with party ({string.Join(", ", pParty.Select(x => x.Name))})");
        }
Esempio n. 14
0
        public override void Start(bool joinDuringEvent = false)
        {
            foreach (var chr in LobbyMap.Characters.ToList())
            {
                if (MapleTeam.Count < StoryTeam.Count)
                {
                    MapleTeam.Add(chr);
                    chr.ChangeMap(sMapId, SnowballMap.Top.Name);
                }
                else
                {
                    StoryTeam.Add(chr);
                    chr.ChangeMap(sMapId, SnowballMap.Bottom.Name);
                }
            }

            Program.MainForm.LogDebug("Starting..." + " Maple " + string.Join(", ", MapleTeam.Select(c => c.Name)) + "... Story " + string.Join(", ", StoryTeam.Select(c => c.Name)));

            End = RepeatingAction.Start("SnowballWatcher", Stop, EventTimeSeconds * 1000, 0);
            SnowballMap.StartTimer(EventTimeSeconds);
            SnowballMap.SnowballState = SnowballEventState.IN_PROGRESS;
            base.Start(joinDuringEvent);
        }
Esempio n. 15
0
        private void CheckAnswer(QuizData question)
        {
            QuizMap.SendPacket(OXPackets.QuizQuestion(false, question.QuestionPage, question.QuestionIdx));

            var losers = QuizMap.Characters
                         .Where(
                chr => chr.Foothold < 0 ||
                (!AreaO.Contains(chr.Position.X, chr.Position.Y) && !AreaX.Contains(chr.Position.X, chr.Position.Y)) ||
                (AreaO.Contains(chr.Position.X, chr.Position.Y) && question.Answer != 'o') ||
                (AreaX.Contains(chr.Position.X, chr.Position.Y) && question.Answer != 'x'))
                         .ToList();

            losers.ForEach(c => c.ChangeMap(LoseMapId));

            if (questions.Count == 0)
            {
                Stop();
            }
            else
            {
                Program.MainForm.LogDebug("Asking next question...");
                curQuestion = RepeatingAction.Start("Quiz - " + (questions.Count - 1) + " - answer", t => AskQuestion(), 10 * 1000, 0);
            }
        }
Esempio n. 16
0
 public void AddRepeatingAction(RepeatingAction pAction)
 {
     AddCallback((a) =>
     {
         _repeatingActions.Add(pAction);
     });
 }
Esempio n. 17
0
        /// <summary>
        /// This function removes a repeating action from the list
        /// </summary>
        /// <param name="pAction">The Repeating Action</param>
        /// <param name="pOnRemoved">Callback when the removal is performed.</param>
        public void RemoveRepeatingAction(RepeatingAction pAction, Action <DateTime, string, bool> pOnRemoved = null)
        {
            var isRemoved = pAction.Stop();

            pOnRemoved?.Invoke(CurrentDate, pAction.Name, isRemoved);
        }
Esempio n. 18
0
 public void AddRepeatingAction(RepeatingAction pAction)
 {
     pAction.Start();
 }