本文整理汇总了C#中SimDescription.ModifyFunds方法的典型用法代码示例。如果您正苦于以下问题:C# SimDescription.ModifyFunds方法的具体用法?C# SimDescription.ModifyFunds怎么用?C# SimDescription.ModifyFunds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimDescription
的用法示例。
在下文中一共展示了SimDescription.ModifyFunds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
protected override bool Run(SimDescription a, SimDescription b)
{
if (a.Household == null) return true;
if (b.Household == null) return true;
if (!ApplyAll)
{
string text = StringInputDialog.Show(Name, Common.Localize("MoneyTransfer:Prompt", a.IsFemale, new object[] { a, b }), a.FamilyFunds.ToString(), 256, StringInputDialog.Validation.None);
if (string.IsNullOrEmpty(text)) return false;
mFunds = 0;
if (!int.TryParse(text, out mFunds))
{
SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
return false;
}
}
if (mFunds > 0)
{
if (mFunds > a.FamilyFunds)
{
Common.Notify(Common.Localize("MoneyTransfer:TooMuch", a.IsFemale, new object[] { a.Household.Name, a.FamilyFunds }));
return false;
}
}
else
{
if (-mFunds > b.FamilyFunds)
{
Common.Notify(Common.Localize("MoneyTransfer:TooLittle", b.IsFemale, new object[] { b.Household.Name, b.FamilyFunds }));
return false;
}
}
a.ModifyFunds (-mFunds);
b.ModifyFunds (mFunds);
return true;
}
示例2: DisplayDialog
public static void DisplayDialog(SimDescription actor, Household target, bool allowHorse)
{
List<SimDescription> pets = new List<SimDescription>();
foreach (SimDescription pet in Households.Pets(actor.Household))
{
if (target != null)
{
int price = GetPrice(pet);
if (price == 0) continue;
if (target.FamilyFunds < price) continue;
}
pets.Add(pet);
}
while (true)
{
string title = Common.Localize("PetSelection:Title");
int maxPrice = int.MaxValue;
if (target != null)
{
title = target.Name + Common.NewLine + Common.Localize("SellPet:Funds", false, new object[] { target.FamilyFunds });
maxPrice = target.FamilyFunds;
}
PetSelection.Results results = new PetSelection(actor, title, maxPrice, pets).SelectMultiple((target != null) ? 1 : 0);
if ((results == null) || (results.Count == 0)) return;
if (actor.CreatedSim != null)
{
PlumbBob.SelectActor(actor.CreatedSim);
}
foreach (SimDescription sim in results)
{
if ((target == null) && (sim.IsHorse) && (!allowHorse))
{
Common.Notify(sim.CreatedSim, Common.Localize("SellPet:WrongSpecies", sim.IsFemale, new object[] { sim }));
}
else if (Relationships.GetParents(sim).Count < 0)
{
Common.Notify(sim.CreatedSim, Common.Localize("SellPet:NoPedigree", sim.IsFemale, new object[] { sim }));
}
else
{
int price = GetPrice(sim);
if (price > maxPrice)
{
price = maxPrice;
}
if (price == 0)
{
Common.Notify(sim.CreatedSim, Common.Localize("SellPet:NoPrice", sim.IsFemale, new object[] { sim }));
}
else
{
actor.ModifyFunds(price);
Common.Notify(sim.CreatedSim, Common.Localize("SellPet:Success", sim.IsFemale, new object[] { sim, price }));
actor.Household.Remove(sim);
pets.Remove(sim);
Household choice = target;
if (choice == null)
{
List<Household> choices = new List<Household>();
foreach (Household house in Household.GetHouseholdsLivingInWorld())
{
if (house == actor.Household) continue;
if (!house.CanAddSpeciesToHousehold(sim.Species)) continue;
if (house.FamilyFunds < price) continue;
choices.Add(house);
}
if (choices.Count > 0)
{
choice = RandomUtil.GetRandomObjectFromList(choices);
}
}
if (choice != null)
{
choice.ModifyFamilyFunds(-price);
choice.Add(sim);
sim.LastName = SimTypes.HeadOfFamily(choice).LastName;
Instantiation.AttemptToPutInSafeLocation(sim.CreatedSim, false);
//.........这里部分代码省略.........