當前位置: 首頁>>代碼示例>>C#>>正文


C# HarvestDefinition.GetBank方法代碼示例

本文整理匯總了C#中Server.Engines.Harvest.HarvestDefinition.GetBank方法的典型用法代碼示例。如果您正苦於以下問題:C# HarvestDefinition.GetBank方法的具體用法?C# HarvestDefinition.GetBank怎麽用?C# HarvestDefinition.GetBank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Server.Engines.Harvest.HarvestDefinition的用法示例。


在下文中一共展示了HarvestDefinition.GetBank方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CheckResources

		public virtual bool CheckResources( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
		{
			HarvestBank bank = def.GetBank( map, loc.X, loc.Y );
			bool available = ( bank != null && bank.Current >= def.ConsumedPerHarvest );

			if ( !available )
				def.SendMessageTo( from, timed ? def.DoubleHarvestMessage : def.NoResourcesMessage );

			return available;
		}
開發者ID:greeduomacro,項目名稱:annox,代碼行數:10,代碼來源:HarvestSystem.cs

示例2: 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

示例3: CheckResources

        public virtual bool CheckResources( Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, bool timed )
        {
            HarvestBank bank = def.GetBank( map, loc.X, loc.Y );
            bool available = ( bank != null && bank.Current >= def.ConsumedPerHarvest );

            if ( available && !(this is Fishing) )
            {
                Regions.GuardedRegion reg = Region.Find(loc, map).GetRegion(typeof(Regions.GuardedRegion)) as Regions.GuardedRegion;

                if (reg != null && !reg.Disabled)
                    available = false;
            }

            if ( !available )
                def.SendMessageTo( from, timed ? def.DoubleHarvestMessage : def.NoResourcesMessage );

            return available;
        }
開發者ID:greeduomacro,項目名稱:divinity,代碼行數:18,代碼來源:HarvestSystem.cs

示例4: 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

示例5: SpecialHarvest

        public override bool SpecialHarvest(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc)
        {
            if (!Core.HS)
                return base.SpecialHarvest(from, tool, def, map, loc);

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

            if (bank == null)
                return false;

            bool boat = Server.Multis.BaseBoat.FindBoatAt(from, from.Map) != null;
            bool dungeon = IsDungeonRegion(from);

            if (!boat && !dungeon)
                return false;

            if (boat || !NiterDeposit.HasBeenChecked(bank))
            {
                double bonus = (from.Skills[SkillName.Mining].Value / 9999) + ((double)from.Luck / 150000);

                if (boat)
                    bonus -= (bonus * .33);

                if (dungeon)
                    NiterDeposit.AddBank(bank);

                if (Utility.RandomDouble() < bonus)
                {
                    int size = Utility.RandomMinMax(1, 5);

                    if (from.Luck / 2500 > Utility.RandomDouble())
                        size++;

                    NiterDeposit niter = new NiterDeposit(size);

                    if (!dungeon)
                    {
                        niter.MoveToWorld(new Point3D(loc.X, loc.Y, from.Z + 3), from.Map);
                        from.SendLocalizedMessage(1149918, niter.Size.ToString()); //You have uncovered a ~1_SIZE~ deposit of niter! Mine it to obtain saltpeter.
                        NiterDeposit.AddBank(bank);
                        return true;
                    }
                    else
                    {
                        for (int i = 0; i < 50; i++)
                        {
                            int x = Utility.RandomMinMax(loc.X - 2, loc.X + 2);
                            int y = Utility.RandomMinMax(loc.Y - 2, loc.Y + 2);
                            int z = from.Z;

                            if (from.Map.CanSpawnMobile(x, y, z))
                            {
                                niter.MoveToWorld(new Point3D(x, y, z), from.Map);
                                from.SendLocalizedMessage(1149918, niter.Size.ToString()); //You have uncovered a ~1_SIZE~ deposit of niter! Mine it to obtain saltpeter.
                                return true;
                            }
                        }
                    }

                    niter.Delete();
                }
            }

            return false;
        }
開發者ID:Crome696,項目名稱:ServUO,代碼行數:65,代碼來源:Mining.cs

示例6: 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

示例7: CheckMapOnHarvest

        public static HarvestMap CheckMapOnHarvest(Mobile from, object harvested, HarvestDefinition def)
        {
            Map map = from.Map;

            if (harvested is IPoint3D && from.Backpack != null)
            {
                IPoint3D p = harvested as IPoint3D;

                Item[] items = from.Backpack.FindItemsByType(typeof(HarvestMap));

                foreach (Item item in items)
                {
                    HarvestMap harvestmap = item as HarvestMap;

                    if (harvestmap != null && harvestmap.TargetMap == map && harvestmap.UsesRemaining > 0 
                        && def.GetBank(map, p.X, p.Y) == def.GetBank(harvestmap.TargetMap, harvestmap.Target.X, harvestmap.Target.Y))
                    {
                        return harvestmap;
                    }
                }
            }

            return null;
        }
開發者ID:Crome696,項目名稱:ServUO,代碼行數:24,代碼來源:HarvestMap.cs

示例8: 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

示例9: RefreshResource

		public static void RefreshResource(HarvestDefinition definition, Map map, int x, int y)
		{
			HarvestBank bank = definition.GetBank(map, x, y);
			bank.NextRespawn = DateTime.MinValue;
		}
開發者ID:greeduomacro,項目名稱:UO-Forever,代碼行數:5,代碼來源:HarvestDefinition.cs

示例10: 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.GetBank方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。