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


C# HarvestDefinition.Validate方法代码示例

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


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

示例1: FinishHarvesting

		public virtual void FinishHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked )
		{
			from.EndAction( locked );

			if ( !CheckHarvest( from, tool ) )
				return;

			int tileID;
			Map map;
			Point3D loc;

			if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
			{
				OnBadHarvestTarget( from, tool, toHarvest );
				return;
			}
			else if ( !def.Validate( tileID ) )
			{
				OnBadHarvestTarget( from, tool, toHarvest );
				return;
			}
			
			if ( !CheckRange( from, tool, def, map, loc, true ) )
				return;
			else if ( !CheckResources( from, tool, def, map, loc, true ) )
				return;
			else if ( !CheckHarvest( from, tool, def, toHarvest ) )
				return;

			if ( SpecialHarvest( from, tool, def, map, loc ) )
				return;

			HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

			if ( bank == null )
				return;

			HarvestVein vein = bank.Vein;

			if ( vein != null )
				vein = MutateVein( from, tool, def, bank, toHarvest, vein );

			if ( vein == null )
				return;

			HarvestResource primary = vein.PrimaryResource;
			HarvestResource fallback = vein.FallbackResource;
			HarvestResource resource = MutateResource( from, tool, def, map, loc, vein, primary, fallback );

			double skillBase = from.Skills[def.Skill].Base;
			double skillValue = from.Skills[def.Skill].Value;

			Type type = null;

			if ( skillBase >= resource.ReqSkill && from.CheckSkill( def.Skill, resource.MinSkill, resource.MaxSkill ) )
			{
				type = GetResourceType( from, tool, def, map, loc, resource );

				if ( type != null )
					type = MutateType( type, from, tool, def, map, loc, resource );

				if ( type != null )
				{
					Item item = Construct( type, from );

					if ( item == null )
					{
						type = null;
					}
					else
					{
						//The whole harvest system is kludgy and I'm sure this is just adding to it.
						if ( item.Stackable )
						{
							int amount = def.ConsumedPerHarvest;
							int feluccaAmount = def.ConsumedPerFeluccaHarvest;

							int racialAmount = (int)Math.Ceiling( amount * 1.1 );
							int feluccaRacialAmount = (int)Math.Ceiling( feluccaAmount * 1.1 );

							bool eligableForRacialBonus = ( def.RaceBonus && from.Race == Race.Human );
							bool inFelucca = (map == Map.Felucca);

							if( eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount )
								item.Amount = feluccaRacialAmount;
							else if( inFelucca && bank.Current >= feluccaAmount )
								item.Amount = feluccaAmount;
							else if( eligableForRacialBonus && bank.Current >= racialAmount )
								item.Amount = racialAmount;
							else
								item.Amount = amount;
						}

						bank.Consume( item.Amount, from );

						if ( Give( from, item, def.PlaceAtFeetIfFull ) )
						{
							SendSuccessTo( from, item, resource );
						}
						else
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:annox,代码行数:101,代码来源:HarvestSystem.cs

示例2: OnHarvesting

		public virtual bool OnHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked, bool last )
		{
			if ( !CheckHarvest( from, tool ) )
			{
				from.EndAction( locked );
				return false;
			}

			int tileID;
			Map map;
			Point3D loc;

			if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
			{
				from.EndAction( locked );
				OnBadHarvestTarget( from, tool, toHarvest );
				return false;
			}
			else if ( !def.Validate( tileID ) )
			{
				from.EndAction( locked );
				OnBadHarvestTarget( from, tool, toHarvest );
				return false;
			}
			else if ( !CheckRange( from, tool, def, map, loc, true ) )
			{
				from.EndAction( locked );
				return false;
			}
			else if ( !CheckResources( from, tool, def, map, loc, true ) )
			{
				from.EndAction( locked );
				return false;
			}
			else if ( !CheckHarvest( from, tool, def, toHarvest ) )
			{
				from.EndAction( locked );
				return false;
			}

			DoHarvestingEffect( from, tool, def, map, loc );

			new HarvestSoundTimer( from, tool, this, def, toHarvest, locked, last ).Start();

			return !last;
		}
开发者ID:greeduomacro,项目名称:annox,代码行数:46,代码来源:HarvestSystem.cs

示例3: FinishHarvesting

        public virtual void FinishHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked )
        {
            from.EndAction( locked );

            if ( !CheckHarvest( from, tool ) )
                return;

            int tileID;
            Map map;
            Point3D loc;

            if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
            {
                OnBadHarvestTarget( from, tool, toHarvest );
                return;
            }
            else if ( !def.Validate( tileID ) )
            {
                OnBadHarvestTarget( from, tool, toHarvest );
                return;
            }

            if ( !CheckRange( from, tool, def, map, loc, true ) )
                return;
            else if ( !CheckResources( from, tool, def, map, loc, true ) )
                return;
            else if ( !CheckHarvest( from, tool, def, toHarvest ) )
                return;

            if ( SpecialHarvest( from, tool, def, map, loc ) )
                return;

            HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

            if ( bank == null )
                return;

            HarvestVein vein = bank.Vein;

            if ( vein != null )
                vein = MutateVein( from, tool, def, bank, toHarvest, vein );

            if ( vein == null )
                return;

            HarvestResource primary = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource( from, tool, def, map, loc, vein, primary, fallback );

            double skillBase = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            if ( skillBase >= resource.ReqSkill && from.CheckSkill( def.Skill, resource.MinSkill, resource.MaxSkill ) )
            {
                type = GetResourceType( from, tool, def, map, loc, resource );

                if ( type != null )
                    type = MutateType( type, from, tool, def, map, loc, resource );

                if ( type != null )
                {
                    Item item = Construct( type, from );

                    if ( item == null )
                    {
                        type = null;
                    }
                    else
                    {
                        if ( item.Stackable )
                        {
                            if ( map == Map.Felucca && bank.Current >= def.ConsumedPerFeluccaHarvest )
                                item.Amount = def.ConsumedPerFeluccaHarvest;
                            else
                                item.Amount = def.ConsumedPerHarvest;
                        }

                        bank.Consume( def, item.Amount );

                        if ( Give( from, item, def.PlaceAtFeetIfFull ) )
                        {
                            SendSuccessTo( from, item, resource );
                        }
                        else
                        {
                            SendPackFullTo( from, item, def, resource );
                            item.Delete();
                        }

                        if ( tool is IUsesRemaining )
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if ( toolWithUses.UsesRemaining > 0 )
                                --toolWithUses.UsesRemaining;

//.........这里部分代码省略.........
开发者ID:justdanofficial,项目名称:khaeros,代码行数:101,代码来源:HarvestSystem.cs

示例4: FinishHarvesting

        public override void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            //Lava fishing needs to have its own set of rules.
            if (IsLavaHarvest(tool, toHarvest))
            {
                from.EndAction(locked);

                if (!CheckHarvest(from, tool))
                    return;

                int tileID;
                Map map;
                Point3D loc;

                if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }
                else if (!def.Validate(tileID) && !def.ValidateSpecial(tileID))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }

                if (!CheckRange(from, tool, def, map, loc, true))
                    return;
                else if (!CheckResources(from, tool, def, map, loc, true))
                    return;
                else if (!CheckHarvest(from, tool, def, toHarvest))
                    return;

                HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

                if (bank == null)
                    return;

                HarvestVein vein = bank.Vein;

                if (vein == null)
                    return;

                Type type = null;

                HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, vein.PrimaryResource, vein.FallbackResource);

                if (from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
                {
                    //Special eye candy item
                    type = GetSpecialLavaItem(from, tool, map, loc, toHarvest);

                    //Special fish
                    if (type == null)
                        type = FishInfo.GetSpecialItem(from, tool, loc, IsLavaHarvest(tool, tileID));

                    if (type != null)
                    {
                        Item item = Construct(type, from, tool);

                        if (item == null)
                        {
                            type = null;
                        }
                        else
                        {
                            if (from.AccessLevel == AccessLevel.Player)
                                bank.Consume(Convert.ToInt32(map != null && map.Rules == MapRules.FeluccaRules ? Math.Ceiling(item.Amount / 2.0) : item.Amount), from);

                            if (Give(from, item, true))
                            {
                                SendSuccessTo(from, item, null);
                            }
                            else
                            {
                                SendPackFullTo(from, item, def, null);
                                item.Delete();
                            }
                        }
                    }
                }

                if (type == null)
                {
                    def.SendMessageTo(from, def.FailMessage);

                    double skill = (double)from.Skills[SkillName.Fishing].Value / 50;

                    if (0.5 / skill > Utility.RandomDouble())
                        OnToolUsed(from, tool, false);
                }
                else
                    OnToolUsed(from, tool, true);

                OnHarvestFinished(from, tool, def, vein, bank, null, null);
            }
            else
                base.FinishHarvesting(from, tool, def, toHarvest, locked);
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:98,代码来源:Fishing.cs

示例5: FinishHarvesting

		public virtual void FinishHarvesting( Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked )
		{
            if (from is PlayerMobile)
                ((PlayerMobile)from).EndPlayerAction();

            if (!CheckHarvest(from, tool))
                return;

            if (!CheckAllowed(from))
                return;

            if (Utility.Random(1000) <= 2)
                AntiMacro.AntiMacroGump.SendGumpThreaded((PlayerMobile)from);

			int tileID;
			Map map;
			Point3D loc;

			if ( !GetHarvestDetails( from, tool, toHarvest, out tileID, out map, out loc ) )
			{
				OnBadHarvestTarget( from, tool, toHarvest );
				return;
			}
			else if ( !def.Validate( tileID ) )
			{
				OnBadHarvestTarget( from, tool, toHarvest );
				return;
			}

            if (!CheckRange(from, tool, def, map, loc, true))
                return;
            else if (!CheckResources(from, tool, def, map, loc, true))
                return;
            else if (!CheckHarvest(from, tool, def, toHarvest))
                return;

			if ( SpecialHarvest( from, tool, def, map, loc ) )
				return;

			HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

			if ( bank == null )
				return;

			HarvestVein vein = bank.Vein;

			if ( vein != null )
				vein = MutateVein( from, tool, def, bank, toHarvest, vein );

			if ( vein == null )
				return;

            //Check if we can mine the vein
            CheckMutateVein(from, def, bank, vein);

			HarvestResource primary = vein.PrimaryResource;
			HarvestResource fallback = vein.FallbackResource;
			HarvestResource resource = MutateResource( from, tool, def, map, loc, vein, primary, fallback );

			double skillBase = from.Skills[def.Skill].Base;
			double skillValue = from.Skills[def.Skill].Value;

			Type type = null;

            //Gain the skill
            from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill);

            //hacky All harvest now has 15 percent, if you can mine them.
			if ( skillBase >= resource.ReqSkill && 0.15 < Utility.RandomDouble())
			{
				type = GetResourceType( from, tool, def, map, loc, resource );

				if ( type != null )
					type = MutateType( type, from, tool, def, map, loc, resource );

				if ( type != null )
				{
					Item item = Construct( type, from );

					if ( item == null )
					{
						type = null;
					}
					else
					{
                        //bool spawnNew = false;
						//The whole harvest system is kludgy and I'm sure this is just adding to it.
						if ( item.Stackable )
						{
							int amount = GetOreAmount(vein);
							int racialAmount = (int)Math.Ceiling( amount * 1.1 );

							bool eligableForRacialBonus = ( def.RaceBonus && from.Race == Race.Human );

							if( eligableForRacialBonus && bank.Current >= racialAmount )
								item.Amount = racialAmount;
							else if( bank.Current >= amount )
								item.Amount = amount;
							else
								item.Amount = bank.Current;
//.........这里部分代码省略.........
开发者ID:FreeReign,项目名称:imaginenation,代码行数:101,代码来源:HarvestSystem.cs

示例6: FinishHarvesting

        public override void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool)) return;

            int tileID;
            Map map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true)) return;
            else if (!CheckResources(from, tool, def, map, loc, false)) return;
            else if (!CheckHarvest(from, tool, def, toHarvest)) return;

            if (SpecialHarvest(from, tool, def, map, loc)) return;

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);
            if (bank == null) return;

            HarvestVein vein = bank.Vein;
            if (vein == null) return;

            HarvestResource resource = null;
            TreeHarvestTool thtool = null;
            TreeResourceItem trsource = null;
            HarvestSuccessRating rating = HarvestSuccessRating.Failure;
            bool gave = false;
            TreeHarvestMethod method = TreeHarvestMethod.Picking;
            string toolType = "unknown";
            string resType = "resources";

            if (tool is TreeHarvestTool)
            {
                thtool = tool as TreeHarvestTool;
                switch (thtool.ResourceType)
                {
                    case TreeResourceType.BarkSkin: toolType = "carving"; method = TreeHarvestMethod.Carving; break;
                    case TreeResourceType.FruitNut: toolType = "picking"; method = TreeHarvestMethod.Picking; break;
                    case TreeResourceType.LeafSpine: toolType = "pinching"; method = TreeHarvestMethod.Picking; break;
                    case TreeResourceType.RootBranch: toolType = "digging"; method = TreeHarvestMethod.Digging; break;
                    case TreeResourceType.SapJuice: toolType = "sapping"; method = TreeHarvestMethod.Sapping; break;
                    case TreeResourceType.LogsBranches: toolType = "chopping"; method = TreeHarvestMethod.Chopping; break;
                }
                bool found = false;
                for (int x = 0; x < def.Resources.Length && !found; x++)
                {
                    if (method == TreeHarvestMethod.Chopping)
                    {
                        //give logs
                        Item logs = Activator.CreateInstance((Type) def.DoubleHarvestMessage) as Item;
                        if (logs is CustomTreeLog)
                        {
                            rating = from.CheckSkill(SkillName.Lumberjacking, ((CustomTreeLog)logs).MinSkill, 100.0)
                                ? Utility.RandomBool()
                                    ? HarvestSuccessRating.PartialSuccess
                                    : HarvestSuccessRating.Success
                                : HarvestSuccessRating.Failure;

                            if (rating >= HarvestSuccessRating.PartialSuccess)
                            {
                                logs.Amount = 10;

                                if (Give(from, logs, def.PlaceAtFeetIfFull))
                                {
                                    from.SendMessage("You receive some {0}.", logs.DefaultName);
                                    gave = true;
                                }
                                else
                                {
                                    from.SendMessage("Your pack is full. Some logs were lost.");
                                    logs.Delete();
                                    return;
                                }
                                bank.Consume(def.ConsumedPerHarvest, from);
                            }
                        }
                        found = true;
                        continue;
                    }

                    object[] obj = new object[] { def.Resources[x].SuccessMessage };
                    Item item = Activator.CreateInstance(def.Resources[x].Types[0], obj) as Item;
                    if (item is TreeResourceItem)
                    {
                        trsource = item as TreeResourceItem;
                        switch (trsource.ResourceType)
                        {
                            case TreeResourceType.BarkSkin: resType = "bark or skin"; break;
                            case TreeResourceType.FruitNut: resType = "fruits or nuts"; break;
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:RuneUO,代码行数:101,代码来源:TreeHarvest.cs


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