本文整理汇总了C#中Critter.GetLocalPopulation方法的典型用法代码示例。如果您正苦于以下问题:C# Critter.GetLocalPopulation方法的具体用法?C# Critter.GetLocalPopulation怎么用?C# Critter.GetLocalPopulation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Critter
的用法示例。
在下文中一共展示了Critter.GetLocalPopulation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateLine
public void GenerateLine(Critter target, Hex habitat)
{
SetCritter(target);
pop = target.GetLocalPopulation(habitat);
critterIcon.sprite = critterSprite;
critterIcon.color = iconColor;
popText.text = pop + "";
SetDietIcons(critter);
PrintDietIcons();
SetLocoIcons(critter);
PrintLocoIcons();
}
示例2: Hunt
//Determines if a creature successfully kills its target, then takes care of casualties and enegery gain.
void Hunt(Critter target, Hex habitat)
{
float casualties = 0;
float bite = biteSize;
float targetPop = target.GetLocalPopulation(habitat);
float targetFoodValue = target.GetBaseFoodValue();
float huntScore = ChaseScore(target) * FightScore(target) / 100;
//print ("-----Target = Creature#" + target.number + "------------------------------------------------------------------------------------------Hunt Success Probability = " + huntScore + ".\r\n");
//print ("This creature (#" + number + ") Hunts Creature #" + target.number + ".\r\n");
if(target == this){
AquireTarget(habitat);
}
else if (Random.Range (1, 101) <= huntScore * AptitudeCheck(target)) {
float popRatio;
if(bite > energy_Needed){
bite = energy_Needed;
}
if(bite < 0){
bite = 0;
}
casualties = (float)((bite / targetFoodValue * target.GetSize()));
casualties = KillCount(target, casualties);
if(casualties >= targetPop){
casualties = targetPop / 2;
}
popRatio = targetPop / (float)(1.25f * GetLocalPopulation(habitat));
if(popRatio > 1.25f){
popRatio = 1.25f;
}
casualties = (casualties * popRatio);
foodTaken += casualties * (targetFoodValue * size);
//print (name + " + Target: " + target.name + " PopRatio " + popRatio + "\r\n");
if(energy_Needed <= foodTaken){
foodTaken = energy_Needed;
}
targetPop -= casualties;
target.SetLocalAdultPopulation(targetPop, habitat);
target.AddCrittersEaten(casualties);
target.AddToHuntDeathsList(habitat, turn, casualties);
habitat.AddExcessMeatFood(foodTaken * .5f);
target.MortalityCheck(habitat);
target.UpdateStats();
//if(isPlayer){
//print ("Total Kills = " + casualties + ". Food aquired = " + foodTaken + " vs. Energy Needed = " + energy_Needed +"\r\n");
//}
} //else {print ("Hunt Failed.\r\n");}
}