示例#1
0
 public virtual bool IsInSameDivision(IFactionMember opponent)
 {
     if (opponent is Character)
     {
         return(((Character)opponent).IsInSameDivision(this));
     }
     return(IsAlliedWith(opponent));
 }
示例#2
0
        public virtual bool MayAttack(IFactionMember opponent)
        {
            if (HasMaster)
            {
                if (ReferenceEquals(Master, opponent))
                {
                    return(false);
                }
                return(Master.MayAttack(opponent));
            }
            if ((opponent is WorldObject && ((WorldObject)opponent).HasMaster))
            {
                opponent = ((WorldObject)opponent).Master;
            }
            if (opponent == null)
            {
                return(false);
            }
            if (ReferenceEquals(opponent, this))
            {
                return(false);
            }
            var victim = opponent as Unit;

            //var attacker = this as Unit;
            if (victim != null && !victim.IsVisible)
            {
                return(false);
            }
            var character = opponent as Character;

            if (character != null && this is NPC && !character.Client.IsConnected)
            {
                return(false);
            }
            if (character != null)
            {
                return(character.MayAttack(this));
            }


            var faction   = Faction;
            var opFaction = opponent.Faction;

            if (faction == opFaction)
            {
                return(false);
            }

            if (faction != null && opFaction != null && faction.Enemies.Contains(opFaction))
            {
                return(true);
            }
            return(false);
        }
示例#3
0
        /// <summary>
        /// Indicates whether the 2 units are neutral towards each other.
        /// </summary>
        /// <returns></returns>
        public virtual bool IsAtLeastNeutralWith(IFactionMember opponent)
        {
            if (IsFriendlyWith(opponent))
            {
                return(true);
            }

            var faction   = Faction;
            var opFaction = opponent.Faction;

            if (faction != null && opFaction != null && faction.Neutrals.Contains(opFaction))
            {
                return(true);
            }
            return(false);
        }
示例#4
0
        public virtual bool MayAttack(IFactionMember opponent)
        {
            if (HasMaster)
            {
                if (ReferenceEquals(Master, opponent))
                {
                    return(false);
                }
                return(Master.MayAttack(opponent));
            }
            if ((opponent is WorldObject && ((WorldObject)opponent).HasMaster))
            {
                opponent = ((WorldObject)opponent).Master;
            }
            if (opponent == null)
            {
                return(false);
            }
            if (ReferenceEquals(opponent, this))
            {
                return(false);
            }
            if (opponent is Character)
            {
                return(((Character)opponent).MayAttack(this));
            }

            var faction   = Faction;
            var opFaction = opponent.Faction;

            if (faction == opFaction)
            {
                return(false);
            }

            if (faction != null && opFaction != null && faction.Enemies.Contains(opFaction))
            {
                return(true);
            }
            return(false);
        }
示例#5
0
        public virtual bool IsAlliedWith(IFactionMember opponent)
        {
            if (HasMaster)
            {
                if (ReferenceEquals(Master, opponent))
                {
                    return(true);
                }
                return(Master.IsAlliedWith(opponent));
            }
            if ((opponent is WorldObject && ((WorldObject)opponent).HasMaster))
            {
                opponent = ((WorldObject)opponent).Master;
            }
            if (ReferenceEquals(opponent, this))
            {
                return(true);
            }

            if (opponent is Character)
            {
                return(((Character)opponent).IsAlliedWith(this));
            }

            var faction   = Faction;
            var opFaction = opponent.Faction;

            if (faction == opponent.Faction)
            {
                return(true);
            }
            if (faction != null && opponent.Faction != null)
            {
                return(faction.Friends.Contains(opFaction));
            }
            return(false);
        }
示例#6
0
 public void InitFactionMember(IFactionMember factionMember)
 {
     factionMember.onFactionChange  = new FactionChangeEvent();
     factionMember.currentDirectory = GetComponentInParent <Directory>();
 }
示例#7
0
		public override bool MayAttack(IFactionMember opponent)
		{
			if (ReferenceEquals(opponent, this) || (opponent is Unit && ((Unit)opponent).Master == this))
			{
				return false;
			}

			if (opponent is Character)
			{
				return CanPvP((Character)opponent);
			}

			var opFaction = opponent.Faction;
			return m_faction.Enemies.Contains(opFaction) || (!m_faction.Friends.Contains(opFaction) && m_reputations.CanAttack(opFaction));
		}
示例#8
0
        public override bool IsAtLeastNeutralWith(IFactionMember opponent)
        {
            if (IsFriendlyWith(opponent))
            {
                return true;
            }

			var opFaction = opponent.Faction;
			var rep = m_reputations[opFaction.ReputationIndex];
			if (rep != null)
			{
				return rep.Standing >= Standing.Neutral;
			}
			return m_faction.Neutrals.Contains(opFaction);
        }
示例#9
0
文件: Character.cs 项目: Skizot/WCell
		/// <summary>
		/// One can only cast beneficial spells on people that we are allied with
		/// </summary>
		/// <param name="opponent"></param>
		/// <returns></returns>
		public override bool IsAlliedWith(IFactionMember opponent)
		{
			if (opponent == this ||
				(opponent is Unit && ((Unit)opponent).Master == this))
			{
				return true;
			}

			if (opponent is Character)
			{
				if (IsInBattleground)
				{
					return Battlegrounds.Team == ((Character)opponent).Battlegrounds.Team;
				}

				var group = Group;
				if (group != null && ((Character)opponent).Group == group)
				{
					// cannot ally with duelists
					return DuelOpponent == null && ((Character)opponent).DuelOpponent == null;
				}
			}

			return false;
		}
示例#10
0
文件: Character.cs 项目: Skizot/WCell
		public override bool IsFriendlyWith(IFactionMember opponent)
		{
			if (IsAlliedWith(opponent))
			{
				return true;
			}

			var rep = m_reputations[opponent.Faction.ReputationIndex];
			return rep != null && rep.Standing >= Standing.Friendly;
		}
示例#11
0
		public virtual bool IsAlliedWith(IFactionMember opponent)
		{
			if (HasMaster)
			{
				if (ReferenceEquals(Master, opponent)) return true;
				return Master.IsAlliedWith(opponent);
			}
			if ((opponent is WorldObject && ((WorldObject)opponent).HasMaster))
			{
				opponent = ((WorldObject)opponent).Master;
			}
			if (ReferenceEquals(opponent, this))
			{
				return true;
			}

			if (opponent is Character)
			{
				return ((Character)opponent).IsAlliedWith(this);
			}

			var faction = Faction;
			var opFaction = opponent.Faction;
			if (faction == opponent.Faction)
			{
				return true;
			}
			if (faction != null && opponent.Faction != null)
				return faction.Friends.Contains(opFaction);
			return false;
		}
示例#12
0
		/// <summary>
		/// Indicates whether the 2 units are neutral towards each other.
		/// </summary>
		/// <returns></returns>
		public virtual bool IsAtLeastNeutralWith(IFactionMember opponent)
		{
			if (IsFriendlyWith(opponent))
			{
				return true;
			}

			var faction = Faction;
			var opFaction = opponent.Faction;
			if (faction != null && opFaction != null && faction.Neutrals.Contains(opFaction))
			{
				return true;
			}
			return false;
		}
示例#13
0
 public void ChangeFaction(IFactionMember factionMember, FactionType newFaction)
 {
     factionMember.onFactionChange.Invoke(factionMember, factionMember.faction, newFaction);
     factionMember.faction = newFaction;
 }
示例#14
0
 public bool UserMod(IFactionMember origin, IFactionMember target, FactionType newFaction)
 {
     return(true);
 }
示例#15
0
		public override bool MayAttack(IFactionMember opponent)
		{
			if (ReferenceEquals(opponent, this) || (opponent is Unit && ((Unit)opponent).Master == this))
			{
				return false;
			}

			if (opponent is Character)
			{
				return CanPvP((Character)opponent);
			}

			return m_reputations.CanAttack(opponent.Faction);
		}
示例#16
0
		public override bool IsHostileWith(IFactionMember opponent)
		{
			return m_creator.IsHostileWith(opponent);
		}
示例#17
0
		public override bool IsHostileWith(IFactionMember opponent)
		{
			if (object.ReferenceEquals(opponent, this) || (opponent is Unit && ((Unit)opponent).Master == this))
			{
				return false;
			}

			if (opponent is Character)
			{
				var chr = (Character)opponent;
				return CanPvP(chr);
			}

			return m_reputations.IsHostile(opponent.Faction);
		}
示例#18
0
		public override bool IsAlliedWith(IFactionMember opponent)
		{
			return m_creator.IsAlliedWith(opponent);
		}
示例#19
0
		public virtual bool MayAttack(IFactionMember opponent)
		{
			if (HasMaster)
			{
				if (ReferenceEquals(Master, opponent)) return false;
				return Master.MayAttack(opponent);
			}
			if ((opponent is WorldObject && ((WorldObject)opponent).HasMaster))
			{
				opponent = ((WorldObject)opponent).Master;
			}
			if (opponent == null)
			{
				return false;
			}
			if (ReferenceEquals(opponent, this))
			{
				return false;
			}
			if (opponent is Character)
			{
				return ((Character)opponent).MayAttack(this);
			}

			var faction = Faction;
			var opFaction = opponent.Faction;
			if (faction == opFaction)
			{
				return false;
			}

			if (faction != null && opFaction != null && faction.Enemies.Contains(opFaction))
			{
				return true;
			}
			return false;
		}
示例#20
0
		public override bool IsFriendlyWith(IFactionMember opponent)
		{
			return m_creator.IsFriendlyWith(opponent);
		}
