示例#1
0
        public static bool IsAllied(Mobile a, Mobile b)
        {
            Guild guildA = a.Guild as Guild;
            Guild guildB = b.Guild as Guild;

            if (guildA != null && guildB != null && (guildA == guildB || guildA.IsAlly(guildB)))
            {
                return(true);
            }

            if (TempCombatants == null)
            {
                return(false);
            }

            TemporaryCombatant tempA = TempCombatants.FirstOrDefault(c => c.From == a);
            TemporaryCombatant tempB = TempCombatants.FirstOrDefault(c => c.From == b);

            if (tempA != null && (tempA.Friendly == b || tempA.FriendlyGuild != null && tempA.FriendlyGuild == guildB))
            {
                return(true);
            }

            if (tempB != null && (tempB.Friendly == a || tempB.FriendlyGuild != null && tempB.FriendlyGuild == guildA))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        public static void RemoveTempCombatant(TemporaryCombatant tempCombatant)
        {
            if (TempCombatants == null)
            {
                return;
            }

            TempCombatants.Remove(tempCombatant);
            tempCombatant.From.Delta(MobileDelta.Noto);
            tempCombatant.From.ProcessDelta();

            if (TempCombatants.Count == 0)
            {
                TempCombatants = null;
                StopTempCombatantTimer();
            }
        }
示例#3
0
        public static TemporaryCombatant GetTempCombatant(Mobile from, Mobile to)
        {
            for (var index = 0; index < TempCombatants.Count; index++)
            {
                TemporaryCombatant combatant = TempCombatants[index];

                if (combatant.From == from)
                {
                    if (combatant.Friendly == null && to == null)
                    {
                        return(combatant);
                    }

                    if (combatant.Friendly == to || combatant.FriendlyGuild != null && combatant.FriendlyGuild == from.Guild as Guild)
                    {
                        return(combatant);
                    }
                }
            }

            return(null);
        }
示例#4
0
        public static void AddTempParticipant(Mobile m, Mobile friendlyTo)
        {
            if (TempCombatants == null)
            {
                TempCombatants = new List <TemporaryCombatant>();
                AddTempCombatantTimer();
            }

            var combatant = GetTempCombatant(m, friendlyTo);

            if (combatant == null)
            {
                combatant = new TemporaryCombatant(m, friendlyTo);
            }
            else
            {
                combatant.Reset();
            }

            TempCombatants.Add(combatant);

            m.Delta(MobileDelta.Noto);
            m.ProcessDelta();
        }