本文整理汇总了C#中EnemyHealth.SetHitPoints方法的典型用法代码示例。如果您正苦于以下问题:C# EnemyHealth.SetHitPoints方法的具体用法?C# EnemyHealth.SetHitPoints怎么用?C# EnemyHealth.SetHitPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnemyHealth
的用法示例。
在下文中一共展示了EnemyHealth.SetHitPoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Shoot
void Shoot()
{
Debug.Log ("Weapon Fired");
Vector2 mousePosition = new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y);
RaycastHit2D hit = Physics2D.Raycast (firePointPosition, mousePosition-firePointPosition, 100, whatToHit); //Draw raycast from fire point on model (tip of gun) to mouse position with 100 length
//Debug.DrawLine (firePointPosition, (mousePosition-firePointPosition)*100, Color.cyan);
if (Time.time >= timeToSpawnEffect) {
StartCoroutine("Effect");
timeToSpawnEffect = Time.time + 1/effectSpawnRate;
}
if (hit.collider != null) {
//Debug.DrawLine (firePointPosition, hit.point, Color.red); Red to denote a successful hit
Debug.Log ("We hit " + hit.collider.name + " and did " + damage + " damage.");
enemyHealth = hit.collider.GetComponent<EnemyHealth>();
enemyHealth.SetHitPoints(damage);
}
}