Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Snag : MonoBehaviour {
  5.  
  6.     public GameObject gPlayer;
  7.     //public Player _Player;
  8.     public ChainThings _ChainThings;
  9.     public float direction = 0;
  10.  
  11.     public float burnout = 0;
  12.  
  13.     private LineRenderer twochain;
  14.  
  15.     void Start () {
  16.  
  17.         twochain = gameObject.GetComponent<LineRenderer>();
  18.         twochain.enabled = true;
  19.         gPlayer = GameObject.Find ("Player");
  20.         //_Player.holdEnemy ();
  21.         _ChainThings.holdEnemy ();
  22.  
  23.     }
  24.  
  25. // Gets called once when the bullet is created
  26. void Update () {  
  27.  
  28.         if (Input.GetKeyDown ("left")) {
  29.             direction = 1;
  30.         }
  31.  
  32.         if (Input.GetKeyDown ("right")) {
  33.             direction = 2;
  34.  
  35.         }
  36.         if (Input.GetKeyDown ("down")) {
  37.             direction = 3;
  38.  
  39.         }
  40.         if (Input.GetKeyDown ("up")) {
  41.             direction = 4;
  42.  
  43.         }
  44.  
  45.         twochain.SetPosition (1, transform.position);
  46.         twochain.SetPosition (0, gPlayer.transform.position);
  47.  
  48.         if (direction == 1) {
  49.             Vector3 tempPos = transform.position;
  50.             tempPos.x += 30 * Time.deltaTime;
  51.             tempPos.y = gPlayer.transform.position.y;
  52.             transform.position = tempPos;
  53.         }
  54.  
  55.         if (direction == 2) {
  56.             Vector3 tempPos = transform.position;
  57.             tempPos.x -= 30 * Time.deltaTime;
  58.             tempPos.y = gPlayer.transform.position.y;
  59.             transform.position = tempPos;
  60.         }
  61.  
  62.         if (direction == 4) {
  63.             Vector3 tempPos = transform.position;
  64.             tempPos.y += 30 * Time.deltaTime;
  65.             tempPos.x = gPlayer.transform.position.x;
  66.             transform.position = tempPos;
  67.         }
  68.  
  69.         if (direction == 3) {
  70.             Vector3 tempPos = transform.position;
  71.             tempPos.y -= 30 * Time.deltaTime;
  72.             tempPos.x = gPlayer.transform.position.x;
  73.             transform.position = tempPos;
  74.         }
  75.  
  76.         burnout += 1 * Time.deltaTime;
  77.  
  78.             if (burnout > 1) {
  79.         Destroy (gameObject);
  80.             }
  81.     }
  82.  
  83.     void FixedUpdate () {
  84.        
  85.    
  86.        
  87.     }
  88.  
  89.     void OnTriggerEnter2D(Collider2D other)
  90.     {
  91.         if (other.tag == "Enemy"  || other.tag == "ground") {
  92.             _ChainThings.holdEnemy();
  93.             Destroy (gameObject);
  94.         }
  95.     }
  96.  
  97.  
  98. // Gets called when the object goes out of the screen
  99. void OnBecameInvisible() {  
  100.     // Destroy the bullet
  101.         //Destroy(gameObject);
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement