Advertisement
dantepw

Untitled

May 18th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MovimentoPlayer : MonoBehaviour {
  5.  
  6.     // Use this for initialization
  7.     void Start () {
  8.    
  9.     }
  10.  
  11.  
  12.  
  13.     // Update is called once per frame
  14.     void Update () {
  15.         if(Input.GetKey(KeyCode.A))
  16.         {
  17.             this.transform.Translate(-5 * Time.deltaTime,0 ,0);
  18.         }
  19.         if(Input.GetKey (KeyCode.D))
  20.         {
  21.             this.transform.Translate (5 * Time.deltaTime, 0, 0);
  22.         }
  23.  
  24.         if(Input.GetKey (KeyCode.W))
  25.         {
  26.             this.transform.Translate (0, 10 * Time.deltaTime, 0);
  27.         }
  28.     }
  29.  
  30.  
  31.     void OnCollisionEnter2D(Collision2D colidir)
  32.     {
  33.        
  34.         float posicaoInimigo = colidir.transform.position.y;
  35.         float posicaoPlayer = transform.position.y;
  36.        
  37.        
  38.         if (colidir.gameObject.tag == "Inimigo")
  39.         {
  40.             if(posicaoPlayer < posicaoInimigo)
  41.             {
  42.                 print ("VENCEU!!!!");
  43.             }
  44.             else
  45.             {
  46.                 print ("morreu, posiçao do pulo inimigo: " + posicaoInimigo + " --- Posiçao do player: " + posicaoPlayer);
  47.             }
  48.            
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement