当前位置: 首页>>代码示例>>C#>>正文


C# Mobile.GetDistanceToSqrt方法代码示例

本文整理汇总了C#中Server.Mobile.GetDistanceToSqrt方法的典型用法代码示例。如果您正苦于以下问题:C# Mobile.GetDistanceToSqrt方法的具体用法?C# Mobile.GetDistanceToSqrt怎么用?C# Mobile.GetDistanceToSqrt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server.Mobile的用法示例。


在下文中一共展示了Mobile.GetDistanceToSqrt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FireWall

        public static void FireWall( Mobile from, Mobile target )
        {
            Effects.SendPacket( from.Location, from.Map, new FlashEffect( FlashType.LightFlash ) );
            Effects.PlaySound( from.Location, from.Map, 0x44B );

            Direction d = from.GetDirectionTo( target );

            int dx, dy;
            bool diagonal;

            GetDirectionOffset( d, out dx, out dy, out diagonal );

            int length = 1 + (int) Math.Min( from.GetDistanceToSqrt( target ), 10 );

            for ( int i = 0; i < length; i++ )
            {
                int x = from.Location.X + ( dx * i );
                int y = from.Location.Y + ( dy * i );

                Point3D loc = new Point3D( x, y, from.Location.Z );

                TimeSpan duration = TimeSpan.FromSeconds( 100.0 - ( i * 9.0 ) );

                if ( d == Direction.West || d == Direction.East || diagonal )
                    new FireFieldItem( from, loc, from.Map, 0x398C, duration );

                if ( d == Direction.North || d == Direction.South || diagonal )
                    new FireFieldItem( from, loc, from.Map, 0x3996, duration );
            }
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:30,代码来源:MonsterHelper.cs

示例2: OnDoubleClick

        public override void OnDoubleClick( Mobile from )
        {
            PlayerMobile pm = from as PlayerMobile;

            if ( pm == null )
                return;

            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
                return;
            }

            if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
                return;
            }

            if ( pm.Bedlam )
            {
                BaseCreature.TeleportPets( pm, BedlamEntrance, from.Map );
                pm.MoveToWorld( BedlamEntrance, Map );
            }
            else
            {
                pm.SendLocalizedMessage( 1074276 ); // You press and push on the iron maiden, but nothing happens.
            }
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:29,代码来源:BedlamTeleport.cs

示例3: OnHit

		public override void OnHit(Mobile attacker, Mobile defender, int damage)
		{
			if (!Validate(attacker) || !CheckMana(attacker, true))
				return;

			ClearCurrentAbility(attacker);


			attacker.SendMessage("You poisoned your target.");
			defender.SendMessage("You've been poisoned.");

			int level;

			if (Core.AOS)
			{
				if (attacker.InRange(defender, 2))
				{
					int total = (attacker.Skills.Poisoning.Fixed) / 2;

					if (total >= 1000)
						level = 3;
					else if (total > 850)
						level = 2;
					else if (total > 650)
						level = 1;
					else
						level = 0;
				}
				else
				{
					level = 0;
				}
			}
			else
			{
				double total = attacker.Skills[SkillName.Poisoning].Value;

				double dist = attacker.GetDistanceToSqrt(defender);

				if (dist >= 3.0)
					total -= (dist - 3.0) * 10.0;

				if (total >= 200.0 && 1 > Utility.Random(10))
					level = 3;
				else if (total > (Core.AOS ? 170.1 : 170.0))
					level = 2;
				else if (total > (Core.AOS ? 130.1 : 130.0))
					level = 1;
				else
					level = 0;
			}

			defender.ApplyPoison(attacker, Poison.GetPoison(level));

			defender.FixedParticles(0x374A, 10, 15, 5021, EffectLayer.Waist);
			defender.PlaySound(0x474);
		}
开发者ID:ITLongwell,项目名称:aedilis2server,代码行数:57,代码来源:SerpentArrow.cs

示例4: OnTarget

        public void OnTarget(Mobile from, object targeted)
        {
            if (targeted is BattleChickenLizard && !((BattleChickenLizard)targeted).Controlled)
            {
                BattleChickenLizard bcl = (BattleChickenLizard)targeted;

                int chance = 50 / (int)Math.Max(1, from.GetDistanceToSqrt(bcl.Location));

                if (chance > Utility.Random(100))
                {
                    bcl.Frozen = true;

                    m_Timer = new InternalTimer(this, bcl, from);
                    from.SendLocalizedMessage(1112484); //You successfully ensnare the chicken! You best hurry before it frees itself from it!
                }
                else
                    from.SendLocalizedMessage(1112483); //The collar falls to the ground as the chicken deftly avoids it.
            }
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:19,代码来源:ScaleCollar.cs

示例5: OnDoubleClick

        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
                return;
            }

            if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
            {
                from.SendLocalizedMessage( 500446 ); // That is too far away.
                return;
            }

            Point3D dest = new Point3D( 330, 1973, 0 );
            Map map = Map.Malas;

            BaseCreature.TeleportPets( from, dest, map );
            from.MoveToWorld( dest, map );
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:20,代码来源:LabyrinthDoor.cs

示例6: CheckArtifactChance

        private static bool CheckArtifactChance( Mobile from, BaseCreature bc )
        {
            if ( !from.Alive )
                return false;

            Region r = from.Region;

            if ( r.Name != "Covetous" && r.Name != "Deceit" && r.Name != "Despise" && r.Name != "Destard" && r.Name != "Hythloth" && r.Name != "Shame" && r.Name != "Wrong" )
                return false;

            if ( from.GetDistanceToSqrt( bc ) > 16 )
                return false;

            double fame = (double) bc.Fame;

            PlayerMobile pm = from as PlayerMobile;

            int luck = pm.Luck;

            double chance = fame / 1000000000;

            if ( from.Hidden )
                chance /= 2;

            pm.TenthAnniversaryCredits += chance;

            chance = pm.TenthAnniversaryCredits;

            if ( luck > 0 )
            {
                double luckmodifier = ( (double) luck / 600 );

                if ( luckmodifier < 1 )
                    luckmodifier = 1;

                chance *= luckmodifier;
            }

            return chance > Utility.RandomDouble();
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:40,代码来源:TenthAnniversary.cs

示例7: AbsorbDamage

        public override int AbsorbDamage( Mobile attacker, Mobile defender, int damage )
        {
            damage = base.AbsorbDamage( attacker, defender, damage );

            if ( defender.MeleeDamageAbsorb > 0 && attacker.GetDistanceToSqrt( defender ) <= 1 )
            {
                double absorb = (double)(damage * defender.MeleeDamageAbsorb) / 100.0;
                if ( absorb > damage )
                    absorb = damage;

                attacker.PlaySound( 0x1F1 );
                attacker.FixedEffect( 0x374A, 10, 16 );

                if ( absorb >= 1 )
                {
                    attacker.Damage( ((int)absorb + 1) / 2 ); // since damage is havled before its applied... halve it here too
                    damage -= (int)absorb;
                }
            }

            return damage;
        }
开发者ID:FreeReign,项目名称:Rebirth-Repack,代码行数:22,代码来源:BaseMeleeWeapon.cs

示例8: OnDoubleClick

        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.Alive )
                return;

            if ( !from.InLOS( this.GetWorldLocation() ) )
            {
                from.SendLocalizedMessage( 502800 ); // You can't see that.
            }
            else if ( from.GetDistanceToSqrt( this.GetWorldLocation() ) > 2 )
            {
                from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
            }
            else
            {
                Point3D dest = new Point3D( 107, 1883, 0 );

                BaseCreature.TeleportPets( from, dest, Map.Malas );
                from.MoveToWorld( dest, Map.Malas );

                from.SendLocalizedMessage( 1072730 ); // The manor lord is unavailable. Please use the teleporter on your right.
            }
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:23,代码来源:Citadel.cs

示例9: GetAllAttackers

        public static ArrayList GetAllAttackers( Mobile m, int range )
        {
            ArrayList targets = new ArrayList();

            if ( m.Combatant != null && m.InLOS( m.Combatant ) )
            {
                if ( m.GetDistanceToSqrt( m.Combatant ) <= range )
                {
                    targets.Add( m.Combatant );
                }
            }

            // Current combatant has double chance to get an attack because of the above code

            foreach ( Mobile t in m.GetMobilesInRange( range ) )
            {
                if ( t.Combatant == m && m.InLOS( t ) && !t.Hidden )
                {
                    targets.Add( t );
                }
            }

            return targets;
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:24,代码来源:BaseAttackHelperSE.cs

示例10: OnDoubleClick

        public override void OnDoubleClick( Mobile from )
        {
            ArrayList list = StrongBox.Table[from] as ArrayList;
            if ( list != null && list.Count > 1 )
            {
                from.SendAsciiMessage( "You already own a strong box, you cannot place another!" );
                return;
            }

            BaseHouse h = BaseHouse.FindHouseAt( from );
            if ( h != null && h.IsOwner( from ) && !(h is Tent) && h.IsInside( from ) )
            {
                IPooledEnumerable eable = h.GetItemsInRange( 18 );
                foreach ( Item i in eable )
                {
                    if ( h.IsInside( i ) )
                    {
                        if ( i is BaseDoor && ( i.X == from.X || i.Y == from.Y ) && from.GetDistanceToSqrt( i ) < 2 && i.Z-5 < from.Z && i.Z+5 > from.Z )
                        {
                            from.SendAsciiMessage( "You cannot place this in front of a door." );
                            eable.Free();
                            return;
                        }
                        else if ( i is StrongBox )
                        {
                            from.SendAsciiMessage( "There is already a strong box in this house." );
                            eable.Free();
                            return;
                        }
                    }
                }
                eable.Free();

                StrongBox s = new StrongBox( from, h );
                s.MoveToWorld( from.Location, from.Map );
                this.Delete();
            }
            else
            {
                from.SendAsciiMessage( "You must be in a house you own in order to place a strong box." );
            }
        }
开发者ID:FreeReign,项目名称:Rebirth-Repack,代码行数:42,代码来源:StrongBox.cs

示例11: OnDoubleClick

		public override void OnDoubleClick( Mobile from )
		{
			from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1008155 ); // You peer into the heavens, seeking the moons...

			from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Trammel, from.X, from.Y ), "", AffixType.Prepend, "Trammel : ", "" ) );
			
            // Scriptiz : on ne joue pas sur felucca
            //from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Felucca, from.X, from.Y ), "", AffixType.Prepend, "Felucca : ", "" ) );

			PlayerMobile player = from as PlayerMobile;

            /* Scriptiz : Code pour repérer les autres bateaux (source : Alambik) */
            // Get the maximum range the player can see
            // A cartograph master with a tracking master experience lead to see to 125 tiles: A true captain!
            int MinimumRange = 25; //Regular 800x600 screen + "normal" extra
            int MaximumExtraRange = 100;
            int ExtraRange = MaximumExtraRange *
                  ((int)(from.Skills[SkillName.Cartography].Value) +
                   (int)(from.Skills[SkillName.Tracking].Value)) / 200;
            int range = MinimumRange + ExtraRange;

            foreach (Item item in from.GetItemsInRange(range))
            {
                if (item is BaseBoat)
                {
                    // Player can see the boat
                    BaseBoat baseboat = (BaseBoat)item;
                    if (!(baseboat.Contains(from))) // On va éviter de répeter qu'on voit son propre bateau
                    {
                        /* Scriptiz : implémentation du tracking */
                        // If the player is good at tracking, let him track a mobile on the boat
                        if(from.Skills[SkillName.Tracking].Value * 2 >= from.GetDistanceToSqrt(baseboat.Location))
                        {
                            foreach (Mobile m in baseboat.GetMobilesInRange(15))
                            {
                                if (m == null) continue;
                                if (baseboat.Contains(m))
                                {
                                    from.QuestArrow = new TrackArrow(from, m, range);
                                    break;
                                }
                            }
                        }

                        // Get the name if not too far
                        string name = "un navire";
                        if (from.InRange(item.Location, MinimumRange + MaximumExtraRange / 5))
                            if (baseboat.ShipName != null)
                                name = "le" + baseboat.ShipName;

                        // Is it far?
                        string distance = "à l'horizon";
                        if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 1 / 5))
                            distance = "à côté";
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 2 / 5))
                            distance = "proche";
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 3 / 5))
                            distance = "loin";
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 4 / 5))
                            distance = "très loin";

                        // Get the relative direction of the seen boat
                        string direction;
                        // north/south
                        if (from.Y < baseboat.Y)
                            direction = "Sud";
                        else
                            direction = "Nord";
                        // east/west (Scriptiz : correction est <> ouest)
                        if (from.X < baseboat.X)
                            direction = direction + " Est";
                        else
                            direction = direction + " Ouest";

                        //Does the boat is moving?
                        string mobility = "est immobile";
                        if (baseboat.IsMoving)
                        {
                            mobility = "bouge vers ";
                            switch (baseboat.Moving)
                            {
                                case Direction.North: mobility += "le nord"; break;
                                case Direction.South: mobility += "le sud"; break;
                                case Direction.East: mobility += "l'est"; break;
                                case Direction.West: mobility += "l'ouest"; break;
                                case Direction.Up: mobility += "le nord-ouest"; break;
                                case Direction.Down: mobility += "le sud-est"; break;
                                case Direction.Left: mobility += "le sud-ouest"; break;
                                case Direction.Right: mobility += "le nord-est"; break;
                                default: break;
                            }
                        }
                        from.SendMessage("Vous voyez {0} au {1}. Il est {2} et {3}.", name, direction, distance, mobility);
                    }
                }
            }
            /* Scriptiz : fin du code de Alambik */

			if ( player != null )
			{
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:vivre-uo,代码行数:101,代码来源:Spyglass.cs

示例12: OnDoubleClick

        public override void OnDoubleClick( Mobile from )
        {
            if ( !from.InRange( GetWorldLocation(), 2 ) )
            {
                from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
                return;
            }

            Point2D[] banks;
            PMList moongates;
            if ( from.Map == Map.Trammel )
            {
                banks = m_TrammelBanks;
                moongates = PMList.Trammel;
            }
            else if ( from.Map == Map.Felucca )
            {
                banks = m_FeluccaBanks;
                moongates = PMList.Felucca;
            }
            else if ( from.Map == Map.Ilshenar )
            {
            #if false
                banks = m_IlshenarBanks;
                moongates = PMList.Ilshenar;
            #else
                from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x482, 3, 1061684, "", "" ) ); // The magic of the sextant fails...
                return;
            #endif
            }
            else if ( from.Map == Map.Malas )
            {
                banks = m_MalasBanks;
                moongates = PMList.Malas;
            }
            else
            {
                banks = null;
                moongates = null;
            }

            Point3D closestMoongate = Point3D.Zero;
            double moongateDistance = double.MaxValue;
            if ( moongates != null )
            {
                foreach ( PMEntry entry in moongates.Entries )
                {
                    double dist = from.GetDistanceToSqrt( entry.Location );
                    if ( moongateDistance > dist )
                    {
                        closestMoongate = entry.Location;
                        moongateDistance = dist;
                    }
                }
            }

            Point2D closestBank = Point2D.Zero;
            double bankDistance = double.MaxValue;
            if ( banks != null )
            {
                foreach ( Point2D p in banks )
                {
                    double dist = from.GetDistanceToSqrt( p );
                    if ( bankDistance > dist )
                    {
                        closestBank = p;
                        bankDistance = dist;
                    }
                }
            }

            int moonMsg;
            if ( moongateDistance == double.MaxValue )
                moonMsg = 1048021; // The sextant fails to find a Moongate nearby.
            else if ( moongateDistance > m_LongDistance )
                moonMsg = 1046449 + (int)from.GetDirectionTo( closestMoongate ); // A moongate is * from here
            else if ( moongateDistance > m_ShortDistance )
                moonMsg = 1048010 + (int)from.GetDirectionTo( closestMoongate ); // There is a Moongate * of here.
            else
                moonMsg = 1048018; // You are next to a Moongate at the moment.

            from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x482, 3, moonMsg, "", "" ) );

            int bankMsg;
            if ( bankDistance == double.MaxValue )
                bankMsg = 1048020; // The sextant fails to find a Bank nearby.
            else if ( bankDistance > m_LongDistance )
                bankMsg = 1046462 + (int)from.GetDirectionTo( closestBank ); // A town is * from here
            else if ( bankDistance > m_ShortDistance )
                bankMsg = 1048002 + (int)from.GetDirectionTo( closestBank ); // There is a city Bank * of here.
            else
                bankMsg = 1048019; // You are next to a Bank at the moment.

            from.Send( new MessageLocalized( Serial, ItemID, MessageType.Label, 0x5AA, 3, bankMsg, "", "" ) );
        }
