Advertisement
JohnsterSpaceProgram

CampController Script (Finished FTT Version)

Dec 12th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.78 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CampController : MonoBehaviour //Code in the CampController script for the field trip
  6. {
  7.     // Start is called before the first frame update
  8.     void Start()
  9.     {
  10.         this.campingmusic.SetActive(false);
  11.         this.campingmuswin.SetActive(false);
  12.         this.campcharacter.SetActive(false);
  13.         this.bushonkarrival.SetActive(false);
  14.         this.schoolbus.SetActive(false);
  15.         this.campwinitembox.SetActive(true);
  16.         this.whoosh.SetActive(false);
  17.         this.campcomplete = false;
  18.         this.itemboxdissapear = false;
  19.         this.playerwin = false;
  20.         this.surviveforseconds.SetActive(false);
  21.         this.gettothebus.SetActive(false);
  22.         this.rewarditemtext.SetActive(false);
  23.     }
  24.  
  25.     // Update is called once per frame
  26.     void Update()
  27.     {
  28.         if (this.plsc.camping == true)
  29.         {
  30.             this.bal.SetActive(false);
  31.             this.play.SetActive(false);
  32.             this.pri.SetActive(false);
  33.             this.sweep.SetActive(false);
  34.             this.firstpri.SetActive(false);
  35.             this.zeroth.SetActive(false);
  36.             this.artsandcrafts.SetActive(false);
  37.             this.bullychar.SetActive(false);
  38.             this.notebooktext.SetActive(false);
  39.             this.itembg.SetActive(false);
  40.             this.itemslots.SetActive(false);
  41.             this.select.SetActive(false);
  42.             this.slot0.SetActive(false);
  43.             this.slot1.SetActive(false);
  44.             this.slot2.SetActive(false);
  45.             this.itemstext.SetActive(false);
  46.             StartCoroutine(StartCamp());
  47.         }
  48.         if (this.plsc.camping == false && this.campcomplete == true && this.playerwin == false)
  49.         {
  50.             this.bal.SetActive(true);
  51.             this.play.SetActive(true);
  52.             this.pri.SetActive(true);
  53.             this.sweep.SetActive(true);
  54.             this.firstpri.SetActive(true);
  55.             this.zeroth.SetActive(true);
  56.             this.artsandcrafts.SetActive(true);
  57.             this.bullychar.SetActive(true);
  58.             this.notebooktext.SetActive(true);
  59.             this.itembg.SetActive(true);
  60.             this.itemslots.SetActive(true);
  61.             this.select.SetActive(true);
  62.             this.slot0.SetActive(true);
  63.             this.slot1.SetActive(true);
  64.             this.slot2.SetActive(true);
  65.             this.itemstext.SetActive(true);
  66.             this.CampRewards();
  67.         }
  68.         if (this.campcomplete == true)
  69.         {
  70.             this.surviveforseconds.SetActive(false);
  71.             this.gettothebus.SetActive(true);
  72.             this.bushonkarrival.SetActive(true);
  73.             this.campcharacter.SetActive(false);
  74.         }
  75.         if (this.itemboxdissapear == true)
  76.         {
  77.             this.gettothebus.SetActive(false);
  78.             this.campwinitembox.SetActive(false);
  79.             this.whoosh.SetActive(true);
  80.         }
  81.         if (this.playerwin == true)
  82.         {
  83.             this.campingmusic.SetActive(false);
  84.             this.gettothebus.SetActive(false);
  85.             StartCoroutine(PlayerWin());
  86.         }
  87.     }
  88.  
  89.     IEnumerator StartCamp()
  90.     {
  91.         this.surviveforseconds.SetActive(true);
  92.         this.campingmusic.SetActive(true);
  93.         this.campcharacter.SetActive(true);
  94.         float timer = 45f;
  95.         while (timer > 0)
  96.         {
  97.             timer -= Time.deltaTime;
  98.             yield return new WaitForEndOfFrame();
  99.         }
  100.         this.campcomplete = true;
  101.         this.schoolbus.SetActive(true);
  102.     }
  103.  
  104.     IEnumerator PlayerWin()
  105.     {
  106.         this.rewarditemtext.SetActive(true);
  107.         this.campingmuswin.SetActive(true);
  108.         this.plsc.walkSpeed = 0f;
  109.         this.plsc.runSpeed = 0f;
  110.         float timer = 5f;
  111.         while (timer > 0)
  112.         {
  113.             timer -= Time.deltaTime;
  114.             yield return new WaitForEndOfFrame();
  115.         }
  116.         this.plsc.walkSpeed = 10f;
  117.         this.plsc.runSpeed = 16f;
  118.         this.playerwin = false;
  119.         this.rewarditemtext.SetActive(false);
  120.     }
  121.  
  122.     public void CampRewards()
  123.     {
  124.         this.campwinitembox.SetActive(true);
  125.         this.campbus.SetActive(false);
  126.         this.itemboxdissapear = true;
  127.     }
  128.  
  129.     public PlayerScript plsc;
  130.  
  131.     public GameObject bal;
  132.  
  133.     public GameObject play;
  134.  
  135.     public GameObject pri;
  136.  
  137.     public GameObject sweep;
  138.  
  139.     public GameObject zeroth;
  140.  
  141.     public GameObject firstpri;
  142.  
  143.     public GameObject artsandcrafts;
  144.  
  145.     public GameObject campcharacter;
  146.  
  147.     public GameObject bullychar;
  148.  
  149.     public GameObject campingmusic;
  150.  
  151.     public GameObject campingmuswin;
  152.  
  153.     public GameObject schoolbus;
  154.  
  155.     public bool campcomplete;
  156.  
  157.     public GameObject campbus;
  158.  
  159.     public GameObject campwinitembox;
  160.  
  161.     public GameObject whoosh;
  162.  
  163.     public bool itemboxdissapear;
  164.  
  165.     public bool playerwin;
  166.  
  167.     public GameObject notebooktext;
  168.     public GameObject itembg;
  169.     public GameObject select;
  170.     public GameObject slot0;
  171.     public GameObject slot1;
  172.     public GameObject slot2;
  173.     public GameObject itemslots;
  174.     public GameObject itemstext;
  175.  
  176.     public GameObject rewarditemtext;
  177.     public GameObject surviveforseconds;
  178.     public GameObject gettothebus;
  179.  
  180.     public GameObject bushonkarrival;
  181. }
  182.  
  183.  
  184.  
  185.  
  186. //PlayerScript.cs
  187.  
  188. // Token: 0x060000E1 RID: 225 RVA: 0x00007AC6 File Offset: 0x00005EC6
  189. {
  190.     private void Start()
  191.     {
  192.         this.camping = false; //Set camping for the player to false
  193.     }
  194.    
  195.     // Token: 0x060000E7 RID: 231 RVA: 0x00007FC8 File Offset: 0x000063C8
  196.     private void OnTriggerEnter(Collider other)
  197.     {
  198.         else if (other.transform.name == "minigamebus") //If the player touches the bus in the school
  199.         {
  200.             this.player.position = new Vector3(-259f, 4f, 55f); // Teleport the player to the camping field trip minigame
  201.             this.camping = true; //Set camping for the player to true
  202.         }
  203.         else if (other.transform.name == "schoolbus") //If the player touches the bus that takes them back to the school
  204.         {
  205.             this.player.position = new Vector3(-120f, 4f, 145f); // Teleport the player back to the schoolhouse
  206.             this.camping = false; //Set player camping to false
  207.             this.campscript.playerwin = true; //Set playerwin in the campcontroller script to true
  208.         }
  209.         else if (other.transform.name == "CampingChar") //If the player collides with the camping character
  210.         {
  211.                 this.gameOver = true; //Give them a gameover
  212.         }
  213.         else if (other.transform.name == "Joeaudio") //If the player collides with the invisible box near the bus
  214.         {
  215.             this.joesaudio.SetActive(true); //Play joe's welcome audio
  216.         }
  217.     }
  218.     public GameObject joesaudio;
  219.     public CampController campscript; //Define the campcontroller script
  220. }
  221.  
  222. //Campcharscript.cs
  223.  
  224. public class CampCharScript : MonoBehaviour //Script for the charcter that chases you in the field trip
  225. {
  226.     // Token: 0x060000AE RID: 174 RVA: 0x0000653A File Offset: 0x0000493A
  227.     public void Start()
  228.     {
  229.         this.agent = base.GetComponent<UnityEngine.AI.NavMeshAgent>(); // Define the AI Agent
  230.     }
  231.  
  232.     // Token: 0x060000AF RID: 175 RVA: 0x0000654E File Offset: 0x0000494E
  233.     private void Update()
  234.     {
  235.         if (this.coolDown > 0f)
  236.         {
  237.             this.coolDown -= 1f * Time.deltaTime;
  238.         }
  239.     }
  240.  
  241.     // Token: 0x060000B0 RID: 176 RVA: 0x00006578 File Offset: 0x00004978
  242.     private void FixedUpdate()
  243.     {
  244.         Vector3 direction = this.player.position - base.transform.position;
  245.         RaycastHit raycastHit;
  246.         if (Physics.Raycast(base.transform.position, direction, out raycastHit, float.PositiveInfinity, 3,       
  247.         QueryTriggerInteraction.Ignore) & raycastHit.transform.tag == "Player") //Check if its the player
  248.         {
  249.             this.dbs = true; //If the character sees the player
  250.             this.TargetPlayer(); //Head towards the player
  251.         }
  252.         else
  253.         {
  254.             this.TargetPlayer(); //Target the player
  255.         }
  256.     }
  257.  
  258.     // Token: 0x060000B2 RID: 178 RVA: 0x00006658 File Offset: 0x00004A58
  259.     private void TargetPlayer()
  260.     {
  261.         this.agent.SetDestination(this.player.position); //Set it's destination to the player
  262.         this.coolDown = 1f;
  263.         this.agent.speed = 9.5f; //Set the agent's speed to slightly less than player's walk speed (player walk speed = 10f)
  264.     }
  265.  
  266.     // Token: 0x04000125 RID: 293
  267.     public bool dbs; //Variable that determines if the character sees the player
  268.  
  269.     // Token: 0x04000126 RID: 294
  270.     public Transform player; //Define the player
  271.  
  272.     // Token: 0x04000129 RID: 297
  273.     public float coolDown;
  274.  
  275.     // Token: 0x0400012A RID: 298
  276.     private UnityEngine.AI.NavMeshAgent agent;
  277. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement