Guest User

Untitled

a guest
May 8th, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Player : MonoBehaviour {
  5.  
  6.     public GameObject PlyObj;
  7.     public GameObject Bullet;
  8.     public GameObject PlyGun;
  9.     public Rigidbody2D PlyBody;
  10.     public GameObject PlyCam;
  11.  
  12.     public float MoveThrust = 2f;
  13.  
  14.     public AudioClip AllahHuAkbar;
  15.     public AudioClip Pew;
  16.     public AudioSource AudioSrc;
  17.  
  18.     // For fucks sake unity!
  19.     Vector3 MousePos;
  20.     Rect cHairRect;
  21.  
  22.     void Start () {
  23.         cHairRect = new Rect (0, 0, 0, 0);
  24.         PlyGun = GameObject.FindGameObjectWithTag ("PewThing");
  25.         PlyCam = GameObject.FindGameObjectWithTag ("MainCamera");
  26.     }
  27.  
  28.     void Update () {
  29.         // FUCKING CAMERA
  30.         PlyCam.transform.position = new Vector3(this.gameObject.transform.position.x, PlyCam.transform.position.y, PlyCam.transform.position.z);
  31.  
  32.         // GUN REALISMZ
  33.         PlyGun.transform.position = new Vector3 (PlyBody.transform.position.x + 0.128f, PlyBody.transform.position.y, 0f);
  34.         //PlyGun.transform.LookAt(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
  35.         // INPUT RAZIZZLE
  36.         if (Input.GetKey (KeyCode.W)) {
  37.             PlyObj.transform.Translate(Vector3.up * Time.deltaTime * MoveThrust * 4);
  38.         }
  39.         if (Input.GetKey (KeyCode.D)) {
  40.             PlyObj.transform.Translate(Vector3.right * Time.deltaTime * MoveThrust);
  41.         }
  42.         if (Input.GetKey (KeyCode.A)) {
  43.             PlyObj.transform.Translate(Vector3.left * Time.deltaTime * MoveThrust);
  44.         }
  45.         if (Input.GetKeyDown (KeyCode.Space)) {
  46.             // ALLAH HU AKBAAAAR
  47.             AudioSrc.PlayOneShot(AllahHuAkbar);
  48.         }
  49.  
  50.         // PEW PEW PEW!
  51.         if (Input.GetMouseButtonDown (0)) {
  52.             Instantiate (Bullet);
  53.             AudioSrc.PlayOneShot(Pew);
  54.             Debug.Log ("Pew?");
  55.         }
  56.  
  57.         // DONT YOU FUCKING TIP OVER ON ME!
  58.         PlyBody.transform.rotation = new Quaternion(0, 0, 0, 0);
  59.  
  60.         // CROSSHAIR
  61.         MousePos = Input.mousePosition;
  62.         // Ehmm... wat?
  63.         cHairRect = new Rect (MousePos.x, Screen.height - MousePos.y, 2, 2);
  64.     }
  65.  
  66.     void OnGUI() {
  67.         GUI.Box (cHairRect, "");
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment