Beispiel #1
0
        public void SendRelation(Character pTarget)
        {
            if (pTarget.FamilyIdentity != Identity)
            {
                return;
            }

            foreach (var allies in Allies.Values)
            {
                MsgFamily pMsg = new MsgFamily
                {
                    Identity = Identity,
                    Type     = FamilyType.SEND_ALLY
                };
                pMsg.AddRelation(allies.Identity, allies.Name, allies.LeaderName);
                pTarget.Send(pMsg);
            }

            foreach (var enemies in Enemies.Values)
            {
                MsgFamily pMsg = new MsgFamily
                {
                    Identity = Identity,
                    Type     = FamilyType.SEND_ENEMY
                };
                pMsg.AddRelation(enemies.Identity, enemies.Name, enemies.LeaderName);
                pTarget.Send(pMsg);
            }
        }
Beispiel #2
0
        public bool AllyFamily(Family pTarget)
        {
            if (IsAlly(pTarget.Identity) || IsEnemy(pTarget.Identity))
            {
                return(false);
            }

            if (Allies.Count >= 5 || pTarget.Allies.Count >= 5)
            {
                return(false);
            }

            MsgFamily pMsg = new MsgFamily
            {
                Identity = pTarget.Identity,
                Type     = FamilyType.SEND_ALLY
            };

            pMsg.AddRelation(pTarget.Identity, pTarget.Name, pTarget.LeaderName);
            Send(pMsg);
            pMsg = new MsgFamily
            {
                Identity = Identity,
                Type     = FamilyType.SEND_ALLY
            };
            pMsg.AddRelation(Identity, Name, LeaderName);
            pTarget.Send(pMsg);

            pTarget.SetAlly(Identity);
            SetAlly(pTarget.Identity);
            return(Save() && Allies.TryAdd(pTarget.Identity, pTarget) &&
                   pTarget.Save() && pTarget.Allies.TryAdd(Identity, this));
        }
Beispiel #3
0
        public bool RemoveEnemy(Family pTarget)
        {
            if (!IsEnemy(pTarget.Identity))
            {
                return(false);
            }

            MsgFamily pMsg = new MsgFamily
            {
                Identity = pTarget.Identity,
                Type     = FamilyType.DELETE_ENEMY
            };

            pMsg.AddRelation(pTarget.Identity, pTarget.Name, pTarget.LeaderName);
            pTarget.Send(pMsg);

            ClearEnemy(pTarget.Identity);
            Family trash;

            return(Save() && Enemies.TryRemove(pTarget.Identity, out trash));
        }
Beispiel #4
0
        public bool EnemyFamily(Family pTarget)
        {
            if (IsAlly(pTarget.Identity) || IsEnemy(pTarget.Identity))
            {
                return(false);
            }

            if (Enemies.Count >= 5)
            {
                return(false);
            }

            MsgFamily pMsg = new MsgFamily
            {
                Identity = Identity,
                Type     = FamilyType.SEND_ENEMY
            };

            pMsg.AddRelation(pTarget.Identity, pTarget.Name, pTarget.LeaderName);
            pTarget.Send(pMsg);

            SetEnemy(pTarget.Identity);
            return(Save() && Enemies.TryAdd(pTarget.Identity, pTarget));
        }