JohnsterSpaceProgram

CampController Script (Old/Unfinished Version)

Dec 11th, 2019
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.04 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CampController : MonoBehaviour //Script for the camping field trip minigame
  6. {
  7.     // Start is called before the first frame update
  8.     void Start() //When you start playing the mod
  9.     {
  10.         this.campingmusic.SetActive(false); //Disable the camping music
  11.         this.campingmuswin.SetActive(false); //Disable the mus_win music
  12.         this.campcharacter.SetActive(false); //Disable the character that chases you
  13.         this.schoolbus.SetActive(false); //Disable the bus that takes you back to the schoolhouse
  14.         this.campwinitembox.SetActive(true); //Activate the box surrounding the reward
  15.         this.whoosh.SetActive(false); //Disable the bal_wow sound
  16.         this.campcomplete = false; //Set campcomplete to false
  17.         this.itemboxdissapear = false; //Set itemboxdissapear to false
  18.         this.playerwin = false; //Set playerwin to false
  19.     }
  20.  
  21.     // Update is called once per frame
  22.     void Update()
  23.     {
  24.         if (this.plsc.camping == true) //If the player has begun camping
  25.         {
  26.             this.bal.SetActive(false); //Disable Baldi
  27.             this.play.SetActive(false); //Disable playtime
  28.             this.pri.SetActive(false); //Disable pott
  29.             this.sweep.SetActive(false); //Disable gotta sweep
  30.             this.firstpri.SetActive(false); //Disable 1st prize
  31.             this.zeroth.SetActive(false); //Disable 0th Prize
  32.             this.artsandcrafts.SetActive(false); //Disable aac
  33.             this.bullychar.SetActive(false); //Disable the bully
  34.             this.notebooktext.SetActive(false); //Disable the notebook text (/7 Notebooks) in the hud
  35.             this.itembg.SetActive(false); //Disable the item slots in the hud
  36.             this.itemslots.SetActive(false); //Disable the item slots in the hud
  37.             this.select.SetActive(false); //Disable the item slots in the hud
  38.             this.slot0.SetActive(false); //Disable the item slots in the hud
  39.             this.slot1.SetActive(false); //Disable the item slots in the hud
  40.             this.slot2.SetActive(false); //Disable the item slots in the hud
  41.             this.itemstext.SetActive(false); //Disable the item text in the hud
  42.             StartCoroutine(StartCamp()); //Start the camping minigame
  43.         }
  44.         if (this.plsc.camping == false && this.campcomplete == true && this.playerwin == false) //If the player is not camping, has finished the camping minigame, and the win animation has finished
  45.         {
  46.             this.bal.SetActive(true); //Reactivate all the previously deactivated characters
  47.             this.play.SetActive(true);
  48.             this.pri.SetActive(true);
  49.             this.sweep.SetActive(true);
  50.             this.firstpri.SetActive(true);
  51.             this.zeroth.SetActive(true);
  52.             this.artsandcrafts.SetActive(true);
  53.             this.bullychar.SetActive(true);
  54.             this.notebooktext.SetActive(true);
  55.             this.itembg.SetActive(true); //Reactivate the disabled HUD elements
  56.             this.itemslots.SetActive(true);
  57.             this.select.SetActive(true);
  58.             this.slot0.SetActive(true);
  59.             this.slot1.SetActive(true);
  60.             this.slot2.SetActive(true);
  61.             this.itemstext.SetActive(true);
  62.             this.CampRewards(); //Start the camp rewards
  63.         }
  64.         if (this.campcomplete == true) //If the player has finished camping
  65.         {
  66.             this.campcharacter.SetActive(false); //Disable the character that chases you
  67.         }
  68.         if (this.itemboxdissapear == true) //If itemboxdissapear is set to true
  69.         {
  70.             this.campwinitembox.SetActive(false); //Disable the item box surrounding the reward
  71.             this.whoosh.SetActive(true); //Activate the bal_wow sound
  72.         }
  73.         if (this.playerwin == true) //If the player has won the camping minigame
  74.         {
  75.             this.campingmusic.SetActive(false); //Disable the camping music
  76.             StartCoroutine(PlayerWin()); //Start the player win animation
  77.         }
  78.     }
  79.  
  80.     IEnumerator StartCamp()
  81.     {
  82.         this.campingmusic.SetActive(true); //Activate the camping music
  83.         this.campcharacter.SetActive(true); //Activate the camping character
  84.         float timer = 45f; //Field trip lasts for 45 seconds
  85.         while (timer > 0) //If the field trip time left is 0
  86.         {
  87.             timer -= Time.deltaTime;
  88.             yield return new WaitForEndOfFrame();
  89.         }
  90.         this.campcomplete = true; //Set campcomplete to true
  91.         this.schoolbus.SetActive(true); //Activate the bus that takes you back to the school
  92.     }
  93.  
  94.     IEnumerator PlayerWin()
  95.     {
  96.         this.campingmuswin.SetActive(true); //Active the mus_win music
  97.         this.plsc.walkSpeed = 0f; //Set player's walk speed to 0
  98.         this.plsc.runSpeed = 0f; //Set player's run speed to 0
  99.         float timer = 5f; //Keep the player frozen in place for 5 seconds
  100.         while (timer > 0) //If the time left is 0
  101.         {
  102.             timer -= Time.deltaTime;
  103.             yield return new WaitForEndOfFrame();
  104.         }
  105.         this.plsc.walkSpeed = 10f; //Set the player's walk speed back to normal
  106.         this.plsc.runSpeed = 16f; //Set the player's run speed back to normal
  107.         this.playerwin = false; //Set playerwin to false
  108.     }
  109.  
  110.     public void CampRewards()
  111.     {
  112.         this.campwinitembox.SetActive(true); //Activate the item box surrounding the reward
  113.         this.campbus.SetActive(false); //Deactive the field trip bus
  114.         this.itemboxdissapear = true; //Set itemboxdissapear to true
  115.     }
  116.  
  117.     public PlayerScript plsc; //Define the player script
  118.  
  119.     public GameObject bal; //Characters
  120.  
  121.     public GameObject play; //Characters
  122.  
  123.     public GameObject pri; //Characters
  124.  
  125.     public GameObject sweep; //Characters
  126.  
  127.     public GameObject zeroth; //Characters
  128.  
  129.     public GameObject firstpri; //Characters
  130.  
  131.     public GameObject artsandcrafts; //Characters
  132.  
  133.     public GameObject campcharacter; //Characters
  134.  
  135.     public GameObject bullychar; //Characters
  136.  
  137.     public GameObject campingmusic; //Camping music gameobject
  138.  
  139.     public GameObject campingmuswin; //Camping win music gameobject
  140.  
  141.     public GameObject schoolbus; //Field trip bus gameobject
  142.  
  143.     public bool campcomplete;
  144.  
  145.     public GameObject campbus; //Field trip bus gameobject 2
  146.  
  147.     public GameObject campwinitembox;
  148.  
  149.     public GameObject whoosh;
  150.  
  151.     public bool itemboxdissapear;
  152.  
  153.     public bool playerwin;
  154.  
  155.     public GameObject notebooktext; //Player HUD elements
  156.     public GameObject itembg; //Player HUD elements
  157.     public GameObject select; //Player HUD elements
  158.     public GameObject slot0; //Player HUD elements
  159.     public GameObject slot1; //Player HUD elements
  160.     public GameObject slot2; //Player HUD elements
  161.     public GameObject itemslots; //Player HUD elements
  162.     public GameObject itemstext; //Player HUD elements
  163. }
  164.  
  165.  
  166.  
  167.  
  168. public class PlayerScript : MonoBehaviour //Code in the player script for the field trip
  169. {
  170.         private void OnTriggerEnter(Collider other)
  171.         {
  172.         else if (other.transform.name == "minigamebus") //If the player touches the field trip bus in the school
  173.         {
  174.             this.player.position = new Vector3(-259f, 4f, 55f); // Teleport the player to the camping field trip minigame
  175.             this.camping = true; //Set camping to true
  176.         }
  177.         else if (other.transform.name == "schoolbus") //If the player touches the bus that appears when the field trip is completed
  178.         {
  179.             this.player.position = new Vector3(-120f, 4f, 145f); // Teleport the player back to the schoolhouse
  180.             this.camping = false; //Set camping to false
  181.             this.campscript.playerwin = true; //Set playerwin to true
  182.         }
  183.         else if (other.transform.name == "CampingChar") //If the player touches the character in the field trip chasing them
  184.         {
  185.                 this.gameOver = true; //Give the player a gameover
  186.         }
  187.     }
  188.     public CampController campscript; //Define the campcontroller script
  189. }
Advertisement
Add Comment
Please, Sign In to add comment