Ejemplo n.º 1
0
        private MapInstance GetMapInstance(Player player, int mapId)
        {
            if (IsDungeon(mapId))
            {
                if (player.Party != null)
                    lock (player.Party.MemberLock)
                        foreach (Player partyMember in player.Party.PartyMembers)
                            if (Global.PlayerService.IsPlayerOnline(partyMember) && partyMember.Instance != null &&
                                partyMember.Instance.MapId == mapId)
                                return partyMember.Instance;

                var dungeon = ((ADungeon) Activator.CreateInstance(Dungeons[mapId]));
                dungeon.MapId = mapId;

                SpawnMap(dungeon);

                dungeon.Init();
                return dungeon;
            }

            if (Maps[mapId].Count > 0)
                return Maps[mapId][0];

            var ins = new MapInstance {MapId = mapId};
            SpawnMap(ins);

            return ins;
        }
Ejemplo n.º 2
0
        public void SpawnTeraObject(TeraObject obj, MapInstance instance)
        {
            var creature = obj as Creature;
            if (creature != null)
            {
                lock (instance.CreaturesLock)
                {
                    if (obj is Npc)
                        instance.Npcs.Add((Npc) obj);
                    else if (obj is Player)
                        instance.Players.Add((Player) obj);
                    else if (obj is Campfire)
                        instance.Campfires.Add((Campfire) obj);
                    else if (obj is Gather)
                        instance.Gathers.Add((Gather) obj);
                    else if (obj is Item)
                        instance.Items.Add((Item) obj);
                    else if (obj is Projectile)
                        instance.Projectiles.Add((Projectile) obj);
                }

                creature.Instance = instance;
            }
        }
Ejemplo n.º 3
0
 private void DestructInstance(MapInstance instance)
 {
     instance.Release();
     Maps[instance.MapId].Remove(instance);
 }
Ejemplo n.º 4
0
        public void SpawnMap(MapInstance instance)
        {
            if (MergedSpawn.ContainsKey(instance.MapId))
                foreach (SpawnTemplate template in MergedSpawn[instance.MapId])
                    SpawnTeraObject(CreateNpc(template), instance);

            if (Data.Data.CampfireTemplates.ContainsKey(instance.MapId) && Data.Data.CampfireTemplates[instance.MapId] != null)
                foreach (CampfireSpawnTemplate campfireSpawnTemplate in Data.Data.CampfireTemplates[instance.MapId])
                    if (campfireSpawnTemplate.Type == 4)
                        SpawnTeraObject(new Campfire
                        {
                            Type = campfireSpawnTemplate.Type,
                            Status = campfireSpawnTemplate.Status,
                            Position = campfireSpawnTemplate.Position.Clone(),
                            IsStationary = true,
                        }, instance);

            foreach (GSpawnTemplate gSpawnTemplate in Data.Data.DcGatherSpawnTemplates)
                if (gSpawnTemplate.WorldPosition.MapId == instance.MapId)
                    SpawnTeraObject(CreateGather(gSpawnTemplate), instance);

            if (!Maps.ContainsKey(instance.MapId))
                Maps.Add(instance.MapId, new List<MapInstance>());

            Maps[instance.MapId].Add(instance);
        }
Ejemplo n.º 5
0
        public override void Release()
        {
            if (ObserversList != null)
                ObserversList.Clear();
            ObserversList = null;

            VisiblePlayers = null;
            VisibleNpcs = null;
            VisibleItems = null;

            if (Ai != null)
                Ai.Release();
            Ai = null;

            if (_lifeStats != null)
                _lifeStats.Release();
            _lifeStats = null;

            GameStats = null;

            Position = null;
            BindPoint = null;
            Instance = null;

            Target = null;

            EffectsLock = null;

            base.Release();
        }
Ejemplo n.º 6
0
        public override void Release()
        {
            if (ObserversList != null)
                ObserversList.Clear();
            ObserversList = null;

            VisiblePlayers = null;
            VisibleNpcs = null;
            VisibleItems = null;
            VisibleGathers = null;

            if (Ai != null)
                Ai.Release();
            Ai = null;

            if (_lifeStats != null)
                _lifeStats.Release();
            _lifeStats = null;

            GameStats = null;

            Position = null;
            BindPoint = null;
            Instance = null;

            Target = null;

            if (VisualEffect != null)
                VisualEffect.Release();
            VisualEffect = null;

            if (Effects != null)
                for (int i = 0; i < Effects.Count; i++)
                    Effects[i].Release();
            Effects = null;
            EffectsLock = null;

            base.Release();
        }
Ejemplo n.º 7
0
        public void SpawnRxjhObject(RxjhObject obj, MapInstance instance)
        {
            var creature = obj as Creature;
            if (creature != null)
            {
                lock (instance.CreaturesLock)
                {
                    if (obj is Npc)
                        instance.AddNpc((Npc)obj);
                    else if (obj is Player)
                        instance.Players.Add((Player)obj);
                    else if (obj is Item)
                        instance.Items.Add((Item)obj);
                }

                creature.Instance = instance;
            }
        }
Ejemplo n.º 8
0
        public void SpawnMap(MapInstance instance)
        {
            if (MergedSpawn.ContainsKey(instance.MapId))
            {
                foreach (SpawnTemplate template in MergedSpawn[instance.MapId])
                {
                    if (template.GroupSpawn)
                    {
                        for (int i = 0; i < template.Count; i++)
                        {
                            Npc npc = CreateNpc(template);
                            Random rnd = new Random((int)(DateTime.Now.Ticks + Funcs.Random().Next(int.MinValue, (int)Math.Abs(npc.Position.X)))); ;
                            npc.Position.X += rnd.Next(0, 400) * (rnd.Next(0, 100) < 50 ? 1 : -1);
                            npc.Position.Y += rnd.Next(0, 400) * (rnd.Next(0, 100) < 50 ? 1 : -1);
                            npc.Position.CopyTo(npc.BindPoint);
                            SpawnRxjhObject(npc, instance);
                        }
                    }
                    else
                        SpawnRxjhObject(CreateNpc(template), instance);
                }
            }

            if (!Maps.ContainsKey(instance.MapId))
                Maps.Add(instance.MapId, new List<MapInstance>());

            Maps[instance.MapId].Add(instance);
        }