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;
		}
	}
Exemplo n.º 2
0
    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());
                }
            }



            

        }


    }