Advertisement
JohnsterSpaceProgram

CampScript w/Mouse Cursor Visibility

Dec 23rd, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.56 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6.  
  7. // Token: 0x0200000B RID: 11
  8. public class CTRL_CampingScript : MonoBehaviour
  9. {
  10.     // Token: 0x06000034 RID: 52 RVA: 0x000032E5 File Offset: 0x000014E5
  11.     private void Start()
  12.     {
  13.         Debug.Log("Camping Controller Start");
  14.         base.StartCoroutine("Timer");
  15.         this.UpdateStickCount();
  16.         this.normalWalkSpeed = this.ps.walkSpeed;
  17.         this.normalRunSpeed = this.ps.runSpeed;
  18.     }
  19.  
  20.     // Token: 0x06000035 RID: 53 RVA: 0x00003328 File Offset: 0x00001528
  21.     private void Update()
  22.     {
  23.         this.MouseTexture();
  24.  
  25.         if (Input.GetMouseButtonDown(0))
  26.         {
  27.             Debug.Log("Click");
  28.             Ray ray = Camera.main.ScreenPointToRay(new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2), 0f));
  29.             RaycastHit raycastHit;
  30.             if (Physics.Raycast(ray, out raycastHit))
  31.             {
  32.                 if (raycastHit.transform.tag == "Firewood" & Vector3.Distance(this.player.position, raycastHit.transform.position) < 10f)
  33.                 {
  34.                     Debug.Log("My object is clicked by mouse");
  35.                     UnityEngine.Object.Destroy(raycastHit.transform.gameObject);
  36.                     this.AddSticks(1);
  37.                 }
  38.                 else if (raycastHit.transform.name == "Fire" & Vector3.Distance(this.player.position, raycastHit.transform.position) < 10f)
  39.                 {
  40.                     this.fire.BuildFire(this.sticks);
  41.                     this.AddSticks(this.sticks * -1);
  42.                 }
  43.             }
  44.         }
  45.         if (Input.GetKeyDown(KeyCode.R))
  46.         {
  47.             this.AddSticks(this.sticks * -1);
  48.         }
  49.     }
  50.  
  51.     // Token: 0x06000036 RID: 54 RVA: 0x0000345C File Offset: 0x0000165C
  52.     private IEnumerator Timer()
  53.     {
  54.         float t = 1f;
  55.         while (t > 0f)
  56.         {
  57.             t -= Time.deltaTime;
  58.             yield return new WaitForEndOfFrame();
  59.         }
  60.         this.time--;
  61.         if (this.time < 0)
  62.         {
  63.             Time.timeScale = 0f;
  64.             this.AddScore(Mathf.RoundToInt(this.fire.fireLevel * 10000f));
  65.             this.winscreenbg.SetActive(true);
  66.             this.finalText.gameObject.SetActive(true);
  67.             this.finalText.text = string.Concat(new object[]
  68.             {
  69.                 "Wow, you are good at camping!\nFire Bonus:\n",
  70.                 Mathf.RoundToInt(this.fire.fireLevel * 10000f),
  71.                 "\n\nYour Score:\n",
  72.                 this.score,
  73.                 "\n\nWith that score, you get these great things! Congrats!"
  74.             });
  75.             if (this.score >= 50000)
  76.             {
  77.                 this.reward1.SetActive(true);
  78.                 this.reward2.SetActive(true);
  79.                 this.reward3.SetActive(true);
  80.                 this.reward4.SetActive(true);
  81.             }
  82.             else if (this.score >= 25000)
  83.             {
  84.                 this.reward1.SetActive(true);
  85.                 this.reward2.SetActive(true);
  86.                 this.reward3.SetActive(true);
  87.             }
  88.             else
  89.             {
  90.                 this.reward1.SetActive(true);
  91.             }
  92.             base.StartCoroutine("WinTime");
  93.             this.audioDevice.PlayOneShot(this.winMusic);
  94.         }
  95.         else
  96.         {
  97.             this.timeText.text = "Time: " + this.time;
  98.             base.StartCoroutine("Timer");
  99.         }
  100.         yield break;
  101.     }
  102.  
  103.     // Token: 0x06000037 RID: 55 RVA: 0x00003478 File Offset: 0x00001678
  104.     public void AddSticks(int amount)
  105.     {
  106.         this.sticks += amount;
  107.         this.UpdateStickCount();
  108.         if (this.sticks > 3)
  109.         {
  110.             this.ps.walkSpeed = this.normalWalkSpeed - (float)(8 * (this.sticks - 3)) / ((float)(this.sticks - 3) + 2f / this.speedScale);
  111.             this.ps.slowSpeed = this.ps.walkSpeed;
  112.             this.ps.runSpeed = this.normalRunSpeed - (float)(8 * (this.sticks - 3)) / ((float)(this.sticks - 3) + 2f / this.speedScale);
  113.         }
  114.         else
  115.         {
  116.             this.ps.walkSpeed = this.normalWalkSpeed;
  117.             this.ps.slowSpeed = this.normalWalkSpeed;
  118.             this.ps.runSpeed = this.normalRunSpeed;
  119.         }
  120.     }
  121.  
  122.     // Token: 0x06000038 RID: 56 RVA: 0x0000355B File Offset: 0x0000175B
  123.     private void UpdateStickCount()
  124.     {
  125.         this.stickText.text = this.sticks + " Sticks";
  126.     }
  127.  
  128.     // Token: 0x06000039 RID: 57 RVA: 0x0000357D File Offset: 0x0000177D
  129.     public void AddScore(int points)
  130.     {
  131.         this.score += points;
  132.         this.scoreText.text = this.score + " Points";
  133.     }
  134.  
  135.     // Token: 0x0600003A RID: 58 RVA: 0x000035B0 File Offset: 0x000017B0
  136.     public void BigScore(int value)
  137.     {
  138.         this.bigScoreText.text = "BIG POINTS! \n" + value;
  139.         this.bigScoreText.gameObject.SetActive(true);
  140.         this.audioDevice.PlayOneShot(this.bigScoreSound);
  141.         base.StartCoroutine("BigScoreTime");
  142.     }
  143.  
  144.     // Token: 0x0600003B RID: 59 RVA: 0x00003608 File Offset: 0x00001808
  145.     private IEnumerator BigScoreTime()
  146.     {
  147.         float t = 1f;
  148.         while (t > 0f)
  149.         {
  150.             t -= Time.deltaTime;
  151.             yield return new WaitForEndOfFrame();
  152.         }
  153.         this.bigScoreText.gameObject.SetActive(false);
  154.         yield break;
  155.     }
  156.  
  157.     // Token: 0x0600003C RID: 60 RVA: 0x00003624 File Offset: 0x00001824
  158.     private IEnumerator WinTime()
  159.     {
  160.         float t = 10f;
  161.         while (t > 0f)
  162.         {
  163.             t -= Time.unscaledDeltaTime;
  164.             yield return new WaitForEndOfFrame();
  165.         }
  166.         this.msct.UnlockCursor();
  167.         this.msct.UnlockMouse();
  168.         SceneManager.LoadScene("TestTitleScreen");
  169.         yield break;
  170.     }
  171.  
  172.     // Token: 0x0600003D RID: 61 RVA: 0x00003638 File Offset: 0x00001838
  173.     public void SpawnBaldi()
  174.     {
  175.         this.baldi.SetActive(true);
  176.         this.msct.UnlockCursor();
  177.         this.msct.UnlockMouse();
  178.         SceneManager.LoadScene("TestMinigameLost");
  179.     }
  180.  
  181.     private void MouseTexture()
  182.     {
  183.         Ray ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
  184.  
  185.         RaycastHit raycastHit;
  186.  
  187.         if (Physics.Raycast(ray, out raycastHit) && (raycastHit.collider.tag == "Firewood" & Vector3.Distance(this.player.position, raycastHit.transform.position) < 10f))
  188.         {
  189.             {
  190.  
  191.                 this.reticle.SetActive(false);
  192.                 this.reticle2.SetActive(true);
  193.                 return;
  194.  
  195.             }
  196.         }
  197.         if (Physics.Raycast(ray, out raycastHit) && (raycastHit.collider.tag == "Fire" & Vector3.Distance(this.player.position, raycastHit.transform.position) < 10f))
  198.         {
  199.             {
  200.  
  201.                 this.reticle.SetActive(false);
  202.                 this.reticle2.SetActive(true);
  203.                 return;
  204.  
  205.             }
  206.         }
  207.         {
  208.             this.reticle.SetActive(true);
  209.  
  210.             this.reticle2.SetActive(false);
  211.  
  212.             return;
  213.         }
  214.     }
  215.  
  216.     // Token: 0x04000052 RID: 82
  217.     public int sticks;
  218.  
  219.     // Token: 0x04000053 RID: 83
  220.     public int score;
  221.  
  222.     // Token: 0x04000054 RID: 84
  223.     public int time;
  224.  
  225.     // Token: 0x04000055 RID: 85
  226.     public float speedScale;
  227.  
  228.     // Token: 0x04000056 RID: 86
  229.     public GameObject baldi;
  230.  
  231.     // Token: 0x04000057 RID: 87
  232.     public GameObject reward1;
  233.  
  234.     // Token: 0x04000058 RID: 88
  235.     public GameObject reward2;
  236.  
  237.     // Token: 0x04000059 RID: 89
  238.     public GameObject reward3;
  239.  
  240.     // Token: 0x0400005A RID: 90
  241.     public GameObject reward4;
  242.  
  243.     public GameObject winscreenbg;
  244.  
  245.     // Token: 0x0400005B RID: 91
  246.     public Text stickText;
  247.  
  248.     // Token: 0x0400005C RID: 92
  249.     public Text scoreText;
  250.  
  251.     // Token: 0x0400005D RID: 93
  252.     public Text bigScoreText;
  253.  
  254.     // Token: 0x0400005E RID: 94
  255.     public Text timeText;
  256.  
  257.     // Token: 0x0400005F RID: 95
  258.     public Text finalText;
  259.  
  260.     // Token: 0x04000060 RID: 96
  261.     public Transform player;
  262.  
  263.     // Token: 0x04000061 RID: 97
  264.     public PlayerScript ps;
  265.  
  266.     // Token: 0x04000062 RID: 98
  267.     private float normalWalkSpeed;
  268.  
  269.     // Token: 0x04000063 RID: 99
  270.     private float normalRunSpeed;
  271.  
  272.     // Token: 0x04000064 RID: 100
  273.     public FireScript fire;
  274.  
  275.     // Token: 0x04000065 RID: 101
  276.     public AudioSource audioDevice;
  277.  
  278.     // Token: 0x04000066 RID: 102
  279.     public AudioClip bigScoreSound;
  280.  
  281.     // Token: 0x04000067 RID: 103
  282.     public AudioClip winMusic;
  283.  
  284.     public MouseScriptCampingTest msct;
  285.  
  286.     public GameObject reticle;
  287.  
  288.     public GameObject reticle2;
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement