Advertisement
zhardyCode

Education Game - Fountain Questions

Mar 29th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class FountainQuestion : FountainAnswer
  6. {
  7.  
  8.     //provides a countdown until question and checks to see if there already is a question.
  9.     void Update()
  10.     {
  11.  
  12.         if (RandTimer >= 0 && randPanel.activeInHierarchy == false)
  13.         {
  14.             //stops esteem, risk, and satisfaction from updating by tuning off player collider.
  15.             gameObject.GetComponent<BoxCollider2D>().enabled = true;
  16.             //resume the game
  17.             timeFactor = 1;
  18.             //deactivate the buttons
  19.             fountainYes.SetActive(false);
  20.             fountainNo.SetActive(false);
  21.         }
  22.  
  23.         else
  24.         {
  25.             //stops esteem, risk, and satisfaction from updating by tuning off player collider.
  26.             gameObject.GetComponent<BoxCollider2D>().enabled = false;
  27.             //pause the game
  28.             timeFactor = 0;
  29.             //activate the question
  30.             randPanel.SetActive(true);
  31.         }
  32.     }
  33.  
  34.     //when RandTimer is zero this code acts as a switch to activate the question by checking to see if the player is in a matching location
  35.     void OnTriggerStay2D(Collider2D other)
  36.     {
  37.         RandTimer -= Time.deltaTime;
  38.  
  39.         if (RandTimer <= 0)
  40.         {
  41.             activateFountainQuestion = true;
  42.             fountainYes.SetActive(true);
  43.             fountainNo.SetActive(true);
  44.         }
  45.  
  46.        
  47.  
  48.  
  49.     }
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement