本文整理汇总了C#中Entity.HitLanded方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.HitLanded方法的具体用法?C# Entity.HitLanded怎么用?C# Entity.HitLanded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity.HitLanded方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnShot
public void OnShot(Entity e)
{
if (IsDying()) return;
int damage = (e.WieldsWeapon) ? e.WeaponDamage : e.MeleeDamage;
Vector2 direction = e.Orientation;
bool died = m_lifeData.UpdateHP(-damage);
Debug.LogFormat("Entity {0} hit! Current Hp: {1}", name, m_lifeData.HP);
transform.Translate(direction * e.WeaponRecoil * 1.6f);
if (died)
{
e.HitLanded();
m_audioSource.PlayOneShot(m_deathSound);
StartCoroutine(DieInSeconds(1.0f));
}
else
{
m_audioSource.PlayOneShot(m_hitSound);
if (HitReaction(e))
{
m_hitTime = Time.time;
}
}
}
示例2: HitReaction
protected override bool HitReaction(Entity attacker)
{
m_state = NPCState.Hit;
attacker.HitLanded();
Color c = m_renderer.color;
c.a = 0.5f;
m_renderer.color = c;
return true;
}
示例3: OnBumped
public void OnBumped(Entity e)
{
if (IsEthereal()) return;
if (!e.CanBumpEntity(this))
{
return;
}
bool dead = m_lifeData.UpdateHP(-1);
Debug.LogFormat("Entity {0} hit! Current Hp: {1}", name, m_lifeData.HP);
if (dead)
{
e.HitLanded();
StartCoroutine(DieInSeconds(1.0f));
}
else
{
HitReaction(e);
m_hitTime = Time.time;
}
}
示例4: HitReaction
protected override bool HitReaction(Entity attacker)
{
if (m_state == PlayerState.Hit)
{
Debug.LogFormat("Already hit!!");
return false;
}
else
{
m_state = PlayerState.Hit;
attacker.HitLanded();
m_oldState = m_state;
Color c = m_renderer.color;
c.a = 0.5f;
m_renderer.color = c;
return true;
}
}