Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var offset:Vector3;
- var pos:Vector3;
- var cam :Camera;
- var fin :boolean;
- var init :Vector3;
- var timerText : UI.Text;
- var timerNumber : float;
- function Start () {
- fin=false;
- }
- function Update () {
- timerNumber -= Time.deltaTime;
- timerText.text = "Time left: "+timerNumber.ToString("0");
- if (timerNumber.ToString("0") == "0"){
- timerNumber = 0;
- SceneManager.LoadScene("game_over1");
- }
- }
- function OnMouseDown()
- {
- offset=transform.position-cam.main.ScreenToWorldPoint(Input.mousePosition);
- init=transform.position;
- }
- function OnMouseDrag()
- {
- if (fin==false){
- pos=cam.main.ScreenToWorldPoint(Input.mousePosition)+offset;
- transform.position=pos;
- }
- }
- function OnTriggerEnter2D(other:Collider2D)
- {
- if(other.gameObject.name=="g1"){
- fin=true ;
- transform.position=other.gameObject.transform.position;
- transform.position.z=-1;
- transform.position.y=1.97;
- transform.position.x=1.78;
- transform.localScale.x=0.4;
- transform.localScale.y=0.4;
- }
- if(other.gameObject.name=="g2"){
- fin=true ;
- transform.position=other.gameObject.transform.position;
- transform.position.z=-0.5;
- transform.position.y=-1.63;
- transform.position.x=1.89;
- transform.localScale.x=0.4;
- transform.localScale.y=0.4;
- }
- if(other.gameObject.name=="g3"){
- fin=true ;
- transform.position=other.gameObject.transform.position;
- transform.position.z=-1;
- transform.position.y=-1.66;
- transform.position.x=7.78;
- transform.localScale.x=0.4;
- transform.localScale.y=0.4;
- }
- }
- function OnMouseUp(){
- if( fin==false){
- transform.position=init;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement