private void handleItemCollision(Collider2D other) { if (other.gameObject.tag == Tags.TAG_VEGETABLE) { other.gameObject.SetActive(false); if (playerStatus.FitnessLevel < playerStatus.MaxFitnessLevel) { HealthyFood healthyFood = other.gameObject.GetComponent <HealthyFood>(); healthyFood.modifyFitnessLevel(playerStatus, Constants.VEGETABLE_FITNESS_CHANGE); } if (playerStatus.weight > playerStatus.minWeight) { playerStatus.weight += Constants.VEGETABLE_WEIGHT_CHANGE; } PlayEatAppleSound(); ItemAchievement.incrementItemCount(); playerStatus.handleVegetableCollision(); gameObject.transform.localScale = new Vector3(playerStatus.weight, playerStatus.weight, 1); } if (other.gameObject.tag == Tags.TAG_CANDY) { Destroy(other.gameObject); if (playerStatus.FitnessLevel > playerStatus.MinFitenessLevel) { JunkFood junkfood = other.gameObject.GetComponent <JunkFood>(); junkfood.modifyFitnessLevel(playerStatus, Constants.CANDY_FITNESS_CHANGE); } if (playerStatus.weight < playerStatus.MaxWeight) { playerStatus.weight += Constants.CANDY_WEIGHT_CHANGE; } PlayEatCandySound(); ItemAchievement.incrementItemCount(); playerStatus.handleJunkFoodCollision(); gameObject.transform.localScale = new Vector3(playerStatus.weight, playerStatus.weight, 1); } if (other.gameObject.tag == Tags.TAG_FLAG) { PlayAchievement.incrementPlayCount(); PlayerPrefs.SetInt("Finished", 1); if (playerStatus.score.getScore() > PlayerPrefs.GetInt(PlayerPrefs.GetString("HighScore5"))) { Application.LoadLevel("highscore"); } else { Application.LoadLevel("ExitSuccess"); } } }
void OnBecameInvisible() { PlayAchievement.incrementPlayCount(); if (transform.position.y <= -Camera.main.camera.orthographicSize) { PlayerPrefs.SetInt("Finished", 0); if (playerStatus.score.getScore() > PlayerPrefs.GetInt(PlayerPrefs.GetString("HighScore5"))) { ; Application.LoadLevel("highscore"); } else { Application.LoadLevel("Exitfailed"); } } }