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


C# CraftResource.ToString方法代码示例

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


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

示例1: SellResource

        public static bool SellResource(TradeAdvisor trader, PlayerMobile buyer, CraftResource r, int amount)
        {
            if(trader.Government == null || trader.Government.Deleted)
                return false;

            if (trader.Government.TradeInformation == null)
                return false;

            if (!CanDoBusiness(trader.Government, buyer))
            {
                trader.Say("I cannot do business with you.");
                return false;
            }

            #region Amount Checking
            if (trader.Government.Resources[GetType(r)] < 1)
            {
                trader.Say("I have no " + GetType(r).ToString() + " in stock.");
                return false;
            }
            else if (amount / GetDivisor(r) > trader.Government.Resources[GetType(r)])
            {
                trader.Say("I only have " + trader.Government.Resources[GetType(r)] + " units of " + GetType(r).ToString() + " in stock.");
                return false;
            }
            else if (amount < GetDivisor(r))
            {
                trader.Say("You must purchase at least " + GetDivisor(r).ToString() + " " + GetString(r) + ".");
                return false;
            }
            else if (r != CraftResource.Gold && amount % GetDivisor(r) > 0)
            {
                trader.Say(r.ToString() + " is handled in units of " + GetDivisor(r).ToString() + ".");
                return false;
            }
            #endregion

            if (CustomGuildStone.IsGuildEconomic(buyer, trader.Government))
            {
                Item res = (Item)Activator.CreateInstance(GetResourceObject(r), amount);
                buyer.AddToBackpack(res);
                trader.Say("Of course you may freely access " + trader.Government.Name + "'s resources.");
                trader.Government.Resources[GetType(r)] -= (int)(amount / GetDivisor(r));
                return true;
            }
            else
            {
                if (trader.Government.Resources[GetType(r)] - (amount / GetDivisor(r)) < GetMinimum(r, trader.Government))
                {
                    trader.Say("I have been ordered not to go below " + GetMinimum(r, trader.Government).ToString() + " units of " + GetType(r).ToString() + " in my stock.");
                    return false;

                }
                else if (buyer.Backpack.GetAmount(typeof(Copper)) < ((amount / GetDivisor(r)) * GetSellPrice(r, trader.Government)))
                {
                    trader.Say("You don't have enough coin to buy " + (amount / GetDivisor(r)) + " units of " + GetType(r).ToString() + ".");
                    return false;
                }
                else if (buyer.Backpack.ConsumeTotal(typeof(Copper), ((int)(amount / GetDivisor(r)) * GetSellPrice(r, trader.Government))))
                {
                    #region Successful Sale of Resources to a Player
                    switch (Utility.Random(3))
                    {
                        case 0: buyer.PlaySound(0x2E5); break;
                        case 1: buyer.PlaySound(0x2E6); break;
                        case 2: buyer.PlaySound(0x2E7); break;
                    }

                    Item res = (Item)Activator.CreateInstance(GetResourceObject(r), amount);
                    buyer.AddToBackpack(res);
                    trader.Government.Resources[GetType(r)] -= (int)(amount / GetDivisor(r));
                    return true;
                    #endregion
                }
                else
                {
                    trader.Say("You do not have enough copper coins.");
                    return false;
                }
            }
        }
开发者ID:justdanofficial,项目名称:khaeros,代码行数:81,代码来源:GovernmentEntity.cs


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