void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "EnemyDestroyer") { //Debug.Log("bunny destroyed by " + collision.gameObject.name); //GameObject explosion = (GameObject)Instantiate(Resources.Load("Explosion")); if (!AchTrackerScript.AchievementHasBeenMet(AchievementTrackerScript.Achievement.CHOPPED_BUNNIES)) { AchTrackerScript.IncrementCount(AchievementTrackerScript.Achievement.CHOPPED_BUNNIES); } DestroyBunny(); } else if (collision.gameObject.tag == "Player") { FlapjackController FpController = (FlapjackController)collision.gameObject.GetComponent(typeof(FlapjackController)); if (FpController.getPlayerState() == FlapjackController.PlayerState.INVINCIBLE) { DestroyBunny(); return; } else { guiController.ShowGameOverScreen(); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject == Player) { AchTrackerScript.IncrementCount(AchievementTrackerScript.Achievement.OFF_SCREEN); return; } }
// Update is called once per frame void Update() { RaycastHit2D[] results = new RaycastHit2D[1]; if ((guiController.currentScreen == GUIController.CurrentScreen.GAME_PLAY) && Physics2D.RaycastNonAlloc(transform.position, Vector2.up, results, Mathf.Infinity, Player) != 0 && !hasBeenHurdled) { if (!AchTrackerScript.AchievementHasBeenMet(ThisAchievement)) { //Debug.Log( "Player has hurdled: " + gameObject); AchTrackerScript.IncrementCount(ThisAchievement); hasBeenHurdled = true; } } }