示例#1
0
        public void RemoveEnemy(uint enemyid)
        {
            if (!HasEnemy(enemyid))
            {
                return;
            }
            var associate = Enemies[enemyid];

            Owner.Send(AssociatePacket.Create(enemyid, AssociateAction.RemoveEnemy, true, associate.Name));
            ServerDatabase.Context.Associates.Remove(Owner.UID, enemyid, AssociateType.Enemy);
            //ServerDatabase.Context.Associates.Remove(enemyid, Owner.UID, AssociateType.EnemyOf);
        }
示例#2
0
        public void RemoveFriend(uint friendid)
        {
            if (!HasFriend(friendid))
            {
                return;
            }
            var associate = Friends[friendid];

            Owner.Send(AssociatePacket.Create(friendid, AssociateAction.RemoveFriend, true, associate.Name));
            associate.Send(AssociatePacket.Create(Owner.UID, AssociateAction.RemoveFriend, true, Owner.Name));
            ServerDatabase.Context.Associates.Remove(Owner.UID, friendid, AssociateType.Friend);
            ServerDatabase.Context.Associates.Remove(friendid, Owner.UID, AssociateType.Friend);
        }
示例#3
0
 public void InformAssociates(bool online)
 {
     #region Friends
     foreach (Associate friend in Friends.Values)
     {
         if (online)
         {
             Owner.Send(AssociatePacket.Create(friend, AssociateAction.AddFriend));
             if (friend.IsOnline)
             {
                 friend.Send(AssociatePacket.Create(Owner.UID, AssociateAction.SetOnlineFriend, true, Owner.Name));
             }
         }
         else if (friend.IsOnline && friend.Type == AssociateType.Friend)
         {
             friend.Send(AssociatePacket.Create(Owner.UID, AssociateAction.SetOfflineFriend, false, Owner.Name));
         }
     }
     #endregion
     #region Enemies
     foreach (Associate enemy in Enemies.Values)
     {
         if (online)
         {
             Owner.Send(AssociatePacket.Create(enemy.UID, AssociateAction.AddEnemy, true, enemy.Name));
         }
     }
     #endregion
     #region EnemyOf
     foreach (var enemyof in EnemyOf.Values)
     {
         if (online)
         {
             enemyof.Send(AssociatePacket.Create(Owner.UID, AssociateAction.SetOnlineEnemy, true, Owner.Name));
         }
         else
         {
             enemyof.Send(AssociatePacket.Create(Owner.UID, AssociateAction.SetOfflineEnemy, false, Owner.Name));
         }
     }
     #endregion
 }
示例#4
0
        public void AddFriend(Player friend)
        {
            if (friend == null)
            {
                return;
            }
            if (HasFriend(friend.UID))
            {
                return;
            }
            DbAssociate assoc = new DbAssociate();

            assoc.AssociateID = friend.UID;
            assoc.Name        = friend.Name;
            assoc.Type        = (byte)AssociateType.Friend;
            assoc.UID         = Owner.UID;
            ServerDatabase.Context.Associates.Add(assoc);
            var associate = new Associate(assoc);

            Friends.TryAdd(friend.UID, associate);
            Owner.Send(AssociatePacket.Create(associate, AssociateAction.AddFriend));
        }
示例#5
0
        public void AddEnemy(Player enemy)
        {
            if (enemy == null)
            {
                return;
            }
            if (HasEnemy(enemy.UID))
            {
                return;
            }
            DbAssociate assoc = new DbAssociate();

            assoc.AssociateID = enemy.UID;
            assoc.Name        = enemy.Name;
            assoc.Type        = (byte)AssociateType.Enemy;
            assoc.UID         = Owner.UID;
            ServerDatabase.Context.Associates.Add(assoc);
            var associate = new Associate(assoc);

            Enemies.TryAdd(enemy.UID, associate);
            Owner.Send(AssociatePacket.Create(associate, AssociateAction.AddEnemy));
        }