本文整理汇总了C#中Enemy.loseHP方法的典型用法代码示例。如果您正苦于以下问题:C# Enemy.loseHP方法的具体用法?C# Enemy.loseHP怎么用?C# Enemy.loseHP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy.loseHP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: attack
/*********************** Attack *****************************/
public string attack(Enemy e)
{
//string name = e.typeID;
/* if (soundComponent.characterAudio.isPlaying && soundComponent.characterClip < Sounds.SWORD_HIT) {
soundComponent.stopSound("character");
}*/
animatorComponent.SetBool("Attacking", true);
string message = "Miss! ";
if(stamina > 0){
if(GameObject.Find("Health").GetComponent<Image>().isActiveAndEnabled == false){
this.GetComponent<Tutorial>().showHealthHint();
}
e.lastDamage = Time.time;
float ran = UnityEngine.Random.value;
float hc = hitChance;
if (ran <= hc) {
message = "Hit! ";
float cc = critChance;
int tmpdamage = damage;
/*Critical Hit */
if (ran <= cc) {
tmpdamage *= CRIT_MULT;
message = "Critical Hit! ";
if (weapon != null){
if (weapon.typeID == "Warhammer") {
soundComponent.playCharacterSound (Sounds.HAMMER_CRIT);
} else {
soundComponent.playCharacterSound (Sounds.SWORD_CRIT);
}
} else {
soundComponent.playCharacterSound (Sounds.FISTS_CRIT);
}
} else {
/* Non-crit Sounds */
if (weapon != null){
if (weapon.typeID == "Warhammer") {
soundComponent.playCharacterSound (Sounds.HAMMER_HIT);
} else {
soundComponent.playCharacterSound (Sounds.SWORD_HIT);
}
} else {
soundComponent.playCharacterSound (Sounds.FISTS_HIT);
}
}
bool dead = e.loseHP(tmpdamage);
if (weapon != null) {
stamina -= weapon.staminaLoss;
GameObject.Find("Stamina").GetComponent<Image>().fillAmount = stamina/maxStamina();
} else {
stamina -= STAMINA_LOSS;
GameObject.Find("Stamina").GetComponent<Image>().fillAmount = stamina/maxStamina();
}
if (dead) {
message += " Monster died!\n";
message += addXP(e.level * XP_GAIN_PER_MONSTER_LEVEL) + "\n";
} else {
//add Stats to message
message += e.getHealth()+"/"+e.getMaxHp();
}
} else if (message == "Miss! ") {
soundComponent.playCharacterSound(Sounds.MISS);
message += e.getHealth () + "/" + e.getMaxHp ();
}
} else {
soundComponent.playCharacterSound(Sounds.MISS);
}
return message;
}