本文整理汇总了C#中Projectile.giveDamage方法的典型用法代码示例。如果您正苦于以下问题:C# Projectile.giveDamage方法的具体用法?C# Projectile.giveDamage怎么用?C# Projectile.giveDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile.giveDamage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: hurt
public void hurt(Projectile p)
{
base.blinkRed();
health -= p.giveDamage();
if(health <= 0)
die(this.gameObject);
}
示例2: hurt
//////////////////////////////////////
// WRAHH TAKES DAMAGE //
//////////////////////////////////////
public void hurt(Projectile p)
{
base.blinkRed();
// The damage that Wrahh is about to take is kept in the damageTaken variable.
// The damage is first takes away his armor, and then start to take Wrahh's health
int damageTaken = p.giveDamage ();
int damageToHelm = 0;
int damageToSheild = 0;
// If any armor is left, it will be lost first.
while(damageTaken > 0 && (shieldArmor - damageToSheild > 0 || helmArmor - damageToHelm > 0))
{
int armorHit = Random.Range(0,10); // Randomly assings what part of Wrahh's armor takes a hit
if(armorHit >= 4 && shieldOn &&shieldArmor - damageToSheild > 0)
damageToSheild++;
else if(helmOn && armorHit < 4 && helmArmor - damageToHelm > 0)
damageToHelm++;
else if (shieldOn && shieldArmor - damageToSheild > 0)
damageToSheild++;
else if (helmOn && helmArmor - damageToHelm > 0)
damageToHelm++;
if(helmOn && helmArmor - damageToHelm <= 0)
{
helm.Protection = 0;
helm.upgradeProtection();
}
if(shieldOn && shieldArmor - damageToSheild <= 0)
{
shield.Protection = 0;
shield.upgradeProtection();
}
damageTaken--;
}
shieldArmor -= damageToSheild;
helmArmor -= damageToHelm;
// Any damage left after the armor has been hit, if any armor left, will take away his health.
// And if the health takes away the last of Wrahh's health, he will die, and the game will end.
health -= damageTaken;
if (health <= 0){
die(this.gameObject); // Calls die from GameCharacters class
}
}