Exemplo n.º 1
0
 public void RemoveMonster(Database.Mob mb)
 {
     mapa.RemoveEntityAtTile(mb.MapPosition, mb.InternalID, false);
     //monsters.Remove(mb.UniqueID);
     Database.Mob mbOut;
     monsters.TryRemove(mb.InternalID, out mbOut);
 }
Exemplo n.º 2
0
        public void AddMonster(Database.Mob mb)
        {
            mapa.AddEntityAtTile(mb.MapPosition, mb.InternalID, false);
            monsters.TryAdd(mb.InternalID, mb);
            //BroadcastPacket(mb.PosX, mb.PosY, mb.sightRange, new Packet.SendPacketHandlers.MobSpawn(mb));

            /*
             * List<int> playersList = mapa.GetAllPlayersAtRange(mb.MapPosition, DEBUG_SIGHT_RANGE);
             * Database.Player p;
             * foreach (int i in playersList)
             * {
             *  p = null;
             *  players.TryGetValue(i, out p);
             *  if (p != null)
             *  {
             *      mb.AddPlayer(i);
             *      p.Con.Send(new Packet.SendPacketHandlers.MobSpawn(mb));//newly added player data!
             *  }
             * }
             */
        }
Exemplo n.º 3
0
        public void MoveMobOnMap(Database.Mob mb, Map.Nod from, Map.Nod to)
        {
            //Output.WriteLine("MoveMobOnMap ID " + mb.InternalID.ToString() + " at [" + mb.PosX.ToString() + "," + mb.PosY.ToString() + "]");
            bool rem = mapa.RemoveEntityAtTile(from, mb.InternalID, false);

            if (rem)
            {
                //Output.WriteLine("Removed mob ID " + mb.InternalID.ToString() + " at [" + from.X.ToString() + "," + from.Y.ToString() + "]");
            }
            else
            {
                Output.WriteLine("FAILED to remove mob ID " + mb.InternalID.ToString() + " at [" + from.X.ToString() + "," + from.Y.ToString() + "]");
            }
            if (!mapa.AddEntityAtTile(to, mb.InternalID, false))
            {
                //Output.WriteLine("Fail add mob ID " + mb.InternalID.ToString() + " at [" + to.X.ToString() + "," + to.Y.ToString() + "]");
                mb.Despawn(null);
                return;
            }

            /*
             * else
             * {
             *  //Output.WriteLine("Added mob ID " + mb.InternalID.ToString() + " at [" + to.X.ToString() + "," + to.Y.ToString() + "]");
             *  //send info to all players in sight range about new mob spawn
             *  List<int> playersList = mapa.GetAllPlayersAtRange(to, DEBUG_SIGHT_RANGE);
             *  Database.Player p;
             *  foreach (int i in playersList)
             *  {
             *      if (!mb.ContainsPlayer(i))//this is new player in range so send spawn and add to known list
             *      {
             *          p = null;
             *          players.TryGetValue(i, out p);
             *          if (p != null )
             *          {
             *              mb.AddPlayer(i);
             *              //p.Con.Send(new Packet.SendPacketHandlers.MobSpawn(mb));//newly added player data!
             *              //if (mb.moving)//mob is moving so send this info to new player in range
             *              //{
             *              //    p.Con.Send(new Packet.SendPacketHandlers.MobMoveStart(mb.InternalID, mb.newX, mb.newY));//newly added player data!
             *              //}
             *          }
             *      }
             *  }
             *  List<int> oldPlayersList = mb.KnownPlayers();
             *  foreach (int i in oldPlayersList)
             *  {
             *      if (!playersList.Contains(i))//this player isn't in range so send despawn
             *      {
             *          p = null;
             *          players.TryGetValue(i, out p);
             *          if (p != null)
             *          {
             *              mb.RemovePlayer(i);
             *              //p.Con.Send(new Packet.SendPacketHandlers.MobDespawn(mb.InternalID));//newly added player data!
             *          }
             *      }
             *  }
             * }
             */
        }