Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PetManager.cs v0.3
- //Made with Unity 4.6 beta
- //Play the game here: https://googledrive.com/host/0B0VYjvzDNY0aUS00OG00X01iTGM/VDP.html
- // I'm aware of the bugs with changing the pet's status incorrectly with this version and some of the animations looking silly.
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class PetManager : MonoBehaviour {
- public float startingHappy = 60;
- public float currentHappy;
- public float startingDiaper = 75;
- public float currentDiaper;
- public Slider happySlider;
- public Slider diaperSlider;
- Animator anim;
- bool isSad;
- bool isCrying;
- bool isWet;
- bool isAboutToWet;
- bool isMessy;
- bool isVeryMessy;
- bool isFeed;
- bool isChanging;
- bool isPet;
- bool isCheck;
- void Awake(){
- anim = GetComponent <Animator> ();
- currentHappy = startingHappy;
- currentDiaper = startingDiaper;
- }
- void FixedUpdate () {
- happySlider.value = currentHappy;
- diaperSlider.value = currentDiaper;
- if (currentHappy > 50 && isSad) {
- Happy ();
- }
- if (currentHappy <= 50 && currentHappy > 30 && !isSad) {
- Sad();
- }
- if (currentHappy <= 30 && !isCrying) {
- Crying();
- }
- if (currentHappy < 0) {
- currentHappy = 0;
- }
- if (currentHappy > 100) {
- currentHappy = 100;
- }
- if (isFeed) {
- currentHappy += .05f;
- currentDiaper -= .03f;
- }
- if (isPet) {
- currentHappy += .08f;
- }
- if (isChanging) {
- currentHappy += .05f;
- currentDiaper += .15f;
- if(currentDiaper >= 100){
- isChanging = false;
- isAboutToWet = false;
- isWet = false;
- isMessy = false;
- isVeryMessy = false;
- anim.SetBool ("Wet", false);
- anim.SetBool ("Messy", false);
- anim.SetBool ("VeryMessy", false);
- anim.SetBool ("AboutToWet", false);
- anim.SetBool ("Changing", false);
- }
- }
- if (currentDiaper <= 50 && currentDiaper > 45 && !isAboutToWet) {
- AboutToWet();
- }
- if (currentDiaper <= 45 && currentDiaper > 30 && !isWet) {
- Wet ();
- }
- if (currentDiaper <= 30 && currentDiaper > 1 && !isMessy) {
- Messy();
- }
- if (currentDiaper <= 1 && !isVeryMessy) {
- VeryMessy ();
- }
- if (currentDiaper < 0) {
- currentDiaper = 0;
- }
- currentHappy -= .03f;
- currentDiaper -= .025f;
- }
- void Sad(){
- isSad = true;
- isCrying = false;
- anim.SetBool ("Sad", true);
- anim.SetBool ("Crying", false);
- }
- void Crying(){
- isCrying = true;
- isSad = false;
- anim.SetBool ("Crying", true);
- anim.SetBool ("Sad", false);
- }
- void Happy(){
- isSad = false;
- anim.SetBool ("Sad", false);
- }
- void AboutToWet(){
- isAboutToWet = true;
- isFeed = false;
- anim.SetBool ("AboutToWet", true);
- anim.SetBool ("Feed", false);
- }
- void Wet(){
- isAboutToWet = false;
- isWet = true;
- anim.SetBool ("Wet", true);
- anim.SetBool ("AboutToWet", false);
- }
- void Messy(){
- isWet = false;
- isMessy = true;
- anim.SetBool ("Messy", true);
- anim.SetBool ("Wet", false);
- audio.Play();
- }
- void VeryMessy(){
- isMessy = false;
- isVeryMessy = true;
- anim.SetBool ("VeryMessy", true);
- anim.SetBool("Messy", false);
- audio.Play();
- }
- void Pet(){ // Called from Pet button
- if (isPet == false && !isWet && !isMessy && !isVeryMessy && !isAboutToWet) {
- isPet = true;
- isFeed = false;
- isCheck = false;
- anim.SetBool ("Pet", true);
- anim.SetBool ("Feed", false);
- anim.SetBool ("Check", false);
- } else if (isPet == true && !isWet && !isMessy && !isVeryMessy && !isAboutToWet) {
- isPet = false;
- isFeed = false;
- isCheck = false;
- anim.SetBool ("Pet", false);
- anim.SetBool ("Feed", false);
- anim.SetBool ("Check", false);
- } else {
- currentHappy += 2; //temp
- }
- }
- void Feed(){ // Called from Pet button
- if (isFeed == false && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
- isFeed = true;
- isPet = false;
- isCheck = false;
- anim.SetBool ("Feed", true);
- anim.SetBool ("Pet", false);
- anim.SetBool ("Check", false);
- } else if (isFeed == true && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
- isFeed = false;
- isPet = false;
- isCheck = false;
- anim.SetBool ("Feed", false);
- anim.SetBool ("Pet", false);
- anim.SetBool ("Check", false);
- } else {
- currentDiaper -= 2; //temp
- }
- }
- void Check(){ // Called from Check button
- if (isCheck == false && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
- isCheck = true;
- isFeed = false;
- isPet = false;
- anim.SetBool ("Check", true);
- anim.SetBool ("Feed", false);
- anim.SetBool ("Pet", false);
- } /*else if (isCheck == true && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
- isCheck = false;
- anim.SetBool ("Check", false);
- } */
- else {
- isCheck = false;
- isFeed = false;
- isPet = false;
- anim.SetBool ("Check", false);
- anim.SetBool ("Feed", false);
- anim.SetBool ("Pet", false);
- }
- }
- void Change(){ // Called from Change button
- if (isWet || isMessy || isVeryMessy) {
- isChanging = true;
- anim.SetBool ("Changing", true);
- /*currentDiaper = 100;
- isWet = false;
- isMessy = false;
- isVeryMessy = false;
- anim.SetBool ("Wet", false);
- anim.SetBool ("Messy", false);
- anim.SetBool ("VeryMessy", false);*/
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement