예제 #1
0
        public override void Update()
        {
            base.Update();
            switch (CurrentState)
            {
            case EventState.Open:
                if (_players.Where(x => x.Eventer).Count() <= 0)
                {
                    break;
                }
                Trigger(EventState.Playing);
                break;

            case EventState.Playing:
                if (_players.Where(x => x.Eventer).Count() == 0)
                {
                    Trigger(EventState.Open);
                    return;
                }
                switch (_subState)
                {
                case FortressSubState.Phaze1:
                case FortressSubState.Phaze2:
                case FortressSubState.Phaze3:
                case FortressSubState.Phaze4:
                    var ts = _subStateEnd - DateTime.Now;
                    if (_lastNotify != (int)ts.TotalMinutes)
                    {
                        _lastNotify = (int)ts.TotalMinutes;
                        _           = Program.MapAnoucement((Maps)_map.Map, $"Portal will be closed after {_lastNotify} minutes");
                        _           = _map.SendAsync(_eventState);
                    }

                    foreach (var t in _traps)
                    {
                        foreach (var p in _players.Where(x => x.Eventer))
                        {
                            if (t.Position.Substract(p.Player.Character.Position).LengthSquared() <= 5)
                            {
                                DamageType dmg;
                                Spell      spell;

                                var att = t.MonsterAttack(out dmg, out spell);
                                _ = p.Player.Character.GetAttacked(t.Index, t.Direction, 120, att, dmg, spell);
                            }
                        }
                    }

                    break;
                }

                if (_subStateEnd <= DateTime.Now)
                {
                    if (_subState == FortressSubState.End)
                    {
                        _subState = FortressSubState.None;
                        Trigger(EventState.Open);
                        return;
                    }
                    _logger.Information("Fortress state {0}->{1}", _subState++, _subState);
                    switch (_subState)
                    {
                    case FortressSubState.None:
                        _subStateEnd = DateTime.Now;
                        break;

                    case FortressSubState.StandBy1:
                        _subStateEnd = DateTime.Now.AddMinutes(1);
                        foreach (var g in _fortressGates)
                        {
                            g.monster.Active = true;
                        }
                        _eventState.State = 1;
                        break;

                    case FortressSubState.Phaze1:
                        _subStateEnd = DateTime.Now.AddMinutes(10);
                        _fortressGates[0].monster.Type = ObjectType.Gate;
                        _activeMobs = MonsterIA.Group(_baseGroup, true, OnMonsterDead);
                        break;

                    case FortressSubState.Standby2:
                        _subStateEnd = DateTime.Now.AddMinutes(3);
                        MonsterIA.Group(_baseGroup, false, OnMonsterDead);
                        _eventState.State = 2;
                        break;

                    case FortressSubState.Phaze2:
                        _subStateEnd = DateTime.Now.AddMinutes(10);
                        _fortressGates[3].monster.Type = ObjectType.Gate;
                        _activeMobs = MonsterIA.Group(_baseGroup + 1, true, OnMonsterDead);
                        break;

                    case FortressSubState.StandBy3:
                        _subStateEnd = DateTime.Now.AddMinutes(3);
                        MonsterIA.Group(_baseGroup + 1, false, OnMonsterDead);
                        _eventState.State = 3;
                        break;

                    case FortressSubState.Phaze3:
                        _subStateEnd = DateTime.Now.AddMinutes(10);
                        _fortressGates[6].monster.Type = ObjectType.Gate;
                        _activeMobs = MonsterIA.Group(_baseGroup + 2, true, OnMonsterDead);
                        break;

                    case FortressSubState.StandBy4:
                        if (_eventDay != (DayOfWeek)7)
                        {
                            _subState = FortressSubState.End;
                        }

                        _subStateEnd = DateTime.Now.AddMinutes(3);
                        MonsterIA.Group(_baseGroup + 2, false, OnMonsterDead);
                        _eventState.State = 4;
                        break;

                    case FortressSubState.Phaze4:
                        _subStateEnd = DateTime.Now.AddMinutes(10);
                        _fortressGates[9].monster.Type = ObjectType.Gate;
                        _activeMobs = MonsterIA.Group(_baseGroup + 3, true, OnMonsterDead);
                        break;

                    case FortressSubState.End:
                        _subStateEnd = DateTime.Now.AddMinutes(3);
                        MonsterIA.Group(_baseGroup + 2, false, OnMonsterDead);
                        MonsterIA.Group(_baseGroup + 3, false, OnMonsterDead);
                        break;
                    }
                    _ = _map.SendAsync(_eventState);
                }
                break;
            }
        }
예제 #2
0
        public override void OnTransition(EventState NextState)
        {
            _logger.Information("State {0}->{1}", CurrentState, NextState);
            switch (NextState)
            {
            case EventState.Open:
                _subState = FortressSubState.None;
                foreach (var g in _fortressGates)
                {
                    g.monster.Active = false;
                }

                _map?.Players.ForEach(x => _ = x.WarpTo(267));

                break;

            case EventState.Playing:
                _subStateEnd      = DateTime.Now;
                _eventDay         = DateTime.Now.DayOfWeek;
                _eventDay         = _eventDay == DayOfWeek.Sunday ? (DayOfWeek)7 : _eventDay;
                _baseGroup        = (int)_eventDay * 3 + 21;
                _eventState.Day   = _eventDay;
                _eventState.Unk   = 3;
                _eventState.State = 1;

                switch (DateTime.Now.DayOfWeek)
                {
                case DayOfWeek.Monday:        //Destler
                case DayOfWeek.Thursday:      //Galia
                    _fortressGates = _DestlerGaliaGates;
                    //_fortressAtt = __JerintGaionAtt;
                    Map        = Maps.ImperialGuardian1;
                    _baseGroup = 24;
                    break;

                case DayOfWeek.Tuesday:       //Vermont
                case DayOfWeek.Friday:        //Erkanne
                    _fortressGates = _VermontErkanneGates;
                    //_fortressAtt = __JerintGaionAtt;
                    Map        = Maps.ImperialGuardian2;
                    _baseGroup = 27;
                    break;

                case DayOfWeek.Wednesday:       //Kato
                case DayOfWeek.Saturday:        //Raymond
                    _fortressGates = _KatoRaymondGates;
                    //_fortressAtt = __JerintGaionAtt;
                    Map        = Maps.ImperialGuardian3;
                    _baseGroup = 30;
                    break;

                case DayOfWeek.Sunday:        //Jerint y Gaion Kharein
                    _fortressGates = _JerintGaionGates;
                    _fortressAtt   = __JerintGaionAtt;
                    Map            = Maps.ImperialGuardian4;
                    _baseGroup     = 36;
                    break;
                }
                _map   = ResourceCache.Instance.GetMaps()[Map];
                _traps = _map.Monsters.Where(x => x.Info.Monster == 523).ToList();
                break;
            }
        }