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


C# HarvestDefinition.GetBonusResource方法代碼示例

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


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

示例1: FinishHarvesting


//.........這裏部分代碼省略.........
			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;
								
							//if ( bank.Current <= item.Amount)
								//spawnNew = true;
								
						}

                        bank.Consume(def, item.Amount, from);

                        //Maka
                        //if (spawnNew)
                        //    bank.Vein = def.GetVeinAt(from.Map, from.Location.X, from.Location.Y);

						if ( Give( from, item, /*def.PlaceAtFeetIfFull*/true ) ) //Is there something we dont want to place at the feet
						{
							SendSuccessTo( from, item, resource );
						}
						else
						{
							SendPackFullTo( from, item, def, resource );
							item.Delete();
						}

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = Construct(bonus.Type, from);

                            if (Give(from, bonusItem, true))	//Bonuses always allow placing at feet, even if pack is full irregrdless of def
                            {
                                bonus.SendSuccessTo(from);
                            }
                            else
                            {
                                item.Delete();
                            }
                        }

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

							toolWithUses.ShowUsesRemaining = true;

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

							if ( toolWithUses.UsesRemaining < 1 )
							{
								tool.Delete();
								def.SendMessageTo( from, def.ToolBrokeMessage );
							}
						}
					}
				}
			}

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

			OnHarvestFinished( from, tool, def, vein, bank, resource, toHarvest );
		}
開發者ID:FreeReign,項目名稱:imaginenation,代碼行數:101,代碼來源:HarvestSystem.cs

示例2: FinishHarvesting


//.........這裏部分代碼省略.........

			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
						{
							SendPackFullTo( from, item, def, resource );
							item.Delete();
						}

						BonusHarvestResource bonus = def.GetBonusResource();

						if ( bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill )
						{
							Item bonusItem = Construct( bonus.Type, from );

							if ( Give( from, bonusItem, true ) )	//Bonuses always allow placing at feet, even if pack is full irregrdless of def
							{
								bonus.SendSuccessTo( from );
							}
							else
							{
                                //28JUL2008 Typo in RC2 - SVN 295: in HarvestSystem.cs *** START ***
                                //item.Delete();
                                bonusItem.Delete();
                                //28JUL2008 Typo in RC2 - SVN 295: in HarvestSystem.cs *** END   ***
							}
						}

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

							toolWithUses.ShowUsesRemaining = true;

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

							if ( toolWithUses.UsesRemaining < 1 )
							{
								tool.Delete();
								def.SendMessageTo( from, def.ToolBrokeMessage );
							}
						}
					}
				}
			}

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

			OnHarvestFinished( from, tool, def, vein, bank, resource, toHarvest );
		}
開發者ID:greeduomacro,項目名稱:annox,代碼行數:101,代碼來源:HarvestSystem.cs

示例3: FinishHarvesting


//.........這裏部分代碼省略.........
                        from.SendMessage("Why don't you have a pack?");
                        trsource.Delete();
                        return;
                    }
                    Item tap = pack.FindItemByType(typeof(BarrelTap));

                    if (trsource.ResourceType == TreeResourceType.SapJuice && tap == null)
                    {
                        from.SendMessage("You need a barrel tap to sap this tree.");
                        trsource.Delete();
                        return;
                    }
                    if (trsource.ResourceType == TreeResourceType.SapJuice)
                        trsource.Amount = 1;

                    bank.Consume(trsource.Amount, from);

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

                        toolWithUses.ShowUsesRemaining = true;

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

                        if (toolWithUses.UsesRemaining < 1)
                        {
                            tool.Delete();
                            def.SendMessageTo(from, def.ToolBrokeMessage);
                        }
                    }

                    if (trsource.ResourceType != TreeResourceType.SapJuice || pack.ConsumeTotal(typeof(EmptyJar), 1))
                    {
                        if (trsource.ResourceType == TreeResourceType.SapJuice && 0.12 >= Utility.RandomDouble())
                        {
                            from.SendMessage("Your tap broke in the process, and is now gone.");
                            tap.Delete();
                        }

                        if (Give(from, trsource, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, trsource, resource);
                            gave = true;
                        }
                        else
                        {
                            SendPackFullTo(from, trsource, def, resource);
                            trsource.Delete();
                            return;
                        }
                    }
                    else
                    {
                        from.SendMessage("You don't have an empty jar to hold the sap, so it was lost!");
                        trsource.Delete();
                        return;
                    }
                }
                else
                    trsource.Delete();
            }

            BonusHarvestResource bonus = def.GetBonusResource();

            if (bonus != null && bonus.Type != null && rating >= HarvestSuccessRating.Success)
            {
                Item bonusItem;
                if (bonus.Type == typeof(TreeResource))
                {
                    object[] obj = new object[] { (TreeResource)bonus.SuccessMessage.Number };
                    bonusItem = Activator.CreateInstance(bonus.Type, obj) as Item;
                }
                else
                {
                    bonusItem = Activator.CreateInstance(bonus.Type) as Item;
                }

                if (Give(from, bonusItem, true))
                {
                    from.SendMessage("You find a bonus resource.");
                    gave = true;
                }
                else
                {
                    if (bonusItem != null)
                        bonusItem.Delete();
                }
            }

            if (gave)
            {
                //do nothing
            }
            else if (trsource == null || trsource.Deleted)
                def.SendMessageTo(from, def.FailMessage);

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
開發者ID:greeduomacro,項目名稱:RuneUO,代碼行數:101,代碼來源:TreeHarvest.cs


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