示例#21
0
		public virtual bool IsInSameDivision(IFactionMember opponent)
		{
			if (opponent is Character)
			{
				return ((Character)opponent).IsInSameDivision(this);
			}
			return IsAlliedWith(opponent);
		}
示例#22
0
文件: Character.cs 项目: Jeroz/WCell
		public override bool MayAttack(IFactionMember opponent)
		{
			// TODO: Sometimes we are hostile with someone but cannot attack
			return IsHostileWith(opponent);
		}
示例#23
0
文件: Character.cs 项目: Skizot/WCell
		public override bool MayAttack(IFactionMember opponent)
		{
			if (opponent == this || (opponent is Unit && ((Unit)opponent).Master == this))
			{
				return false;
			}

			if (opponent is Character)
			{
				var chr = (Character)opponent;
				return CanPvP(chr);
			}

			return m_reputations.CanAttack(opponent.Faction);
		}
示例#24
0
		/// <summary>
		/// Indicates whether the 2 units are hostile towards each other.
		/// </summary>
		/// <returns></returns>
		public virtual bool IsHostileWith(IFactionMember opponent)
		{
			if ( object.ReferenceEquals(opponent, this) || (opponent is Unit && ((Unit)opponent).Master == this))
			{
				return false;
			}

			var faction = Faction;
			var opFaction = opponent.Faction;
			if (faction == opFaction)
			{
				return false;
			}

			if (faction != null && opFaction != null && faction.Enemies.Contains(opFaction))
			{
				return true;
			}

			if (opponent is Character)
			{
				return ((Character)opponent).IsHostileWith(this);
			}
			return false;
		}
示例#25
0
		public override bool IsFriendlyWith(IFactionMember opponent)
		{
			if (IsAlliedWith(opponent))
			{
				return true;
			}

			var opFaction = opponent.Faction;
			var rep = m_reputations[opFaction.ReputationIndex];
			if (rep != null)
			{
				return rep.Standing >= Standing.Friendly;
			}
			return m_faction.IsFriendlyTowards(opFaction);
		}
示例#26
0
		public virtual bool MayAttack(IFactionMember opponent)
		{
			if (!opponent.IsInWorld ||  ReferenceEquals(opponent, this) || (opponent is Unit && ((Unit)opponent).Master == this))
			{
				return false;
			}

			var faction = Faction;
			var opFaction = opponent.Faction;
			if (faction == opFaction)
			{
				return false;
			}

			if (faction != null && opFaction != null)
			{
				if (faction.Enemies.Contains(opFaction))
				{
					return true;
				}

				if (faction.Friends.Contains(opFaction))
				{
					return false;
				}
			}

			if (opponent is Character)
			{
				return ((Character)opponent).MayAttack(this);
			}
			return false;
		}
示例#27
0
		public override bool IsHostileWith(IFactionMember opponent)
		{
			if (ReferenceEquals(opponent, this) || (opponent is Unit && ((Unit)opponent).Master == this))
			{
				return false;
			}

			if (opponent is Character)
			{
				return CanPvP((Character)opponent);
			}

			var opFaction = opponent.Faction;

			if (opponent is NPC && opFaction.Neutrals.Contains(m_faction))
			{
				return ((NPC)opponent).ThreatCollection.HasAggressor(this);
			}

			if(m_faction.Friends.Contains(opFaction))
				return false;

			return m_faction.Enemies.Contains(opFaction) && m_reputations.CanAttack(opFaction);
		}
示例#28
0
		public virtual bool IsAlliedWith(IFactionMember opponent)
		{
			if ( object.ReferenceEquals(opponent, this) ||
				(opponent is Unit && ((Unit)opponent).Master == this) ||
				 object.ReferenceEquals(Master, opponent) )
			{
				return true;
			}

			if (opponent is Character)
			{
				return ((Character)opponent).IsAlliedWith(this);
			}

			var faction = Faction;
			var opFaction = opponent.Faction;
			if (faction == opponent.Faction)
			{
				return true;
			}
			if (faction != null && opponent.Faction != null)
				return faction.Friends.Contains(opFaction);
			return false;
		}
示例#29
0
		public override bool IsInSameDivision(IFactionMember opponent)
		{
			if (ReferenceEquals(opponent, this) ||
				(opponent is Unit && ((Unit)opponent).Master == this))
			{
				return true;
			}

			if (!(opponent is Character) && opponent is WorldObject)
			{
				opponent = ((WorldObject)opponent).Master;
			}

			if (opponent is Character)
			{
				if (IsInBattleground)
				{
					return Battlegrounds.Team == ((Character)opponent).Battlegrounds.Team;
				}

				var group = SubGroup;
				if (group != null && ((Character)opponent).SubGroup == group)
				{
					// cannot ally with duelists
					return DuelOpponent == null && ((Character)opponent).DuelOpponent == null;
				}
			}
			return false;
		}
示例#30
0
        public override bool IsNeutralWith(IFactionMember opponent)
		{
            return m_master.IsNeutralWith(opponent);
		}