Exemplo n.º 1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag.Contains ("Wall")) {
         //player hit wall
         switch (state) {
         case PlayerStates.MovingLeft:
             if (other.Equals (LeftWall))
                 state = PlayerStates.StopedLeft;
             break;
         case PlayerStates.MovingRight:
             if (other.Equals (RightWall))
                 state = PlayerStates.StopedRight;
             break;
         }
     } else if (other.tag.Contains ("ScoreLine")) {
         gameController.IncrementScore();
     } else if (other.tag.Contains ("Obsticle")){
         // Player hit obsticles
         GameController.paused = true;
     }
 }
    void OnTriggerEnter2D(Collider2D other) {
        if (other.Equals(GameObject.FindGameObjectWithTag("Diamond").GetComponentInChildren<BoxCollider2D>())) {
			PickupDiamond ();
        }
    }
	protected override void OnTriggerExit2D (Collider2D other)
	{
		if (other.Equals(bench.collider2D))
			this.GetComponent<BoxCollider2D>().isTrigger = false;
		base.OnTriggerExit2D (other);
	}
Exemplo n.º 4
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.Equals(player.GetComponent<BoxCollider2D>()))
         Application.LoadLevel(scene);
 }