本文整理汇总了C#中PlayerScript.getDamage方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerScript.getDamage方法的具体用法?C# PlayerScript.getDamage怎么用?C# PlayerScript.getDamage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerScript
的用法示例。
在下文中一共展示了PlayerScript.getDamage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: shock
void shock()
{
currentShocked = GameObject.FindGameObjectWithTag("Player");
script = currentShocked.GetComponent<PlayerScript>();
LayerMask mask = 1 << 8;
while(currentShocked != null){
Collider2D[] nearbyEnemies = Physics2D.OverlapCircleAll(currentShocked.transform.position,3f,mask.value);
float distance = Mathf.Infinity;
Collider2D closest = null;
foreach(Collider2D enemy in nearbyEnemies){
float testDistance = Vector3.Distance(currentShocked.transform.position,enemy.transform.position);
if(testDistance < distance){
if(!hit.Contains(enemy.gameObject)){
closest = enemy;
distance = testDistance;
}
}
}
if(closest != null){
GameObject newArc = (GameObject)Instantiate(lightningArc,currentShocked.transform.position,new Quaternion(0,0,0,0));
newArc.GetComponent<LineRenderer>().SetPosition(0,currentShocked.transform.position);
newArc.GetComponent<LineRenderer>().SetPosition(1,closest.transform.position);
hit.Add(closest.gameObject);
currentShocked = closest.gameObject;
}else{
currentShocked = null;
}
}
foreach(GameObject go in hit){
if(go.GetComponent<BaseEnemy>() != null){
go.GetComponent<BaseEnemy>().applyStun(3);
go.GetComponent<BaseEnemy>().hullDamage(script.getDamage());
}else if(go.GetComponent<AsteroidScript>() != null){
Destroy(go.gameObject);
}
}
hit.Clear();
}