本文整理汇总了C#中Creature.UpdateGameTurn方法的典型用法代码示例。如果您正苦于以下问题:C# Creature.UpdateGameTurn方法的具体用法?C# Creature.UpdateGameTurn怎么用?C# Creature.UpdateGameTurn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature.UpdateGameTurn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefendAnimation
protected IEnumerator DefendAnimation(Creature attacker, float delay = 0, float advanceDiv = 8)
{
yield return new WaitForSeconds(delay);
// wait for impact
float duration = speed * 0.5f;
yield return new WaitForSeconds(duration);
// get combat positions
Vector3 startPos = new Vector3(this.x, this.y, 0);
Vector3 vec = (new Vector3(attacker.x, attacker.y, 0) - startPos).normalized / advanceDiv;
Vector3 endPos = startPos - vec;
// resolve combat outcome and apply combat sounds and effects
bool isDead = ResolveCombatOutcome(attacker);
if (isDead) {
Die(attacker);
yield break;
}
// move towards attacker
float t = 0;
while (t <= 1) {
t += Time.deltaTime / duration * 0.5f;
transform.localPosition = Vector3.Lerp(startPos, endPos, Mathf.SmoothStep(0f, 1f, t));
yield return null;
}
// move back to position
t = 0;
while (t <= 1) {
t += Time.deltaTime / (duration * 0.5f);
transform.localPosition = Vector3.Lerp(endPos, startPos, Mathf.SmoothStep(0f, 1f, t));
yield return null;
}
state = CreatureStates.Idle;
// emmit event once the defender has finished this action
attacker.UpdateGameTurn();
}