Exemple #1
0
    void OnTriggerStay2D(Collider2D col)
    {
        // Debug.Log("contacting");
        if (Input.GetMouseButtonDown(0))
        {
            // Debug.Log("mouse click");
            if (col.gameObject.tag == "enermy")
            {
                // Debug.Log("hitting")
                col.gameObject.GetComponent <Rigidbody2D>().constraints =
                    RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezePositionY;
                col.isTrigger = true;
                Destroy(col.gameObject, 1f);
                //float timeLeft = 1f;
                //too many enemies are created!
                //col.GetComponent<enermy> ().spawn_update ();
                if (!col.gameObject.GetComponent <enermy> ().dead)
                {
                    col.gameObject.GetComponent <AudioSource> ().Play();
                    player.addScore();
                }
                col.GetComponent <enermy> ().dead = true;

                //InvokeRepeating("Spawn", spawnDelay, spawnTime);
                anim = col.gameObject.GetComponent <Animator> ();
                anim.SetTrigger("death");
                Debug.Log("the enermy is " + col.gameObject.GetComponent <enermy> ().dead);
            }
        }
    }
Exemple #2
0
 void OnTriggerStay2D(Collider2D col)
 {
     // Debug.Log("contacting");
     if (Input.GetMouseButtonDown(0))
     {
         // Debug.Log("mouse click");
         if (col.gameObject.tag == "enermy")
         {
             // Debug.Log("hitting")
             col.GetComponent <enermy>().spawn_update();;
             Destroy(col.gameObject);
             anim = col.gameObject.GetComponent <Animator>();
             anim.SetTrigger("death");
             player.addScore();
         }
     }
 }
Exemple #3
0
 void OnTriggerStay2D(Collider2D col)
 {
     // Debug.Log("contacting");
     if (Input.GetMouseButtonDown(0))
     {
         // Debug.Log("mouse click");
         if (col.gameObject.tag == "enermy")
         {
             // Debug.Log("hitting")
             myaudio.clip = deadman;
             myaudio.Play();
             //col.gameObject.SetActive(false);
             Destroy(col.gameObject);
             anim = col.gameObject.GetComponent <Animator>();
             anim.SetTrigger("death");
             anim.SetTrigger("die");
             player.addScore();
         }
     }
 }