本文整理汇总了C#中EnemyHealth.EnemyIsDead方法的典型用法代码示例。如果您正苦于以下问题:C# EnemyHealth.EnemyIsDead方法的具体用法?C# EnemyHealth.EnemyIsDead怎么用?C# EnemyHealth.EnemyIsDead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnemyHealth
的用法示例。
在下文中一共展示了EnemyHealth.EnemyIsDead方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerStay2D
void OnTriggerStay2D (Collider2D other) {
float currHit = 0f;
int currScore = 0;
if (other.tag == "Lazer") {
currHit = lazerDamage;
currScore = lazerScore;
try {
eHealthScript = gameObject.GetComponentInChildren <EnemyHealth> ();
UIControl.Instance.AddScore (currScore);
if (eHealthScript.EnemyIsDead (currHit)) {
if (gameObject.name == "core"){
// boss died
UIControl.Instance.AddScore (5000);
// for now its game over
SceneManager.LoadScene("WinGame");
}
Instantiate (explosion, transform.position, transform.rotation);
Destroy (gameObject);
}
} catch {
print ("could not get " + gameObject.ToString () + " Script!");
print ("script: " + eHealthScript.ToString());
}
} else {
return;
}
}
示例2: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Boundary")
{
return;
}
if (other.tag == "Player")
{
//tick sheld health down and also destory a side missle launcher
GameObject[] rockets;
GameObject[] shield;
shield = GameObject.FindGameObjectsWithTag("boss01_shield");
if (leftside == true)
{
rockets = GameObject.FindGameObjectsWithTag("boss01_left_rocket");
}
else
{
rockets = GameObject.FindGameObjectsWithTag("boss01_right_rocket");
}
foreach (GameObject r in rockets)
{
try
{
print(r.transform.position);
Instantiate(explosion, r.transform.position, r.transform.rotation);
Destroy(r);
}
catch
{
print("could not get " + r.gameObject.ToString() + " Script!");
print("script: " + eHealthScript.ToString());
}
}
Destroy(gameObject);
foreach (GameObject s in shield)
{
try
{
eHealthScript = s.GetComponentInChildren<EnemyHealth>();
float currHit = -2600f;
if (eHealthScript.EnemyIsDead(currHit))
{
Instantiate(explosion, transform.position, transform.rotation);
Destroy(s);
My_GameController = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<GameController_Boss>();
My_GameController.shield_destoryed = true;
}
}
catch
{
print("could not get " + s.gameObject.ToString() + " Script!");
print("script: " + eHealthScript.ToString());
}
}
}
}
示例3: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
// added shootable tag to EnemyBullet_1 because I think another script takes care of it.
// feel free to correct me
if (other.tag == "Boundary" || other.tag == "Shootable" || other.tag == "enemy_bullet" || other.tag == "EnemyLaser") {
return;
}
if (other.tag == "Player") {
//check if boss wall and return
if (this.tag == "boss01_left_rocket" || this.tag == "boss01_shield" || this.tag == "boss01_right_rocket") {
return;
} else {
// player on ship collision
Instantiate (explosion, transform.position, transform.rotation);
suicideScore = (int) gameObject.GetComponentInChildren<Slider> ().value;
UIControl.Instance.AddScore (suicideScore);
if (UIControl.Instance.PlayerIsDead ((-1f * (float) suicideScore))) {
GameController.Instance.PlayerDied ();
Instantiate (explosion, transform.position, transform.rotation);
Destroy (other.gameObject);
}
Destroy (gameObject);
}
} else {
float currHit = 0f;
int currScore = 0;
if (other.tag == "Bullet") {
//print (gameObject.ToString () + " was hit with Bullet");
currHit = bulletDamage;
currScore = bulletScore;
} else if (other.tag == "Missle") {
//print (gameObject.ToString () + " was hit with Missle");
currHit = missleDamage;
currScore = missleScore;
} else if (other.tag == "Lazer") {
currHit = lazerDamage;
currScore = lazerScore;
destProj = false;
}
// could add more bullet types above in an "else if"
else {
print (other.gameObject.ToString() + "did not match one of the bulletType tags");
return;
}
if (destProj) {
Destroy (other.gameObject);
}
try {
eHealthScript = gameObject.GetComponentInChildren <EnemyHealth> ();
UIControl.Instance.AddScore (currScore);
if (eHealthScript.EnemyIsDead (currHit)) {
if (gameObject.name == "core"){
// boss died
UIControl.Instance.AddScore (5000);
// for now its game over
SceneManager.LoadScene("WinGame");
}
Instantiate (explosion, transform.position, transform.rotation);
Destroy (gameObject);
}
} catch {
print ("could not get " + gameObject.ToString () + " Script!");
}
}
}