Advertisement
hodgepodge

PetManager.cs

Sep 27th, 2014
1,199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 KB | None | 0 0
  1. //PetManager.cs v0.3
  2. //Made with Unity 4.6 beta
  3. //Play the game here: https://googledrive.com/host/0B0VYjvzDNY0aUS00OG00X01iTGM/VDP.html
  4. // I'm aware of the bugs with changing the pet's status incorrectly with this version and some of the animations looking silly.
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using System.Collections;
  8.  
  9. public class PetManager : MonoBehaviour {
  10. public float startingHappy = 60;
  11. public float currentHappy;
  12. public float startingDiaper = 75;
  13. public float currentDiaper;
  14. public Slider happySlider;
  15. public Slider diaperSlider;
  16.  
  17. Animator anim;
  18. bool isSad;
  19. bool isCrying;
  20. bool isWet;
  21. bool isAboutToWet;
  22. bool isMessy;
  23. bool isVeryMessy;
  24. bool isFeed;
  25. bool isChanging;
  26. bool isPet;
  27. bool isCheck;
  28.  
  29. void Awake(){
  30. anim = GetComponent <Animator> ();
  31. currentHappy = startingHappy;
  32. currentDiaper = startingDiaper;
  33. }
  34.  
  35. void FixedUpdate () {
  36. happySlider.value = currentHappy;
  37. diaperSlider.value = currentDiaper;
  38.  
  39. if (currentHappy > 50 && isSad) {
  40. Happy ();
  41. }
  42. if (currentHappy <= 50 && currentHappy > 30 && !isSad) {
  43. Sad();
  44. }
  45. if (currentHappy <= 30 && !isCrying) {
  46. Crying();
  47. }
  48.  
  49. if (currentHappy < 0) {
  50. currentHappy = 0;
  51. }
  52. if (currentHappy > 100) {
  53. currentHappy = 100;
  54. }
  55.  
  56. if (isFeed) {
  57. currentHappy += .05f;
  58. currentDiaper -= .03f;
  59. }
  60. if (isPet) {
  61. currentHappy += .08f;
  62. }
  63. if (isChanging) {
  64. currentHappy += .05f;
  65. currentDiaper += .15f;
  66. if(currentDiaper >= 100){
  67. isChanging = false;
  68. isAboutToWet = false;
  69. isWet = false;
  70. isMessy = false;
  71. isVeryMessy = false;
  72. anim.SetBool ("Wet", false);
  73. anim.SetBool ("Messy", false);
  74. anim.SetBool ("VeryMessy", false);
  75. anim.SetBool ("AboutToWet", false);
  76. anim.SetBool ("Changing", false);
  77. }
  78. }
  79.  
  80. if (currentDiaper <= 50 && currentDiaper > 45 && !isAboutToWet) {
  81. AboutToWet();
  82. }
  83.  
  84. if (currentDiaper <= 45 && currentDiaper > 30 && !isWet) {
  85. Wet ();
  86. }
  87.  
  88. if (currentDiaper <= 30 && currentDiaper > 1 && !isMessy) {
  89. Messy();
  90. }
  91. if (currentDiaper <= 1 && !isVeryMessy) {
  92. VeryMessy ();
  93. }
  94. if (currentDiaper < 0) {
  95. currentDiaper = 0;
  96. }
  97.  
  98. currentHappy -= .03f;
  99. currentDiaper -= .025f;
  100. }
  101.  
  102. void Sad(){
  103. isSad = true;
  104. isCrying = false;
  105. anim.SetBool ("Sad", true);
  106. anim.SetBool ("Crying", false);
  107.  
  108. }
  109.  
  110. void Crying(){
  111. isCrying = true;
  112. isSad = false;
  113. anim.SetBool ("Crying", true);
  114. anim.SetBool ("Sad", false);
  115. }
  116.  
  117. void Happy(){
  118. isSad = false;
  119. anim.SetBool ("Sad", false);
  120. }
  121.  
  122. void AboutToWet(){
  123. isAboutToWet = true;
  124. isFeed = false;
  125. anim.SetBool ("AboutToWet", true);
  126. anim.SetBool ("Feed", false);
  127. }
  128.  
  129. void Wet(){
  130. isAboutToWet = false;
  131. isWet = true;
  132. anim.SetBool ("Wet", true);
  133. anim.SetBool ("AboutToWet", false);
  134. }
  135.  
  136. void Messy(){
  137. isWet = false;
  138. isMessy = true;
  139. anim.SetBool ("Messy", true);
  140. anim.SetBool ("Wet", false);
  141. audio.Play();
  142. }
  143.  
  144. void VeryMessy(){
  145. isMessy = false;
  146. isVeryMessy = true;
  147. anim.SetBool ("VeryMessy", true);
  148. anim.SetBool("Messy", false);
  149. audio.Play();
  150. }
  151.  
  152. void Pet(){ // Called from Pet button
  153. if (isPet == false && !isWet && !isMessy && !isVeryMessy && !isAboutToWet) {
  154. isPet = true;
  155. isFeed = false;
  156. isCheck = false;
  157. anim.SetBool ("Pet", true);
  158. anim.SetBool ("Feed", false);
  159. anim.SetBool ("Check", false);
  160. } else if (isPet == true && !isWet && !isMessy && !isVeryMessy && !isAboutToWet) {
  161. isPet = false;
  162. isFeed = false;
  163. isCheck = false;
  164. anim.SetBool ("Pet", false);
  165. anim.SetBool ("Feed", false);
  166. anim.SetBool ("Check", false);
  167. } else {
  168. currentHappy += 2; //temp
  169. }
  170. }
  171.  
  172. void Feed(){ // Called from Pet button
  173. if (isFeed == false && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
  174. isFeed = true;
  175. isPet = false;
  176. isCheck = false;
  177. anim.SetBool ("Feed", true);
  178. anim.SetBool ("Pet", false);
  179. anim.SetBool ("Check", false);
  180. } else if (isFeed == true && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
  181. isFeed = false;
  182. isPet = false;
  183. isCheck = false;
  184. anim.SetBool ("Feed", false);
  185. anim.SetBool ("Pet", false);
  186. anim.SetBool ("Check", false);
  187. } else {
  188. currentDiaper -= 2; //temp
  189. }
  190. }
  191.  
  192. void Check(){ // Called from Check button
  193. if (isCheck == false && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
  194. isCheck = true;
  195. isFeed = false;
  196. isPet = false;
  197. anim.SetBool ("Check", true);
  198. anim.SetBool ("Feed", false);
  199. anim.SetBool ("Pet", false);
  200. } /*else if (isCheck == true && !isWet && !isMessy && !isVeryMessy && !isAboutToWet ) {
  201. isCheck = false;
  202. anim.SetBool ("Check", false);
  203. } */
  204. else {
  205. isCheck = false;
  206. isFeed = false;
  207. isPet = false;
  208. anim.SetBool ("Check", false);
  209. anim.SetBool ("Feed", false);
  210. anim.SetBool ("Pet", false);
  211. }
  212. }
  213.  
  214. void Change(){ // Called from Change button
  215. if (isWet || isMessy || isVeryMessy) {
  216. isChanging = true;
  217. anim.SetBool ("Changing", true);
  218. /*currentDiaper = 100;
  219. isWet = false;
  220. isMessy = false;
  221. isVeryMessy = false;
  222. anim.SetBool ("Wet", false);
  223. anim.SetBool ("Messy", false);
  224. anim.SetBool ("VeryMessy", false);*/
  225. }
  226. }
  227. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement