Esempio n. 1
0
    /*
     * private void Animation(){
     *      if(ai.lifeState == Ai.LIFE_STATE.IsAlive){
     *              if(ai.moveState != Ai.MOVEMENT_STATE.IsIdle){
     *                      anim.SetBool(animPatrol, true);
     *              } else {
     *                      anim.SetBool(animPatrol, false);
     *              }
     *
     *      } else if(ai.lifeState == Ai.LIFE_STATE.IsDead){
     *              anim.SetBool(animDeath, true);
     *      }
     * }
     */
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "hitbox")
        {
            AudioSource.PlayClipAtPoint(death, transform.position);
            anim.Play("deathGuard");

            hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
            hud.IncreaseScore(2000);
            Destroy(GetComponent <Rigidbody>());
            Destroy(GetComponent <Collider>());
            Destroy(GetComponent <Ai>());
            //enemy.collider.enabled = false;
            //yield return new WaitForSeconds(2f);
            Destroy(gameObject, 3f);
        }

        if (other.gameObject.tag == "Destructible")
        {
            AudioSource.PlayClipAtPoint(death, transform.position);
            anim.Play("deathGuard");

            hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
            hud.IncreaseScore(2000);
            Destroy(GetComponent <Rigidbody>());
            Destroy(GetComponent <Collider>());
            Destroy(GetComponent <Ai>());
            //enemy.collider.enabled = false;
            //yield return new WaitForSeconds(2f);
            Destroy(gameObject, 2f);
        }
    }
Esempio n. 2
0
    void Update()
    {
        RaycastHit2D hit = Physics2D.Raycast(transform.position, new Vector2(1, 0));

        //Debug.Log("hit - " + (hit ? hit.distance.ToString() : "nohit"));
        if (hit && hit.distance < 0.55f)
        {
            hud.IncreaseScore(50);
            if (hit.collider.tag == "Enemy")
            {
                //Debug.Log("HIT");
                var sound = hit.collider.gameObject.GetComponent <AudioSource>();
                sound.Play();
                //rend.enabled = false;
                //hit.collider.isTrigger = true;
                //hit.collider.GetComponent<BoxCollider2D>().isTrigger = true;
                //hit.collider.gameObject.GetComponent<BoxCollider2D>().isTrigger = true;

                //hit.collider.enabled = false;
                hit.collider.GetComponent <BoxCollider2D>().enabled = false;
                //hit.collider.gameObject.GetComponent<BoxCollider2D>().enabled = false;

                hit.collider.gameObject.GetComponent <Animator>().SetTrigger("Death");
                //Destroy(hit.collider.gameObject.GetComponent<BoxCollider2D>());
                //Destroy(hit.collider.gameObject.GetComponent<Rigidbody2D>());
                Destroy(hit.collider.gameObject, 0.75f); //, sound.clip.length);
                Destroy(this.gameObject);
            }
        }
    }
Esempio n. 3
0
	void OnTriggerEnter2D (Collider2D other) {
		if (other.tag == "Player") {
			hud = GameObject.Find("Score Text").GetComponent<HUDScript>();
			hud.IncreaseScore (-2);
			Destroy (this.gameObject);
		}
	}
	void OnTriggerEnter2D(Collider2D other)
	{
		if (other.tag == "Player")
		{
			hud.IncreaseScore(10);
			Destroy(this.gameObject);
		}
	}
Esempio n. 5
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
         hud.IncreaseScore(10);
         Destroy(this.gameObject);
     }
 }
	void OnTriggerEnter2D(Collider2D other) {
		if (other.tag == "Player") {
			SoundManagerScript.instance.RandomisePowerUpSfx(0.6f, coinSound);
			// inefficient, pull it once, put on spawn object, pass it onto children
			hud = GameObject.Find("Main Camera").GetComponent<HUDScript>();
			hud.IncreaseScore (10);
			Destroy (this.gameObject);
		}
	}
Esempio n. 7
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
         hud.IncreaseScore(5000);
         Application.LoadLevel(4);
         return;
     }
 }
Esempio n. 8
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
         gameObject.renderer.enabled = false;
         hud.IncreaseScore(500);
         Destroy(this.gameObject, 2);
     }
 }
Esempio n. 9
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player") {
            hud = GameObject.Find ("Main Camera").GetComponent<HUDScript>(); //fix inefficiant
            //better to pull it one time and have it on the spawn object and have it on the children
            //
            hud.IncreaseScore (10);
            Destroy (this.gameObject);

        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            hud = GameObject.Find("_ScoreHandler").GetComponent <HUDScript> ();
            hud.IncreaseScore(1000);

            {
            }
        }
    }
Esempio n. 11
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Playa")
     {
         hud.IncreaseScore(10);
         //Debug.Log("play audio on powerup");
         audioSource.Play();
         rend.enabled = false;
         Destroy(this.gameObject, audioSource.clip.length);
     }
 }
Esempio n. 12
0
    void OnTriggerEnter(Collider other)
    {
        PlayerPhysics physics = other.gameObject.GetComponent <PlayerPhysics>();

        if (physics)
        {
            hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
            hud.IncreaseScore(5000);
            Application.LoadLevel(2);
            return;
        }
    }
Esempio n. 13
0
    void OnTriggerEnter(Collider other)
    {
        //Debug.Log("other.tag: " + other.tag);

        if (other.tag == "Player")
        {
            hud = GameObject.Find("Main Camera").GetComponent<HUDScript>();
            hud.IncreaseScore(50000);
            //Debug.Log("playerScore: " + hud.playerScore);
            Destroy(this.gameObject);
        }
    }
Esempio n. 14
0
    //Collider2D power;

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            hud = GameObject.Find("Main Camera").GetComponent <HUDScript> ();

            if (this.tag == "PowerUpRed")
            {
                hud.IncreaseScore(1, "red");
            }
            else if (this.tag == "PowerUpBlue")
            {
                hud.IncreaseScore(1, "blue");
            }
            else if (this.tag == "PowerUpGreen")
            {
                hud.IncreaseScore(1, "green");
            }
            Destroy(this.gameObject);
        }
    }
Esempio n. 15
0
    void OnTriggerEnter(Collider other)
    {
        //Debug.Log("other.tag: " + other.tag);

        if (other.tag == "Player")
        {
            hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
            hud.IncreaseScore(50000);
            //Debug.Log("playerScore: " + hud.playerScore);
            Destroy(this.gameObject);
        }
    }
Esempio n. 16
0
    void PlayerRaycast()
    {
        //FOR OUR OWN DEATH
        RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.right);

        if (hit && hit.distance < 0.55f)
        {
            if (hit.collider.tag == "Enemy")
            {
                //Debug.Log("we are dead");
                //this.gameObject.GetComponent<Animator>().SetTrigger("Hurt");
                var thisRB = this.gameObject.GetComponent <Rigidbody2D>();
                thisRB.AddForce(Vector2.up * 10);
                thisRB.gravityScale   = 0;
                thisRB.freezeRotation = false;
                this.gameObject.GetComponent <BoxCollider2D>().enabled = false;
                this.gameObject.GetComponent <Animator>().SetTrigger("Hurt");
                //Destroy(this.gameObject, .75f); //, sound.clip.length);

                StartCoroutine(LoadLevelAfterDelay(2f, "GameOverScene"));

                //LoadLevelAfterDelay(2f, "GameOverScene");
            }
        }

        //for clobbering enemies from above
        RaycastHit2D rayDown = Physics2D.Raycast(transform.position, Vector2.down);

        //Debug.Log(rayDown.collider.tag + " " + rayDown.distance);
        if (rayDown && rayDown.distance < 1f)
        {
            //Debug.Log("wtf got it???");
            //how do we do this properly????
            if (rayDown.collider.tag == "Enemy")
            {
                //Debug.Log("touched Enemy");
                //make bounce up!
                GetComponent <Rigidbody2D>().AddForce(Vector2.up * 1000);
                //kill enemy with animation
                var enemyRB = rayDown.collider.gameObject.GetComponent <Rigidbody2D>();
                enemyRB.AddForce(Vector2.right * 200);
                enemyRB.gravityScale   = 20;
                enemyRB.freezeRotation = false;
                rayDown.collider.gameObject.GetComponent <BoxCollider2D>().enabled = false;
                rayDown.collider.gameObject.GetComponent <EnemyMove>().enabled     = false;
                //Destroy(hit.collider.gameObject);
                hud.IncreaseScore(100);

                //var sound = rayDown.collider.gameObject.GetComponent<AudioSource>();
                //sound.Play();
            }
        }
    }
Esempio n. 17
0
    void OnTriggerEnter(Collider other)
    {
        PlayerPhysics physics = other.gameObject.GetComponent <PlayerPhysics>();

        if (physics)
        {
            AudioSource.PlayClipAtPoint(coinpickup, transform.position);
            hud = GameObject.Find("Main Camera").GetComponent <HUDScript>();
            //gameObject.renderer.enabled = false;
            hud.IncreaseScore(1000);
            Destroy(gameObject);
        }
    }
Esempio n. 18
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if(other.tag == "Player")
     {
         hud = GameObject.Find("Main Camera").GetComponent<HUDScript>();
         hud.IncreaseScore(-5);
         Destroy(this.gameObject);
     }
     if (this.tag == "PosShot")
     {
         hud = GameObject.Find("Main Camera").GetComponent<HUDScript>();
         hud.IncreaseScore(10);
         Destroy(this.gameObject);
     }
 }