开发者ID:Godkong,项目名称:Origins,代码行数:95,代码来源:EnchantedSextant.cs

示例13: HandlesOnSpeech

		public override bool HandlesOnSpeech( Mobile from )
		{
			return ( from.Alive && from.GetDistanceToSqrt( this ) <= 3 );
		}
开发者ID:greeduomacro,项目名称:unknown-shard-1,代码行数:4,代码来源:PlayerVendor.cs

示例14: SpillAcid

        public static void SpillAcid( Mobile from, bool yamandon )
        {
            ArrayList targets = GetAllAttackers( from, 2 );

            if ( yamandon )
            {
                targets.Add( from );
            }

            Effects.SendLocationParticles( EffectItem.Create( from.Location, from.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 76, 3, 5042, 0 );

            if ( targets.Count == 0 )
            {
                return;
            }

            foreach ( Mobile m in targets )
            {
                m.FixedParticles( 0x374A, 10, 15, 5021, EffectLayer.Waist );
                m.PlaySound( 0x474 );

                if ( yamandon )
                {
                    m.ApplyPoison( from, Poison.GetPoison( 4 ) );
                }
                else
                {
                    m.ApplyPoison( from, Poison.GetPoison( Utility.Random( 5 ) - ( from.GetDistanceToSqrt( m ) > 1 ? 1 : 0 ) ) );
                }

                m.SendLocalizedMessage( 1070820 ); // The creature spills a pool of acidic slime!
            }
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:33,代码来源:BaseAttackHelperSE.cs

示例15: CheckGuardCandidate

		public void CheckGuardCandidate( Mobile m )
		{
			if ( IsGuarded == false )
				return;

			if ( IsGuardCandidate( m ) )
			{
				GuardTimer timer = (GuardTimer)m_GuardCandidates[m];

				if ( timer == null )
				{
					timer = new GuardTimer( m, m_GuardCandidates );
					timer.Start();

					m_GuardCandidates[m] = timer;
					m.SendLocalizedMessage( 502275 ); // Guards can now be called on you!

					Map map = m.Map;

					if ( map != null )
					{
						Mobile fakeCall = null;
						double prio = 0.0;

						IPooledEnumerable eable = m.GetMobilesInRange( 8 );
						foreach ( Mobile v in eable)
						{
							if ( !v.Player &&
								  v.Body.IsHuman && 
								  v != m && 
								 !IsGuardCandidate( v ) )
							{
								//Pixie 10/28/04: checking whether v is in the region fixes the problem
								// where player1 recalls to a guardzone before player2's explosion hits ...
								if( this.Contains( v.Location ) )
								{
									double dist = m.GetDistanceToSqrt( v );

									if ( fakeCall == null || dist < prio )
									{
										fakeCall = v;
										prio = dist;
									}
								}
								else
								{
									//System.Console.WriteLine( "Mobile ({0}) isn't in this region, so skip him!", v.Name );
								}
							}
						}
						eable.Free();

						if ( fakeCall != null )
						{
							fakeCall.Say( Utility.RandomList( 1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052 ) );
							MakeGuard( m );
							m_GuardCandidates.Remove( m );
							m.SendLocalizedMessage( 502276 ); // Guards can no longer be called on you.
						}
					}
				}
				else
				{
					timer.Stop();
					timer.Start();
				}
			}
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:68,代码来源:GuardedRegion.cs


注:本文中的Server.Mobile.GetDistanceToSqrt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。