本文整理汇总了C#中Pawn.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Pawn.GetType方法的具体用法?C# Pawn.GetType怎么用?C# Pawn.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pawn
的用法示例。
在下文中一共展示了Pawn.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGiveTerminalJob
protected override Job TryGiveTerminalJob(Pawn pawn)
{
if (pawn.GetType() != typeof(Crematorius))
{
return null;
}
Crematorius droid = (Crematorius)pawn;
if (droid.Active)
{
List<CrematoriusTarget> list = droid.GetTargets.OrderBy((CrematoriusTarget t) => t.Priority).ThenBy((CrematoriusTarget t)=>t.NaturalPriority).ThenBy((CrematoriusTarget t) => t.Label).ToList();
for (int i = 0; i < list.Count; i++)
{
CrematoriusTarget target = list[i];
if (target.Mode != CrematoriusOperationMode.Off)
{
Corpse corpse = target.GetCorpse();
if (corpse != null)
{
JobDef jDef = (target.Mode == CrematoriusOperationMode.Butcher) ? DefDatabase<JobDef>.GetNamed("MD2DroidButcherCorpse") : DefDatabase<JobDef>.GetNamed("MD2DroidCremateCorpse");
return new Job(jDef, corpse);
}
}
}
}
return null;
}
示例2: Attack
/**
* This will calculate the damage dealt to a certain pawn
* Weapon type and armor type will have a damage modifer.
* Initial damage is randomized base on attack and a weapon type modifier
* Piercing = 0.2
* Light = 0.3
* Heavy = 0.5
* Energy = 0.4
* Modifer goes both ways -> could both amplify and mitigate attack.
* For Weapon that counters enemy's Armor, damage * 1.3
* For Weapon that are countered by enemy's Armor, damage * 07
*/
public void Attack(Pawn other)
{
// Check if the target is in range
if (CheckReach(other)) {
if (other.GetType () == typeof(Creature)) {
Creature otherCreature = other as Creature;
float dmg = 0f;
if (Weapon == WeaponType.Piercing) {
dmg = Atk * (Random.value + 0.2f);
if (otherCreature.Armor == ArmorType.Wooden)
dmg *= 1.3f;
else if (otherCreature.Armor == ArmorType.Plate)
dmg *= 0.7f;
}
if (Weapon == WeaponType.Light) {
dmg = Atk * (Random.value + 0.3f);
if (otherCreature.Armor == ArmorType.Leather)
dmg *= 1.3f;
else if (otherCreature.Armor == ArmorType.Mail)
dmg *= 0.7f;
}
if (Weapon == WeaponType.Heavy) {
dmg = Atk * (Random.value + 0.2f);
if (otherCreature.Armor == ArmorType.Plate)
dmg *= 1.3f;
else if (otherCreature.Armor == ArmorType.Leather)
dmg *= 0.7f;
}
if (Weapon == WeaponType.Energy) {
dmg = Atk * (Random.value + 0.2f);
if (otherCreature.Armor == ArmorType.Mail)
dmg *= 1.3f;
else if (otherCreature.Armor == ArmorType.Wooden)
dmg *= 0.7f;
}
otherCreature.TakDmg (dmg);
} else if (other.GetType () == typeof(Structure)) {
// Haven't decided for structures yet.
Structure otherStruct = other as Structure;
float dmg = 0f;
if (Weapon == WeaponType.Piercing) {
dmg = Atk * (Random.value + 0.2f);
}
if (Weapon == WeaponType.Light) {
dmg = Atk * (Random.value + 0.3f);
}
if (Weapon == WeaponType.Heavy) {
dmg = Atk * (Random.value + 0.2f);
}
if (Weapon == WeaponType.Energy) {
dmg = Atk * (Random.value + 0.2f);
}
otherStruct.TakDmg (dmg);
} else {
Debug.Log ("Can't attack this Object.");
}
} else
Debug.Log ("Invalid target.");
}