Advertisement
jretchy

Untitled

May 17th, 2022
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.41 KB | None | 0 0
  1. public float moveSpeed = 5f;
  2.     public Rigidbody2D rb;
  3.     Vector2 movement;
  4.  
  5.     private GameObject mainCam;
  6.     private GameObject skillsUI;
  7.  
  8.     public bool hasGotBulb;
  9.     public bool hasGotFlashlight;
  10.     public bool hasTalkedToFederna;
  11.     public bool hasGotDog;
  12.  
  13.     public bool hasTalkedToMarcus;
  14.     public bool hasTalkedToFrazer;
  15.     public bool hasTalkedToJoel;
  16.     public bool hasTalkedToLogan;
  17.     public bool hasTalkedToTyler;
  18.  
  19.     public bool isInsideBar;
  20.     public AudioSource jazzMusic;
  21.  
  22.     public bool trashHint;
  23.     public bool lightbulbHint;
  24.  
  25.     public bool changedBulb;
  26.     public bool dogReturned;
  27.     public bool flashlightReturned;
  28.     public bool trashCollected;
  29.  
  30.     public bool brokenFight;
  31.     public bool talkedToCivilian;
  32.  
  33.     public bool gameFinished;
  34.  
  35.     public Animator animator;
  36.  
  37.     bool WalkingDown;
  38.     bool NotWalkingDown;
  39.  
  40.     bool WalkingUp;
  41.     bool NotWalkingUp;
  42.  
  43.     bool WalkingLeft;
  44.     bool NotWalkingLeft;
  45.  
  46.     bool WalkingRight;
  47.     bool NotWalkingRight;
  48.  
  49.     public string startPoint;
  50.  
  51.     static bool playerExists;
  52.  
  53.     private void Start()
  54.     {
  55.         mainCam = GameObject.Find("Main Camera");
  56.         skillsUI = GameObject.Find("SkillsUI");
  57.  
  58.         WalkingDown = false;
  59.         NotWalkingDown = true;
  60.  
  61.         WalkingUp = false;
  62.         NotWalkingUp = true;
  63.  
  64.         WalkingRight = false;
  65.         NotWalkingRight = true;
  66.  
  67.         WalkingLeft = false;
  68.         NotWalkingLeft = true;
  69.  
  70.         hasGotBulb = false;
  71.         hasGotFlashlight = false;
  72.         hasTalkedToFederna = false;
  73.         hasGotDog = false;
  74.  
  75.         hasTalkedToMarcus = false;
  76.         hasTalkedToFrazer = false;
  77.         hasTalkedToJoel = false;
  78.         hasTalkedToLogan = false;
  79.         hasTalkedToTyler = false;
  80.  
  81.         isInsideBar = false;
  82.  
  83.      
  84.         DontDestroyOnLoad(this.gameObject);
  85.        
  86.     }
  87.  
  88.     void Update()
  89.     {
  90.         movement.x = Input.GetAxisRaw("Horizontal");
  91.         movement.y = Input.GetAxisRaw("Vertical");
  92.  
  93.         if (Input.GetKeyDown(KeyCode.S))
  94.         {
  95.             WalkingDown = true;
  96.             NotWalkingDown = false;
  97.         }
  98.         else if (Input.GetKeyUp(KeyCode.S))
  99.         {
  100.             NotWalkingDown = true;
  101.             WalkingDown = false;
  102.         }
  103.  
  104.         if (Input.GetKeyDown(KeyCode.W))
  105.         {
  106.             WalkingUp = true;
  107.             NotWalkingUp = false;
  108.         }
  109.         else if (Input.GetKeyUp(KeyCode.W))
  110.         {
  111.             WalkingUp = false;
  112.             NotWalkingUp = true;
  113.         }
  114.  
  115.         if (Input.GetKeyDown(KeyCode.A))
  116.         {
  117.             WalkingLeft = true;
  118.             NotWalkingLeft = false;
  119.         }
  120.         else if (Input.GetKeyUp(KeyCode.A))
  121.         {
  122.             WalkingLeft = false;
  123.             NotWalkingLeft = true;
  124.         }
  125.  
  126.         if (Input.GetKeyDown(KeyCode.D))
  127.         {
  128.             WalkingRight = true;
  129.             NotWalkingRight = false;
  130.         }
  131.         else if (Input.GetKeyUp(KeyCode.D))
  132.         {
  133.             WalkingRight = false;
  134.             NotWalkingRight = true;
  135.         }
  136.  
  137.         if (isInsideBar == true)
  138.         {
  139.             jazzMusic.UnPause();
  140.         }
  141.         else
  142.         {
  143.             jazzMusic.Pause();
  144.         }
  145.  
  146.  
  147.         if (gameFinished == true)
  148.         {
  149.             Destroy(this.gameObject);
  150.             Destroy(mainCam);
  151.             Destroy(skillsUI);
  152.         }
  153.     }
  154.  
  155.     void FixedUpdate()
  156.     {
  157.         rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
  158.  
  159.         if (WalkingDown == true)
  160.         {
  161.             animator.SetBool("isWalkingDown", true);
  162.         }
  163.  
  164.         if (NotWalkingDown == true)
  165.         {
  166.             animator.SetBool("isWalkingDown", false);
  167.         }
  168.  
  169.         if (WalkingUp == true)
  170.         {
  171.             animator.SetBool("isWalkingUp", true);
  172.         }
  173.  
  174.         if (NotWalkingUp == true)
  175.         {
  176.             animator.SetBool("isWalkingUp", false);
  177.         }
  178.  
  179.         if (WalkingLeft == true)
  180.         {
  181.             animator.SetBool("isWalkingLeft", true);
  182.         }
  183.  
  184.         if (NotWalkingLeft == true)
  185.         {
  186.             animator.SetBool("isWalkingLeft", false);
  187.         }
  188.  
  189.         if (WalkingRight == true)
  190.         {
  191.             animator.SetBool("isWalkingRight", true);
  192.         }
  193.  
  194.         if (NotWalkingRight == true)
  195.         {
  196.             animator.SetBool("isWalkingRight", false);
  197.         }
  198.     }
  199. }
  200.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement