本文整理匯總了C#中AttackResult.setKilled方法的典型用法代碼示例。如果您正苦於以下問題:C# AttackResult.setKilled方法的具體用法?C# AttackResult.setKilled怎麽用?C# AttackResult.setKilled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AttackResult
的用法示例。
在下文中一共展示了AttackResult.setKilled方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: takeAttackFrom
// Takes the attack from an enemy unit, returning the counter-attack and attack results.
// TODO: fix this weird attack problem
// on counters it attacks itself?
public List<AttackResult> takeAttackFrom(Unit enemy, int distance, bool firstAttack)
{
Attack atk = new Attack(enemy, this);
List<AttackResult> attacks = new List<AttackResult>();
AttackResult result = new AttackResult(HitType.Miss, 0, false, atk);
AttackResult counter = new AttackResult(HitType.CannotCounter, 0, false);
string statStr = "stats1 this " + ident() + ", clay: " + clay + ", endurance: " + currentWater;
statStr += "\nstats1 enemy " + enemy.ident() + ", clay: " + enemy.clay + ", endurance: " + currentWater;
statStr += "\nAttack info: " + atk;
Debug.Log(statStr);
Debug.Log("taking attack from: " + ident() + ", enemy doing this: " + enemy.ident());
string playType = (isEnemy()) ? "enemy" : "player";
if (Random.value <= atk.getHitChance())
{
result.setType(HitType.Hit);
result.setDamageTaken(atk.getDamage());
Debug.Log(playType + " was Hit!");
if (Random.value <= atk.getCritChance())
{
clay -= (3 * atk.getDamage());
result.setType(HitType.Crit);
result.setDamageTaken(3 * atk.getDamage());
Debug.Log("Crit!");
}
else
clay -= atk.getDamage();
}
else
Debug.Log(playType + " was Missed!");
if(clay <= 0)
result.setKilled(true);
// Only counter if it is the first attack in a set and the enemy's range allows it
else if(firstAttack && enemy.getMinAttackRange() <= distance && enemy.getMaxAttackRange() >= distance)
counter = enemy.takeAttackFrom(this, distance, false)[0];
// Add this enemy's result first, then the counter result
attacks.Add(result);
attacks.Add(counter);
statStr = "\nstats2 this " + ident() + ", clay: " + clay + ", endurance: " + currentWater;
statStr += "\nstats2 enemy " + enemy.ident() + ", clay: " + enemy.clay + ", endurance: " + currentWater;
Debug.Log(statStr);
return attacks;
}