Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. // Decompiled with JetBrains decompiler
  2. // Type: Chartergo
  3. // Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: A258C9B1-E700-457A-BAE7-06EFF4747DB4
  5. // Assembly location: /Volumes/T5_1TB/Projects/WakeApp/23_Petr/build/TestWakeApp_Data/Managed/Assembly-CSharp.dll
  6.  
  7. using UnityEngine;
  8. using UnityEngine.UI;
  9.  
  10. public class Chartergo : MonoBehaviour
  11. {
  12.   public float speedMove;
  13.   private float gravityForce;
  14.   public Vector3 moveVector;
  15.   private CharacterController ch_controller;
  16.   private Animator ch_animator;
  17.   public Text ScoreText;
  18.   public int score;
  19.  
  20.   private void Start()
  21.   {
  22.     this.score = 0;
  23.     this.ch_controller = this.GetComponent<CharacterController>();
  24.     this.ch_animator = this.GetComponent<Animator>();
  25.   }
  26.  
  27.   private void Update()
  28.   {
  29.     this.CharacterMove();
  30.     this.CamingGravity();
  31.     this.OutputScore();
  32.   }
  33.  
  34.   private void CharacterMove()
  35.   {
  36.     this.moveVector = Vector3.zero;
  37.     this.moveVector.x = Input.GetAxis("Horizontal") * this.speedMove;
  38.     this.moveVector.z = Input.GetAxis("Vertical") * this.speedMove;
  39.     if ((double) this.moveVector.x != 0.0 || (double) this.moveVector.z != 0.0)
  40.     {
  41.       int num = (int) this.ch_controller.Move(this.moveVector * Time.deltaTime);
  42.       this.ch_animator.SetBool("Move", true);
  43.     }
  44.     else
  45.       this.ch_animator.SetBool("Move", false);
  46.     if ((double) Vector3.Angle(Vector3.forward, this.moveVector) <= 1.0 && (double) Vector3.Angle(Vector3.forward, this.moveVector) != 0.0)
  47.       return;
  48.     this.transform.rotation = Quaternion.LookRotation(Vector3.RotateTowards(this.transform.forward, this.moveVector, this.speedMove, 0.0f));
  49.   }
  50.  
  51.   private void CamingGravity()
  52.   {
  53.     if (this.ch_controller.isGrounded)
  54.       this.gravityForce -= 20f * Time.deltaTime;
  55.     else
  56.       this.gravityForce = -1f;
  57.   }
  58.  
  59.   private void OutputScore()
  60.   {
  61.     this.ScoreText.text = "Coins:  " + (object) this.score;
  62.   }
  63.  
  64.   private void OnTriggerEnter(Collider other)
  65.   {
  66.     if (!other.gameObject.CompareTag("Coins"))
  67.       return;
  68.     Object.Destroy((Object) other.gameObject);
  69.     ++this.score;
  70.   }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement