Beispiel #1
0
 public virtual void LeaveWorld(Entity entity)
 {
     if (entity is Player)
     {
         Player dummy;
         Players.TryRemove(entity.Id, out dummy);
         PlayersCollision.Remove(entity);
     }
     else if (entity is Enemy)
     {
         Enemy dummy;
         Enemies.TryRemove(entity.Id, out dummy);
         EnemiesCollision.Remove(entity);
     }
     else if (entity is Projectile)
     {
         Projectile p = entity as Projectile;
         Projectiles.TryRemove(new Tuple <int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
     }
     else if (entity is StaticObject)
     {
         StaticObject dummy;
         StaticObjects.TryRemove(entity.Id, out dummy);
         if (entity is Decoy)
         {
             PlayersCollision.Remove(entity);
         }
         else
         {
             EnemiesCollision.Remove(entity);
         }
     }
     entity.Owner = null;
 }
Beispiel #2
0
        public virtual void LeaveWorld(Entity entity)
        {
            if (entity is Player)
            {
                Player dummy;
                Players.TryRemove(entity.Id, out dummy);
                PlayersCollision.Remove(entity);

                // if in trade, cancel it...
                if (dummy.tradeTarget != null)
                {
                    dummy.CancelTrade();
                }
            }
            else if (entity is Enemy)
            {
                Enemy dummy;
                Enemies.TryRemove(entity.Id, out dummy);
                EnemiesCollision.Remove(entity);
                if (entity.ObjectDesc.Quest)
                {
                    Quests.TryRemove(entity.Id, out dummy);
                }
            }
            else if (entity is Projectile)
            {
                var p = entity as Projectile;
                Projectiles.TryRemove(new Tuple <int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
            }
            else if (entity is StaticObject)
            {
                StaticObject dummy;
                StaticObjects.TryRemove(entity.Id, out dummy);

                if (entity.ObjectDesc?.BlocksSight == true)
                {
                    if (Blocking == 3)
                    {
                        Sight.UpdateRegion(Map, (int)entity.X, (int)entity.Y);
                    }

                    foreach (var plr in Players.Values
                             .Where(p => MathsUtils.DistSqr(p.X, p.Y, entity.X, entity.Y) < Player.RadiusSqr))
                    {
                        plr.Sight.UpdateCount++;
                    }
                }

                if (entity is Decoy)
                {
                    PlayersCollision.Remove(entity);
                }
                else
                {
                    EnemiesCollision.Remove(entity);
                }
            }

            entity.Dispose();
        }
Beispiel #3
0
 public virtual void LeaveWorld(Entity entity)
 {
     if (entity is Player)
     {
         Player dummy;
         if (!Players.TryRemove(entity.Id, out dummy))
         {
             Log.WarnFormat("Could not remove {0} from world {1}", entity.Name, Name);
         }
         PlayersCollision.Remove(entity);
     }
     else if (entity is Enemy)
     {
         Enemy dummy;
         Enemies.TryRemove(entity.Id, out dummy);
         EnemiesCollision.Remove(entity);
         if (entity.ObjectDesc.Quest)
         {
             Quests.TryRemove(entity.Id, out dummy);
         }
     }
     else
     {
         var projectile = entity as Projectile;
         if (projectile != null)
         {
             var p = projectile;
             Projectiles.TryRemove(new Tuple <int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
         }
         else if (entity is StaticObject)
         {
             StaticObject dummy;
             StaticObjects.TryRemove(entity.Id, out dummy);
             if (entity is Decoy)
             {
                 PlayersCollision.Remove(entity);
             }
             else
             {
                 EnemiesCollision.Remove(entity);
             }
         }
         else if (entity is Pet)
         {
             if (entity.IsPet)
             {
                 Pet dummy2;
                 Pets.TryRemove(entity.Id, out dummy2);
                 PlayersCollision.Remove(entity);
             }
         }
     }
     entity.Owner = null;
     entity.Dispose();
 }
 public virtual void LeaveWorld(Entity entity)
 {
     if (entity is Player)
     {
         Player dummy;
         Players.TryRemove(entity.Id, out dummy);
         PlayersCollision.Remove(entity);
     }
     else if (entity is Enemy)
     {
         Enemy dummy;
         Enemies.TryRemove(entity.Id, out dummy);
         EnemiesCollision.Remove(entity);
         if (entity.ObjectDesc.Quest)
         {
             Quests.TryRemove(entity.Id, out dummy);
         }
         if (entity.isPet)
         {
             Entity dummy2;
             Pets.TryRemove(entity.Id, out dummy2);
         }
     }
     else if (entity is Projectile)
     {
         var p = entity as Projectile;
         Projectiles.TryRemove(new Tuple <int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
     }
     else if (entity is StaticObject)
     {
         StaticObject dummy;
         StaticObjects.TryRemove(entity.Id, out dummy);
         if (entity is Decoy)
         {
             PlayersCollision.Remove(entity);
         }
         else
         {
             EnemiesCollision.Remove(entity);
         }
     }
     else if (entity is ItemEntity)
     {
         ItemEntity dummy;
         EnemiesCollision.Remove(entity);
         ItemEntities.TryRemove(entity.Id, out dummy);
     }
     entity.Dispose();
     entity = null;
 }
        public virtual void LeaveWorld(Entity entity)
        {
            if (entity is Player)
            {
                Player dummy;
                if (!Players.TryRemove(entity.Id, out dummy))
                {
                    Log.WarnFormat("Could not remove {0} from world {1}", entity.Name, Name);
                }
                PlayersCollision.Remove(entity);
            }
            else if (entity is Enemy)
            {
                Enemy dummy;
                Enemies.TryRemove(entity.Id, out dummy);
                EnemiesCollision.Remove(entity);
                if (entity.ObjectDesc.Quest)
                {
                    Quests.TryRemove(entity.Id, out dummy);
                }
                foreach (var i in (entity as Enemy).DamageCounter.GetPlayerData())
                {
                    if (i.Item1 != null)
                    {
                        var player = i.Item1;
                        var enemy  = (entity as Enemy);
                        switch (enemy.Name)
                        {
                        case "Archdemon Malphas":
                            player.playerQuestManager.ProcessQuestAction(1);
                            break;

                        case "Septavius the Ghost God":
                            player.playerQuestManager.ProcessQuestAction(2);
                            break;

                        case "Oryx the Mad God 2":
                            player.playerQuestManager.ProcessQuestAction(3);     // quest id
                            break;
                        }
                    }
                }
            }
            else
            {
                var projectile = entity as Projectile;
                if (projectile != null)
                {
                    var p = projectile;
                    Projectiles.TryRemove(new Tuple <int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
                }
                else if (entity is StaticObject)
                {
                    StaticObject dummy;
                    StaticObjects.TryRemove(entity.Id, out dummy);
                    if (entity is Decoy)
                    {
                        PlayersCollision.Remove(entity);
                    }
                    else
                    {
                        EnemiesCollision.Remove(entity);
                    }
                }
                else if (entity is Pet)
                {
                    if (entity.IsPet)
                    {
                        Pet dummy2;
                        Pets.TryRemove(entity.Id, out dummy2);
                        PlayersCollision.Remove(entity);
                    }
                }
            }
            entity.Owner = null;
            entity.Dispose();
        }
Beispiel #6
0
 public virtual void LeaveWorld(Entity entity)
 {
     if (!(entity is Pet || entity is Portal))
     {
         if (entity is Wall && entity.ObjectDesc != null && entity.ObjectDesc.FullOccupy || entity.ObjectDesc.OccupySquare || entity.ObjectDesc.EnemyOccupySquare)
         {
             WmapTile tile = Map[(int)entity.X, (int)entity.Y].Clone();
             tile.TileId     = Map[(int)entity.X, (int)entity.Y].TileId;
             tile.ObjType    = 0;
             tile.ObjectDesc = null;
             Map[(int)entity.X, (int)entity.Y] = tile;
         }
     }
     if (entity is Player)
     {
         Player dummy;
         if (!Players.TryRemove(entity.Id, out dummy))
         {
             Console.WriteLine("Could not remove {0} from world {1}", entity.Name, Name);
         }
         PlayersCollision.Remove(entity);
     }
     else if (entity is Enemy)
     {
         Enemy dummy;
         Enemies.TryRemove(entity.Id, out dummy);
         EnemiesCollision.Remove(entity);
         if (entity.ObjectDesc.Quest)
         {
             Quests.TryRemove(entity.Id, out dummy);
         }
     }
     else
     {
         var projectile = entity as Projectile;
         if (projectile != null)
         {
             var p = projectile;
             Projectiles.TryRemove(new Tuple <int, byte>(p.ProjectileOwner.Self.Id, p.ProjectileId), out p);
         }
         else if (entity is StaticObject)
         {
             StaticObject dummy;
             StaticObjects.TryRemove(entity.Id, out dummy);
             if (entity is Decoy)
             {
                 PlayersCollision.Remove(entity);
             }
             else
             {
                 EnemiesCollision.Remove(entity);
             }
         }
         else if (entity is Pet)
         {
             if (entity.IsPet)
             {
                 Pet dummy2;
                 Pets.TryRemove(entity.Id, out dummy2);
                 PlayersCollision.Remove(entity);
             }
         }
     }
     entity.Owner = null;
     entity.Dispose();
 }