Initialize() public method

public Initialize ( ) : void
return void
Esempio n. 1
0
        public void Initialize()
        {
            _random         = new Random(MapNpcId);
            Npc             = ServerManager.GetNpcMonster(NpcVNum);
            LastEffect      = DateTime.UtcNow;
            LastMove        = DateTime.UtcNow;
            IsHostile       = Npc.IsHostile;
            FirstX          = MapX;
            FirstY          = MapY;
            EffectActivated = true;
            EffectDelay     = 4000;
            _movetime       = ServerManager.RandomNumber(400, 1600);

            //Observable.Timer(TimeSpan.FromMilliseconds(_movetime)).Subscribe(observer => RegisterNpcLife());
            Path        = new List <Node>();
            Recipes     = ServerManager.Instance.GetRecipesByMapNpcId(MapNpcId);
            Target      = -1;
            Teleporters = ServerManager.Instance.GetTeleportersByNpcVNum((short)MapNpcId);
            Shop shop = ServerManager.Instance.GetShopByMapNpcId(MapNpcId);

            if (shop != null)
            {
                shop.Initialize();
                Shop = shop;
            }
        }
Esempio n. 2
0
        public override void Initialize()
        {
            _random     = new Random(MapNpcId);
            Npc         = ServerManager.GetNpc(this.NpcVNum);
            LastEffect  = DateTime.Now;
            LastMove    = DateTime.Now;
            FirstX      = MapX;
            FirstY      = MapY;
            _movetime   = _random.Next(500, 3000);
            Path        = new List <GridPos>();
            Recipes     = ServerManager.Instance.GetReceipesByMapNpcId(MapNpcId);
            Target      = -1;
            Teleporters = ServerManager.Instance.GetTeleportersByNpcVNum((short)MapNpcId);
            Shop shop = ServerManager.Instance.GetShopByMapNpcId(MapNpcId);

            if (shop != null)
            {
                shop.Initialize();
                Shop = shop;
            }
        }
Esempio n. 3
0
        public override void Initialize()
        {
            _random         = new Random(MapNpcId);
            Npc             = ServerManager.Instance.GetNpc(NpcVNum);
            LastEffect      = DateTime.Now;
            LastMove        = DateTime.Now;
            IsHostile       = Npc.IsHostile;
            FirstX          = MapX;
            EffectActivated = true;
            FirstY          = MapY;
            EffectDelay     = 4000;
            _movetime       = ServerManager.Instance.RandomNumber(500, 3000);
            Path            = new List <Node>();
            Recipes         = ServerManager.Instance.GetReceipesByMapNpcId(MapNpcId);
            Target          = -1;
            Teleporters     = ServerManager.Instance.GetTeleportersByNpcVNum((short)MapNpcId);
            Shop shop = ServerManager.Instance.GetShopByMapNpcId(MapNpcId);

            if (shop != null)
            {
                shop.Initialize();
                Shop = shop;
            }
        }
Esempio n. 4
0
        public void Initialize()
        {
            if (MapInstance.MapInstanceType == MapInstanceType.BaseMapInstance && ServerManager.Instance.MapBossVNums.Contains(NpcVNum))
            {
                MapCell randomCell = MapInstance.Map.GetRandomPosition();
                if (randomCell != null)
                {
                    if (MapInstance.Portals.Any(s => Map.GetDistance(new MapCell {
                        X = s.SourceX, Y = s.SourceY
                    }, new MapCell {
                        X = randomCell.X, Y = randomCell.Y
                    }) < 5))
                    {
                        randomCell = MapInstance.Map.GetRandomPosition();
                    }
                    MapX = randomCell.X;
                    MapY = randomCell.Y;
                }
            }

            _random = new Random(MapNpcId);
            Npc     = ServerManager.GetNpcMonster(NpcVNum);
            MaxHp   = Npc.MaxHP;
            MaxMp   = Npc.MaxMP;

            if (MapInstance?.MapInstanceType == MapInstanceType.TimeSpaceInstance)
            {
                if (IsProtected)
                {
                    MaxHp *= 8;
                    MaxMp *= 8;
                }
            }
            IsAlive             = true;
            CurrentHp           = MaxHp;
            CurrentMp           = MaxMp;
            LastEffect          = DateTime.Now;
            LastProtectedEffect = DateTime.Now;
            LastMove            = DateTime.Now;
            LastSkill           = DateTime.Now;
            IsHostile           = Npc.IsHostile;
            ShouldRespawn       = ShouldRespawn ?? true;
            FirstX          = MapX;
            FirstY          = MapY;
            EffectActivated = true;
            _movetime       = ServerManager.RandomNumber(500, 3000);
            Path            = new List <Node>();
            Recipes         = ServerManager.Instance.GetRecipesByMapNpcId(MapNpcId);
            Target          = -1;
            Teleporters     = ServerManager.Instance.GetTeleportersByNpcVNum(MapNpcId);
            Shop shop = ServerManager.Instance.GetShopByMapNpcId(MapNpcId);

            if (shop != null)
            {
                shop.Initialize();
                Shop = shop;
            }
            Skills = new List <NpcMonsterSkill>();
            foreach (NpcMonsterSkill ski in Npc.Skills)
            {
                Skills.Add(new NpcMonsterSkill {
                    SkillVNum = ski.SkillVNum, Rate = ski.Rate
                });
            }
            BattleEntity = new BattleEntity(this);

            if (AliveTime > 0)
            {
                Thread AliveTimeThread = new Thread(() => AliveTimeCheck());
                AliveTimeThread.Start();
            }

            if (NpcVNum == 1408)
            {
                OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(621, new MapCell {
                    X = MapX, Y = MapY
                }, null, move: true)));
            }
            if (NpcVNum == 1409)
            {
                OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(622, new MapCell {
                    X = MapX, Y = MapY
                }, null, move: true)));
            }
            if (NpcVNum == 1410)
            {
                OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(623, new MapCell {
                    X = MapX, Y = MapY
                }, null, move: true)));
            }

            if (OnSpawnEvents.Any())
            {
                OnSpawnEvents.ToList().ForEach(e => { EventHelper.Instance.RunEvent(e, npc: this); });
                OnSpawnEvents.Clear();
            }
        }