Esempio n. 1
0
    void CtrlMobile()
    {
        if (!mobileIp)
        {
            return;
        }

        shootmobile     = false;
        changedirmobile = false;
        othersmobile    = false;     //jump

        foreach (Touch touch in Input.touches)
        {
            if (touch.phase == TouchPhase.Stationary && ShootMobCtrl.HitTest(touch.position))
            {
                shootmobile = true;
            }
            if (touch.phase == TouchPhase.Ended && ChangeDirMobCtrl.HitTest(touch.position))
            {
                changedirmobile = true;
            }
            //Not on any control
            if ((touch.phase == TouchPhase.Ended) && (!ShootMobCtrl.HitTest(touch.position) && !ChangeDirMobCtrl.HitTest(touch.position)))
            {
                othersmobile = true;
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began)
            {
                if (bt.HitTest(t.position, Camera.main))
                {
                    isButtonPressed = true;
                    currentLine++;
                }
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (bt.HitTest(Input.mousePosition, Camera.main))
            {
                isButtonPressed = true;
                currentLine++;
            }
        }

        if (isTrigShow)
        {
            GameObject.Find("bt").guiTexture.enabled = true;
        }
        else
        {
            GameObject.Find("bt").guiTexture.enabled = false;
        }
    }
Esempio n. 3
0
    private void OnTheGUI()
    {
        if (m_Button1.HitTest(Input.mousePosition))
        {
            m_Button1.GetComponent <ChangeTextureHover>().ChangeToHoverTexture();
        }
        else
        {
            m_Button1.GetComponent <ChangeTextureHover>().ChangeBack();
        }
        if (m_Button2.HitTest(Input.mousePosition))
        {
            m_Button2.GetComponent <ChangeTextureHover>().ChangeToHoverTexture();
        }
        else
        {
            m_Button2.GetComponent <ChangeTextureHover>().ChangeBack();
        }

        if (m_Button1.HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            EndMenu();
            RasmusGameSave.SaveLevel();
            Application.LoadLevel(m_Scene);
        }
        if (m_Button2.HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            EndMenu();
        }
    }
Esempio n. 4
0
    void Update()
    {
        if (Input.touchCount > 0)
        {
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch t = Input.GetTouch(i);
                if (t.phase == TouchPhase.Began)
                {
                    if (guiLeft.HitTest(t.position, Camera.main))
                    {
                        Debug.Log("Touching Left Control");
                        moveLeft = true;
                    }
                    if (guiRight.HitTest(t.position, Camera.main))
                    {
                        Debug.Log("Touching Right Control");
                        moveRight = true;
                    }

                    // Are we touching the jump button?
                    if (guiJump.HitTest(t.position, Camera.main))
                    {
                        Debug.Log("Touching Jump Control");
                        doJump = true;
                    }
                }
                if (t.phase == TouchPhase.Ended)
                {
                    // Stop all movement
                    doJump = moveLeft = moveRight = false;
                    rigidbody2D.velocity = Vector2.zero;
                }
            }
        }
        if (Input.GetMouseButtonDown(0))
        {
            if (guiLeft.HitTest(Input.mousePosition, Camera.main))
            {
                Debug.Log("Touching Left Control");
                moveLeft = true;
            }
            if (guiRight.HitTest(Input.mousePosition, Camera.main))
            {
                Debug.Log("Touching Right Control");
                moveRight = true;
            }
            if (guiJump.HitTest(Input.mousePosition, Camera.main))
            {
                Debug.Log("Touching Jump Control");
                doJump = true;
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            doJump = moveLeft = moveRight = false;
            rigidbody2D.velocity = Vector2.zero;
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        //displays ability power if hit in air by player
        ShowPower();

        //if ability loaded and displayed , on touch is activated
        if (!Desktop)
        {
            foreach (Touch touch in Input.touches)
            {
                if (Input.touchCount > 0)
                {
                    if (gui.HitTest(touch.position))
                    {
                        EnablePower();
                    }
                }
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0) && gui.HitTest(Input.mousePosition) || Input.GetMouseButton(0) && gui.HitTest(Input.mousePosition))
            {
                EnablePower();
            }
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if (!alku && Vector2.Distance(transform.position, pallo.transform.position) > 1f)
        {
            lataa.enabled = false;
        }
        else
        {
            lataa.enabled = true;
        }


        if (Input.GetKey("space") && (alku) && Vector2.Distance(transform.position, alkupaikka) < 4.5f)
        {
            transform.Translate(Vector3.down * 3f * Time.deltaTime);
        }

        if (Input.GetKeyUp("space"))
        {
            if (alku)
            {
                pallo.rigidbody2D.AddForce(Vector2.up * 5, ForceMode2D.Impulse);
            }
            alku = false;
            rigidbody2D.isKinematic         = false;
            pallo.collider2D.sharedMaterial = bounce;
        }

        if (Vector2.Distance(transform.position, alkupaikka) < 0.1f)
        {
            rigidbody2D.isKinematic = true;
        }

        if (Input.touchCount > 0)
        {
            int i;

            for (i = 0; i < Input.touchCount; i++)
            {
                Touch touch = Input.GetTouch(i);


                if (lataa.HitTest(touch.position) && touch.phase == TouchPhase.Stationary && (alku) && Vector2.Distance(transform.position, alkupaikka) < 4.5)
                {
                    transform.Translate(Vector3.down * 3f * Time.deltaTime);
                }
                if (lataa.HitTest(touch.position) && touch.phase == TouchPhase.Ended)
                {
                    if (alku)
                    {
                        pallo.rigidbody2D.AddForce(Vector2.up * 5, ForceMode2D.Impulse);
                    }
                    alku = false;
                    rigidbody2D.isKinematic         = false;
                    pallo.collider2D.sharedMaterial = bounce;
                }
            }
        }
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        GUI.depth = 0;
        isPressed = false;
        bool hitTest = false;

        foreach (Touch touch in Input.touches)
        {
            hitTest = guitex.HitTest(touch.position);
            if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved)
            {
                if (hitTest)
                {
                    guitex.texture = pressedTex;
                    isTouchDown    = true;
                }
                else
                {
                    if (touch.phase == TouchPhase.Moved)
                    {
                        guitex.texture = normalTex;
                    }
                }
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                if (hitTest)
                {
                    guitex.texture = normalTex;
                    if (isTouchDown)
                    {
                        isPressed = true;
                    }
                    isTouchDown = false;
                }
            }
        }
        hitTest = guitex.HitTest(Input.mousePosition);
        if (hitTest)
        {
            if (Input.GetMouseButton(0))
            {
                guitex.texture = pressedTex;
                isTouchDown    = true;
                isPressed      = false;
            }

            if (Input.GetMouseButtonUp(0))
            {
                guitex.texture = normalTex;
                if (isTouchDown)
                {
                    isPressed = true;
                    GUIAudioManager.Instance.PlayButtonClickedSfx(this.transform.position, 1.0f);
                }
                isTouchDown = false;
            }
        }
    }
Esempio n. 8
0
 public void touchInput(GUITexture texture)
 { 
     if (Input.touchCount > 0)
 { 
         if (texture.HitTest(Input.GetTouch(0).position))
 { 
             switch (Input.GetTouch(0).phase)
 { 
                 case TouchPhase.Began:
     //do stuff 
     SendMessage("OnFirstTouchBegan",SendMessageOptions.DontRequireReceiver);
     SendMessage("OnFirstTouch",SendMessageOptions.DontRequireReceiver);
     guiTouch = true; 
     break; 
     case TouchPhase.Stationary: 
     //do stuff
     SendMessage("OnFirstTouchStayed",SendMessageOptions.DontRequireReceiver);
     SendMessage("OnFirstTouch",SendMessageOptions.DontRequireReceiver);
     guiTouch = true; 
     break;
     case TouchPhase.Moved:
     //do stuff 
     SendMessage("OnFirstTouchMoved",SendMessageOptions.DontRequireReceiver);
     SendMessage("OnFirstTouch",SendMessageOptions.DontRequireReceiver);
     guiTouch = true;
     break;
     case TouchPhase.Ended:
     //do stuff 
     SendMessage("OnFirstTouchEnded",SendMessageOptions.DontRequireReceiver);
     guiTouch = false;
     break; } } } 
     if (Input.touchCount > 1)
     { 
         if (texture.HitTest(Input.GetTouch(1).position))
     { 
             switch (Input.GetTouch(1).phase)
     { 
                 case TouchPhase.Began:
         //do stuff 
         SendMessage("OnSecondTouchBegan",SendMessageOptions.DontRequireReceiver); 
         SendMessage("OnSecondTouch",SendMessageOptions.DontRequireReceiver); 
         break; 
         case TouchPhase.Stationary:
         //do stuff 
         SendMessage("OnSecondTouchStayed",SendMessageOptions.DontRequireReceiver);
         SendMessage("OnSecondTouch",SendMessageOptions.DontRequireReceiver);
         break; 
         case TouchPhase.Moved: 
         //do stuff 
         SendMessage("OnSecondTouchMoved",SendMessageOptions.DontRequireReceiver);
         SendMessage("OnSecondTouch",SendMessageOptions.DontRequireReceiver); 
         break; 
         case TouchPhase.Ended: 
         //do stuff 
         SendMessage("OnSecondTouchEnded",SendMessageOptions.DontRequireReceiver); break; 
     }
     }
     }
 }
Esempio n. 9
0
    void Update()
    {
        if (touchDriveManager == null)
        {
            return;
        }
        if (ButtonTexture == null)
        {
            return;
        }
        if (AlphaValue < 0)
        {
            AlphaValue = 0;
        }

        if (touchDriveManager.TouchBank != null)
        {
            foreach (TouchItemData touch in touchDriveManager.TouchBank)
            {
                if (ButtonTexture.HitTest(touch.Position))
                {
                    TouchData = touch;
                    break;
                }
            }
        }

        if (OneShot && !canTouchAgain)
        {
            ButtonState = ButtonTouchState.Released;
            IsPressed   = false;
        }

        if (TouchData != null)
        {
            if (TouchData.Phase == TouchPhase.Stationary && ButtonTexture.HitTest(TouchData.Position) && canTouchAgain)
            {
                ButtonState = ButtonTouchState.Pressed;
                IsPressed   = true;
                ChangeAlpha(ButtonTexture, true);

                if (OneShot)
                {
                    canTouchAgain = false;
                }
            }
            else if (TouchData.Phase == TouchPhase.Ended)
            {
                ButtonState = ButtonTouchState.Released;
                IsPressed   = false;
                ChangeAlpha(ButtonTexture, false);
                TouchData = null;
            }
        }
        else
        {
            canTouchAgain = true;
        }
    }
Esempio n. 10
0
    public void TouchInput(GUITexture texture)
    {
        if (texture.HitTest(Input.GetTouch(0).position))
        {
            switch (Input.GetTouch(0).phase)
            {
            case TouchPhase.Began:
                SendMessage("OnFirstTouchBegan");
                SendMessage("OnFirstTouch");
                guiTouch = true;
                break;

            case TouchPhase.Stationary:
                SendMessage("OnFirstTouchStationary");
                SendMessage("OnFirstTouch");
                guiTouch = true;
                break;

            case TouchPhase.Moved:
                SendMessage("OnFirstTouchMoved");
                SendMessage("OnFirstTouch");
                guiTouch = true;
                break;

            case TouchPhase.Ended:
                SendMessage("OnFirstTouchEnded");
                SendMessage("OnFirstTouch");
                guiTouch = false;
                break;
            }
        }
        if (texture.HitTest(Input.GetTouch(1).position))
        {
            switch (Input.GetTouch(1).phase)
            {
            case TouchPhase.Began:
                SendMessage("OnSecondaryTouchBegan");
                SendMessage("OnSecondaryTouch");
                break;

            case TouchPhase.Stationary:
                SendMessage("OnSecondaryStationary");
                SendMessage("OnSecondaryTouch");
                break;

            case TouchPhase.Moved:
                SendMessage("OnSecondaryTouchMoved");
                SendMessage("OnSecondaryTouch");
                break;

            case TouchPhase.Ended:
                SendMessage("OnSecondaryTouchEnded");
                SendMessage("OnSecondaryTouch");
                break;
            }
        }
    }
Esempio n. 11
0
    public void TouchInput(GUITexture texture)
    {
        if (texture.HitTest(Input.GetTouch(0).position))
        {
            switch (Input.GetTouch(0).phase)
            {
                case TouchPhase.Began:
                    SendMessage("OnFirstTouchBegan");
                    SendMessage("OnFirstTouch");
                    guiTouch = true;
                    break;
                case TouchPhase.Moved:
                    SendMessage("OnFirstTouchMoved");
                    SendMessage("OnFirstTouch");
                    guiTouch = true;
                    break;
                case TouchPhase.Stationary:
                    SendMessage("OnFirstTouchStayed");
                    SendMessage("OnFirstTouch");
                    guiTouch = true;
                    break;
                case TouchPhase.Ended:
                    SendMessage("OnFirstTouchEnded");
                    guiTouch = true;
                    break;
            }

        }
        if (texture.HitTest(Input.GetTouch(0).position))
        {
            switch (Input.GetTouch(1).phase)
            {
                case TouchPhase.Began:
                    SendMessage("OnSecondTouchBegan");
                    SendMessage("OnSecondTouch");
                    break;
                case TouchPhase.Moved:
                    SendMessage("OnSecondTouchMoved");
                    SendMessage("OnSecondTouch");
                    break;
                case TouchPhase.Stationary:
                    SendMessage("OnSecondTouchStayed");
                    SendMessage("OnSecondTouch");
                    break;
                case TouchPhase.Ended:
                    SendMessage("OnSecondTouchEnded");
                    break;
            }

        }
    }
Esempio n. 12
0
 private void CheckMouseInput()
 {
     if (Input.GetMouseButton(0))
     {
         pressed            = (Level1Selected.HitTest(Input.mousePosition) || Level2Selected.HitTest(Input.mousePosition) || Level3Selected.HitTest(Input.mousePosition) || Level4Selected.HitTest(Input.mousePosition) || BackButton.HitTest(Input.mousePosition) || StartLevel.HitTest(Input.mousePosition));
         level1Pointed      = Level1Selected.HitTest(Input.mousePosition);
         level2Pointed      = Level2Selected.HitTest(Input.mousePosition);
         level3Pointed      = Level3Selected.HitTest(Input.mousePosition);
         level4Pointed      = Level4Selected.HitTest(Input.mousePosition);
         startButtonPressed = StartLevel.HitTest(Input.mousePosition);
         backButtonPressed  = BackButton.HitTest(Input.mousePosition);
         ProcessButtonPress();
     }
 }
Esempio n. 13
0
    void Update()
    {
        //check for ui touch and flip sound on/off if so


        foreach (Touch t in Input.touches)
        {
            if ((soundon.HitTest(t.position) == true) && (t.phase == TouchPhase.Began) && (soundon.enabled == true))
            {
                soundOff();
                return;
            }

            if ((soundoff.HitTest(t.position) == true) && (t.phase == TouchPhase.Began))
            {
                soundOn();
                return;
            }
        }


        if (Input.GetMouseButtonDown(0))
        {
            //check if we hit sound on or sound off with mouse
            if (soundon.HitTest(Input.mousePosition) && (soundon.enabled == true))
            {
                soundOff();
                return;
            }

            if (soundoff.HitTest(Input.mousePosition))
            {
                soundOn();
                return;
            }

            //this.guiText.text="Pressed left click.";
            Application.LoadLevel("pongGameScene");
            //debugText.text = "mbd";
        }

        /*
         * if (Input.GetMouseButtonDown(1))
         *      this.guiText.text="Pressed right click.";
         *
         * if (Input.GetMouseButtonDown(2))
         *      this.guiText.text="Pressed middle click.";
         */
    }
Esempio n. 14
0
    void Update()
    {
        _gunon_ = _GunOn.name;                        //
        _idle_  = _Idle.name;                         // get name of animation
        _shoot_ = _Attack.name;                       //

        GetComponent <Animation>().CrossFade(_idle_); // play animation "idle"

        int count = Input.touchCount;

        for (int i = 0; i < count; i++)
        {
            Touch touch = Input.GetTouch(i);

            if (shat.HitTest(touch.position) & touch.phase == TouchPhase.Stationary) //if shoot
            {
                GetComponent <Animation>().Play(_shoot_);                            // play animation shoot
                col.SetActive(true);                                                 // activation knife collider
            }
            else
            {
                col.SetActive(false);//deactivation knife collider
            }
        }
    }
Esempio n. 15
0
 private void CheckMouseInput()
 {
     if (Input.GetMouseButton(0))
     {
         pressed = (highlightedButton.isHighlighted && button.HitTest(Input.mousePosition));
     }
 }
Esempio n. 16
0
 void Update()
 {
     if (Input.touches.Length > 0)
     {
         for (int i = 0; i < Input.touches.Length; i++)
         {
             if (tex.HitTest(Input.GetTouch(i).position))
             {
                 if (Input.GetTouch(i).phase == TouchPhase.Began)
                 {
                     shootbuttondown = true;
                     shootingstart   = true;
                     deltatime       = 0;
                 }
                 else
                 {
                     shootbuttondown = false;
                 }
             }
         }
     }
     if (shootingstart)
     {
         deltatime += 0.1f;
         if (deltatime > 3)
         {
             Invoke("reshooting", 0.5f);
         }
     }
 }
Esempio n. 17
0
	// Update is called once per frame
	void Update () {
		if(Time.timeScale > 0){ // can only shoot if not paused
			
			// Shield usage
			if(Input.GetMouseButton(0) && useShieldButton.HitTest(Input.mousePosition)){
				if(shieldIsUp == false){
					if(useShieldButton.name == "UseShield"){
						shieldIsUp = true;
						PlayerPrefs.SetInt ( "shieldUp", 1);
						shield.transform.Translate(shieldMoveVector, Camera.main.transform);
						
						if(gunDisplayScript.currentSelection.Equals ("Pistol")){
							reloading = true; // let the script know that we are reloading
							StartCoroutine(PistolReload()); // call this method
						}
						else if(gunDisplayScript.currentSelection.Equals ("HMG")){
							reloading = true; // let the script know that we are reloading
							StartCoroutine(HMGReload()); // call this method
						}
						else if(gunDisplayScript.currentSelection.Equals ("Shotgun")){
							reloading = true; // let the script know that we are reloading
							StartCoroutine(ShotgunReload()); // call this method
						}
					}
				}
			}
			else if(Input.GetMouseButtonUp(0)){
				if(shieldIsUp == true){
					shieldIsUp = false;
					PlayerPrefs.SetInt ( "shieldUp", 0);
					shield.transform.Translate(-shieldMoveVector, Camera.main.transform);
				}
			}
		}
	}
Esempio n. 18
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && texture.HitTest(Input.mousePosition))
     {
         Application.LoadLevel("StartLevel");
     }
 }
Esempio n. 19
0
    // Update is called once per frame
    void Update()
    {
        int count = Input.touchCount;            //获取触摸点的数量

        for (int i = 0; i < count; i++)          //逐个分析触摸点的操作
        {
            Touch touch = Input.GetTouch(i);     //获取当前处理的触摸点
            //将当前的触摸坐标转换为屏幕坐标
            Vector2 currentTouchPos = new Vector2(touch.position.x / Screen.width - centerBall.pixelInset.size.x / 2 / Screen.width,
                                                  touch.position.y / Screen.height - centerBall.pixelInset.size.y / 2 / Screen.height);

            Vector2 temp = currentTouchPos - centerPos;               //得到方向向量temp(触摸的位置和摇杆的坐标差)

            if (centerBall.HitTest(touch.position))                   //判断是否触摸点在要干范围之内
            {
                if (temp.magnitude < joyStickRadius)                  //如果方向向量temp的长度没有超出摇杆的半径,temp.magnitude为求坐标差的距离,及两点间的距离
//					lastFingerID = touch.fingerId;    //记录该触摸的id
                {
                    pressed = true;                        //摇杆移动开关打开
                    break;
                }
            }
            else
            {
                pressed = false;
            }
        }

        if (count == 0)
        {
            pressed = false;
        }
    }
Esempio n. 20
0
    public void receiveClickEvent(float x, float y, bool mouseInputMode = false)
    {
        for (int i = 0; i < GUIList.Length; ++i)
        {
            GUITexture gui = GUIList[i];

            if (gui.enabled == false || gui.gameObject.activeInHierarchy == false)
            {
                continue;
            }

            Vector3 screenPoint = new Vector3(x, y, gui.transform.position.z);

            if (false == mouseInputMode)
            {
                screenPoint = Camera.main.ViewportToScreenPoint(screenPoint);
            }

            if (gui.HitTest(screenPoint))
            {
                GUIEvent guiEvent = gui.GetComponent <GUIEvent>();

                if (guiEvent != null)
                {
                    guiEvent.onClickEvent(x, y);

                    if (clickAudio)
                    {
                        AudioSource.PlayClipAtPoint(clickAudio, transform.position, 1.0f);
                    }
                }
            }
        }
    }
Esempio n. 21
0
    private void UpdateTouch()
    {
        for (var i = 0; i < Input.touchCount; i++)
        {
            var touch = Input.GetTouch(i);

            if (currentFinger == -1 && cover.HitTest(touch.position))
            {
                currentFinger = touch.fingerId;
                OnTouchStart(touch);
                break;
            }

            if (currentFinger != touch.fingerId)
            {
                continue;
            }

            switch (touch.phase)
            {
            case TouchPhase.Moved:
                OnTouchMove(touch);
                break;

            case TouchPhase.Ended:
                OnTouchEnd(touch);
                currentFinger = -1;
                break;
            }
            break;
        }
    }
Esempio n. 22
0
 // Update is called once per frame
 void Update()
 {
     //當滑鼠點擊選單時
     if (Input.GetMouseButtonDown(0))
     {
         if (menuHome.HitTest(Input.mousePosition))
         {
             menuHome.texture = menuHomeTextureMouseDown;
         }
         else if (menuRestart.HitTest(Input.mousePosition))
         {
             menuRestart.texture = menuRestartTextureMouseDown;
         }
         else if (menuSetup.HitTest(Input.mousePosition))
         {
             menuSetup.texture = menuSetupTextureMouseDown;
         }
         else if (menuInformation.HitTest(Input.mousePosition))
         {
             menuInformation.texture = menuInformationTextureMouseDown;
         }
     }
     //滑鼠放開後更換回正常圖示
     else if (Input.GetMouseButtonUp(0))
     {
         menuHome.texture        = menuHomeTextureNormal;
         menuRestart.texture     = menuRestartTextureNormal;
         menuSetup.texture       = menuSetupTextureNormal;
         menuInformation.texture = menuInformationTextureNormal;
     }
 }
Esempio n. 23
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch t = Input.GetTouch(0);

            /*
             * if (t.phase == TouchPhase.Began) {
             *      if (bt.HitTest (t.position, Camera.main)) {
             *
             *      }
             * }
             */
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (Invi.HitTest(Input.mousePosition, Camera.main))
            {
                isButtonPressedNPC = true;
                currentLineDia1++;
                currentLine++;
            }
        }
    }
Esempio n. 24
0
    //更新按钮状态,选中按钮,返回它的ID
    public int UpdateState(bool mouse, Vector3 mousepos)
    {
        int result = -1;

        if (m_textture.HitTest(mousepos))
        {
            if (mouse)
            {
                SetState(StateID.ACTIVE);
                return(m_ID);
            }
            else
            {
                SetState(StateID.FOCUS);
            }
        }
        else
        {
            if (m_isOnActiv)
            {
                SetState(StateID.ACTIVE);
            }
            else
            {
                SetState(StateID.NORMAL);
            }
        }
        return(result);
    }
Esempio n. 25
0
    //call when the screen is touched/clicked
    void Pressed(Vector2 pos)
    {
        //set a zero vector
        Vector3 moveDir = Vector3.zero;

        //if any of the button is pressed, set the corresponding  move direction
        if (up.HitTest(pos))
        {
            moveDir += new Vector3(0, 0, 1);
        }
        if (down.HitTest(pos))
        {
            moveDir += new Vector3(0, 0, -1);
        }
        if (left.HitTest(pos))
        {
            moveDir += new Vector3(-1, 0, 0);
        }
        if (right.HitTest(pos))
        {
            moveDir += new Vector3(1, 0, 0);
        }

        //normalized the total moveDir
        moveDir = moveDir.normalized;

        //move the controlObject according to the input move direction
        controlObject.Translate(moveDir * Time.deltaTime * 3);
    }
Esempio n. 26
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began)
            {
                if (Object1.HitTest(t.position, Camera.main))
                {
                    ButtonPresssed = true;
                    currentLine1++;
                }
            }
        }
        if (currentLine1 == 7)
        {
            Object1.GetComponent <GUITexture>().enabled = false;
            Object2.GetComponent <GUITexture>().enabled = true;
            Object3.GetComponent <GUITexture>().enabled = false;
        }
        if (currentLine1 == 9)
        {
            Object1.GetComponent <GUITexture>().enabled = false;
            Object2.GetComponent <GUITexture>().enabled = false;
            Object3.GetComponent <GUITexture>().enabled = true;
        }
    }
Esempio n. 27
0
    //Controls for the car
    private void ControlCar()
    {
        // Compute the speed based on RPM
        float currentSpeed = Mathf.Round(2 * Mathf.PI * wheelRL.radius * wheelRL.rpm / 60 * 100);


        // Input for Android
        float multiplySpeedFactor = 0;

        if (Input.GetMouseButton(0) && AcceleratePedal.HitTest(Input.mousePosition))
        {
            multiplySpeedFactor = 1;
        }

        if (Input.GetMouseButton(0) && BreakPedal.HitTest(Input.mousePosition))
        {
            multiplySpeedFactor = -1;
        }


        if (currentSpeed < topSpeed)
        {
            // Apply Torque to move the car
            //wheelRL.motorTorque = maxTorque * Input.GetAxis("Vertical");
            //wheelRR.motorTorque = maxTorque * Input.GetAxis("Vertical");
            wheelRL.motorTorque = maxTorque * multiplySpeedFactor;
            wheelRR.motorTorque = maxTorque * multiplySpeedFactor;
        }
        else
        {
            // No more torque is over the speed limit
            wheelRL.motorTorque = 0;
            wheelRR.motorTorque = 0;
        }

        // Decelerate when not pressing any keys
        if (Input.GetButton("Vertical") == false)
        {
            wheelRR.brakeTorque = decelarationSpeed;
            wheelRL.brakeTorque = decelarationSpeed;
        }
        else
        {
            wheelRR.brakeTorque = 0;
            wheelRL.brakeTorque = 0;
        }


        float speedFactor       = rigidbody.velocity.magnitude / highestSpeed;
        float currentSteerAngle = Mathf.Lerp(lowSpeedSteerAngle, highSpeedSteerAngle, speedFactor);


        currentSteerAngle *= Input.acceleration.x * 10;

        // Apply Steering
        wheelFL.steerAngle = currentSteerAngle;
        wheelFR.steerAngle = currentSteerAngle;
    }
Esempio n. 28
0
    public void UpdateTouchInput()
    {
        if (Input.touchCount == 0)
        {
            inputGUI_h            = 0.0f;
            inputGUI_v            = 0.0f;
            Tex_TurnLeft.texture  = Resources.Load("UI/btn-left-normal") as Texture2D;
            Tex_TurnRight.texture = Resources.Load("UI/btn-right-normal") as Texture2D;
            Tex_Jump.texture      = Resources.Load("UI/btn-jump-normal") as Texture2D;
        }

        for (int i = 0; i < Input.touchCount; i++)
        {
            Touch current = Input.GetTouch(i);

            if (Tex_Jump.HitTest(current.position))
            {
                //Debug.Log("Double");
                inputGUI_v       = speed_v;
                Tex_Jump.texture = Resources.Load("UI/btn-jump-clicked") as Texture2D;
            }
            else
            {
                inputGUI_v       = 0.0f;
                Tex_Jump.texture = Resources.Load("UI/btn-jump-normal") as Texture2D;
            }

            if (Tex_TurnLeft.HitTest(current.position))
            {
                inputGUI_h           = -speed_h;
                Tex_TurnLeft.texture = Resources.Load("UI/btn-left-clicked") as Texture2D;
            }
            else
            {
                Tex_TurnLeft.texture = Resources.Load("UI/btn-left-normal") as Texture2D;
            }

            if (Tex_TurnRight.HitTest(current.position))
            {
                inputGUI_h            = speed_h;
                Tex_TurnRight.texture = Resources.Load("UI/btn-right-clicked") as Texture2D;
            }
            else
            {
                Tex_TurnRight.texture = Resources.Load("UI/btn-right-normal") as Texture2D;
            }

            if (current.phase == TouchPhase.Ended && Tex_HPLeft.HitTest(current.position))
            {
                UpdateHP(--HPLeft, -1);
            }

            if (current.phase == TouchPhase.Ended && Tex_HPRight.HitTest(current.position))
            {
                UpdateHP(++HPRight, -1);
            }
        }
    }
Esempio n. 29
0
    public void Button(GUITexture button, int callButton)
    {
        if (button != null)
        {
            if (button.HitTest(Input.mousePosition))
            {
                if (button.color.a <= 0.2f)
                    fadeButton = true;
                if (button.color.a >= 0.4f)
                    fadeButton = false;

                if (!fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a - 0.55f * Time.deltaTime);
                }

                if (fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.55f * Time.deltaTime);
                }

                if (Input.GetMouseButtonDown(0))
                {
                    switch (callButton)
                    {
                        case 0:
                            DestroyInterface();
                            SceneManager.Instance.scene.CloseScene();
                            SceneManager.Instance.ChangeLevelCampaignMode(1);
                            break;

                        case 1:
                            DestroyInterface();
                            break;

                        case 2:
                            DestroyInterface();
                            SceneManager.Instance.scene.CloseScene();
                            SceneManager.Instance.ChangeMenu(0);
                            break;
                    }
                    SceneManager.Instance.paused = !SceneManager.Instance.paused;
                }

            }
            else if (button.color.a < 0.5f)
            {
                button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.45f * Time.deltaTime);
            }
        }
    }
Esempio n. 30
0
    void Raycasting()
    {
        Debug.DrawLine(lineStart.position, lineEnd.position, Color.green);
        Debug.DrawLine(this.transform.position, groundedEnd.position, Color.green);
        Debug.DrawLine(this.transform.position, groundedLeft.position, Color.green);
        Debug.DrawLine(this.transform.position, groundedRight.position, Color.green);

        if (Physics2D.Linecast(this.transform.position, groundedEnd.position, 1 << LayerMask.NameToLayer("Ground")) ||
            Physics2D.Linecast(this.transform.position, groundedLeft.position, 1 << LayerMask.NameToLayer("Ground")) ||
            Physics2D.Linecast(this.transform.position, groundedRight.position, 1 << LayerMask.NameToLayer("Ground")))
        {
            Grounded = true;
        }
        else
        {
            Grounded = false;
        }


        if (Physics2D.Linecast(lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer("Guard")))
        {
            WhatIHit = Physics2D.Linecast(lineStart.position, lineEnd.position, 1 << LayerMask.NameToLayer("Guard"));
            Interact = true;
        }
        else
        {
            Interact = false;
        }
        foreach (Touch touch in Input.touches)
        {
            if (touch.phase == TouchPhase.Began && AttackButton.HitTest(touch.position))
            {
                if (Grounded == true)
                {
                    if (NextAttack < Time.time)
                    {
                        this.gameObject.GetComponent <Animator>().SetTrigger("HurlAttack");
                        GetComponent <AudioSource>().PlayOneShot(HitSound);
                        NextAttack = Time.time + AttackDelay;
                        if (SceneManager.GetActiveScene().Equals("Level8"))
                        {
                            WhatIHit.collider.gameObject.GetComponent <GuardLogicLevel10>().RecieveDamage(AttackStrength);
                        }
                        if (SceneManager.GetActiveScene().Equals("Level10"))
                        {
                            WhatIHit.collider.gameObject.GetComponent <BossScript>().RecieveDamage(25);
                        }
                        else
                        {
                            WhatIHit.collider.gameObject.GetComponent <GuardLogicNormal>().RecieveDamage(AttackStrength);
                        }
                    }
                }
            }
        }
        Physics2D.IgnoreLayerCollision(8, 9);
    }
Esempio n. 31
0
    void Update()
    {
//		int i = 0;
        if (Input.touchCount > 0)
        {
            for (int i = 0; i < Input.touchCount; i++)
            {
//			if(moveLeft.HitTest(Input.GetTouch(i).position, Camera.main))
//			{
//				if(Input.touchCount > 0)
//				{
//					playerMove.MoveLeft();
//				}
//			}
//			if(moveRight.HitTest(Input.GetTouch(i).position, Camera.main))
//			{
//				if(Input.touchCount > 0)
//				{
//					playerMove.MoveRight();
//				}
//			}
//			if(moveLeft.HitTest(Input.GetTouch(i).position, Camera.main))
//			{
//				if(Input.touchCount > 0)
//				{
//					CallFire();
//				}
//			}
                Touch t = Input.GetTouch(i);
                Input.multiTouchEnabled = true;

                if (t.phase == TouchPhase.Began || t.phase == TouchPhase.Stationary)
                {
                    if (moveLeft.HitTest(t.position, Camera.main))
                    {
                        playerMove.MoveLeft();
                    }
                    if (moveRight.HitTest(t.position, Camera.main))
                    {
                        playerMove.MoveRight();
                    }
                }
                if (t.phase == TouchPhase.Began)
                {
                    if (fire.HitTest(t.position, Camera.main))
                    {
                        CallFire();
                    }
                }


                if (t.phase == TouchPhase.Ended)
                {
                }
            }
        }
    }
Esempio n. 32
0
 void Update()
 {
     if (allowNoticeAutoHiding && noticeVisible && ((Input.touchCount > 0 && notice.HitTest(Input.GetTouch(0).position)) ||
                                                    Input.GetKeyDown(KeyCode.Escape) ||
                                                    (Input.GetMouseButtonDown(0) && notice.HitTest(Input.mousePosition))))
     {
         HideNotification();
     }
 }
Esempio n. 33
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && texture.HitTest(Input.mousePosition))
     {
         start.SetActive(true);
         load.SetActive(true);
         confirm.SetActive(false);
     }
 }
Esempio n. 34
0
    public void ButtonBackToMainMenu(GUITexture button)
    {
        if (button != null)
        {
            if (button.HitTest(Input.mousePosition))
            {
                if (button.color.a <= 0.2f)
                    fadeButton = true;
                if (button.color.a >= 0.4f)
                    fadeButton = false;

                if (!fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a - 0.55f * Time.deltaTime);
                }

                if (fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.55f * Time.deltaTime);
                }

                if (Input.GetMouseButtonDown(0))
                {
                    SceneManager.Instance.ChangeMenu(0);
                    CloseScene();
                }

            }
            else if (button.color.a < 0.5f)
            {
                button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.45f * Time.deltaTime);
            }
        }
    }
Esempio n. 35
0
    /// <summary>
    /// 0 for Campaign Mode
    /// 1 for Survive Mode
    /// 2 for Instructions
    /// 3 for Ranking
    /// 4 for Credits
    /// 5 for Quit the game
    /// </summary>
    /// <param name="button">Button to get the effect and call a scene</param>
    /// <param name="callButton">int number for choose the scene to be changed</param>
    public void Button(GUITexture button, int callButton)
    {
        if (button != null)
        {
            if (button.HitTest(Input.mousePosition))
            {
                if (button.color.a <= 0.2f)
                    fadeButton = true;
                if (button.color.a >= 0.4f)
                    fadeButton = false;

                if (!fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a - 0.55f * Time.deltaTime);
                }

                if (fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.55f * Time.deltaTime);
                }

                if (Input.GetMouseButtonDown(0))
                {
                    switch (callButton)
                    {
                        case 0:
                            //Verify the last level played to call the next level
                            SceneManager.Instance.ChangeLevelCampaignMode(1);
                            break;

                        case 1:
                            SceneManager.Instance.ChangeScene(2);
                            break;

                        case 2:
                            SceneManager.Instance.ChangeMenu(1);
                            break;

                        case 3:
                            SceneManager.Instance.ChangeMenu(3);
                            break;

                        case 4:
                            SceneManager.Instance.ChangeMenu(2);
                            break;

                        case 5:
                            Application.Quit();
                            break;
                    }
                    CloseScene();
                }

            }
            else if (button.color.a < 0.5f)
            {
                button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.45f * Time.deltaTime);
            }
        }
    }
	void Update()
	{
		frontWheelStatic = frontWheelObject;
		backWheelStatic = backWheelObject;


		if (Application.loadedLevelName == "W1_Stage_1") {
			float timeLeft = endTime - Time.time;
			if (timeLeft < 0) {
				timeLeft = 0;
			}
			if (timeLeft == 0) {
				isControllable = true;
			} else {
				isControllable = false;
			}
		} else {
			float timeLeft = 0 - Time.time;
			if (timeLeft < 0) {
				timeLeft = 0;
			}
			if (timeLeft <= 0) {
				isControllable = true;
			} else {
				isControllable = false;
			}
		}
		if (crashed) {
			isControllable = false;
		}
		if (crashBurned) {
			isControllable = false;
		}
		if (crashDrowned) {
			isControllable = false;
		}
		
		if (isControllable) {
			if (!isFinish) {	
				RotateVehicle ();
				if (effect) {
					effect.SetActive (true);
					effect.transform.position = rearWheel.transform.position;
					effectstatic.transform.position = effect.transform.position;			
				}
				if (!crash && !crashed) {
			
					//if(Physics2D.Raycast(frontWheel.position,body.transform.position, out hit, (int)DistToCollided))
					if (Physics.Raycast (frontWheel.position, CarBody.transform.position, out hit, DistToCollided)) {
						if (ObjectToVelocity != null) {
							if (hit.collider.gameObject.name == ObjectToVelocity.name) {
								SpeedMotorMobile = speedSuper;
							}
						}
						if (ObjectToCollidedOne != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedOne.name) {
								DestroyBike ();					
							}
						}
						if (ObjectToCollidedTwo != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedTwo.name) {
								DestroyBike ();					
							}
						}
						if (ObjectToCollidedThree != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedThree.name) {
								DestroyBike ();					
							}
						}
						if (ObjectToCollidedFour != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedFour.name) {
								DestroyBike ();					
							}
						}
						if (ObjectToCollidedFive != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedFive.name) {
								DestroyBike ();					
							}
						}
						if (ObjectToCollidedSix != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedSix.name) {
								DestroyBike ();					
							}
						}
						if (ObjectToCollidedSeven != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedSeven.name) {
								DestroyBike ();					
							}
						}
						if (ObjectToCollidedEight != null) {
							if (hit.collider.gameObject.name == ObjectToCollidedEight.name) {
								DestroyBike ();					
							}
						}
					}
				
					//	GameObject weel = GameObject.Find ("front wheel").GetComponent<Collider>();
				
					//if (forMobile) {
					mobileButtons = GameObject.Find ("mobile buttons").transform;
				
					var touches = Input.touches;
				
					accelerate = false;
					brake = false;
					left = false;
					right = false;
					pause = false;
					restart = false;
					leftORright = false;							
				
				
					float angle = 360.0f; // Degree per time unit
					float time = 1.0f; // Time unit in sec
					Vector3 axis = Vector3.left; // Rotation axis, here it the yaw axis
				
					leftTexture = mobileButtons.FindChild ("left").GetComponent<GUITexture> ();
					rightTexture = mobileButtons.FindChild ("right").GetComponent<GUITexture> ();
				
					throttleTexture = mobileButtons.FindChild ("throttle").GetComponent<GUITexture> ();
					brakeTexture = mobileButtons.FindChild ("brake").GetComponent<GUITexture> ();
				
				
					leftTexture.enabled = false;
					rightTexture.enabled = false;
				
					leftTexture.enabled = true;
					rightTexture.enabled = true;
				
					throttleTexture.enabled = true;
					brakeTexture.enabled = true;
				
				
				
					foreach (var touch in touches) {	
					
						//if (touch.phase != TouchPhase.Canceled && touch.phase != TouchPhase.Ended) {																							
						if (throttleTexture.HitTest (touch.position)) //if touch position is inside throttle texture
						
							accelerate = true;
					
						if (brakeTexture.HitTest (touch.position)) //if touch position is inside brake texture
						
							brake = true;
					
					
					
						if (leftTexture.HitTest (touch.position)) //left button is touched
						
							left = true;
					
					
						if (rightTexture.HitTest (touch.position)) //right button is touched
						
							right = true;


						/*if (nitroTexture.HitTest (touch.position)) //if touch position is inside throttle texture
						
						ifnitro = true;
					*/
					
						//if (left || right) //left or right button is touched
						//	leftORright = true;						
						//}
					
					}
				
					if (Input.touchCount == 0) {
					
					}
					/*	
				if (Input.acceleration.x > RightAccelerometer) {
					setVerticalAxis (-1);
				} else if (Input.acceleration.x < RightAccelerometer) {
					setVerticalAxis (1);
				} else {
					setVerticalAxis (0);
				}
				*/
				
					//} else {
					//detect which keys are pressed. keys relevant to "Horizontal" and "Vertical" keywords are set in: Edit -> Project Settings -> Input
					if (!forMobile) {
						if (Input.GetAxisRaw ("Horizontal") != 0)
							leftORright = true;
						else
							leftORright = false;
					
						if (Input.GetAxisRaw ("Horizontal") > 0) {
							//setVerticalAxis(-1);
							right = true;
						} else {
							//setVerticalAxis(1);
							right = false;
						}
						if (Input.GetAxisRaw ("Horizontal") < 0) {
							left = true;
							//setVerticalAxis(1);
						} else {
							//setVerticalAxis(-1);
							left = false;
						}
						/*if (Input.GetKeyDown (KeyCode.Q)) {
						ifnitro = true;

					} else {

						ifnitro = false;
					}*/
						if (Input.GetAxisRaw ("Vertical") > 0 || Input.GetKey (KeyCode.Joystick1Button2))
							accelerate = true;
						else
							accelerate = false;				
					
						if (Input.GetAxisRaw ("Vertical") < 0 || Input.GetKey (KeyCode.Joystick1Button1))
							brake = true;
						else
							brake = false;	
					}
				
					//----------------------------------
					//}
				
				
					if (CarBody.transform.rotation.eulerAngles.z > 210 && CarBody.transform.rotation.eulerAngles.z < 220)					
						flip = true; 																						
				
					if (CarBody.transform.rotation.eulerAngles.z > 320 && flip) { //backflip is done
						if (my_game_uGUI) {
							my_game_uGUI.Update_int_score (setscore);
				
						
						}
						/*if(audioXP){
					audioXP.Play ();
					}*/
						AudioSource.PlayClipAtPoint (audioXP, gameObject.transform.position, 10.0f);

						flip = false;				
						backflipParticle.Emit (1);
					
					
						//	makeclick Achievement = new makeclick ();
						SENDACHIEVEMENT (ACHIEVEMENT_ID_First_BackFlip);

						SENDACHIEVEMENTINCREMENT (INCREMENTAL_ACHIEVEMENT_ID_Two_BackFlip, 1);

						//Reciver.SendMessage ("revealAchievement", ACHIEVEMENT_ID_First_BackFlip,SendMessageOptions.DontRequireReceiver);

						//score += 100;
						//scoreText.text = "SCORE : " + score;
					}
				
					if (CarBody.transform.rotation.eulerAngles.z < 30 && flip) { //frontflip is done			
						if (my_game_uGUI) {
							my_game_uGUI.Update_int_score (setscore);
						}
						/*if(audioXP){
					audioXP.Play ();
					}*/
						AudioSource.PlayClipAtPoint (audioXP, gameObject.transform.position, 10.0f);
						flip = false;
						frontflipParticle.Emit (1);
					
						//	makeclick Achievement = new makeclick ();
						SENDACHIEVEMENT (ACHIEVEMENT_ID_First_FrontFlip);
						SENDACHIEVEMENTINCREMENT (INCREMENTAL_ACHIEVEMENT_ID_Two_FrontFlip, 1);
						//	Reciver.SendMessage ("revealAchievement", INCREMENTAL_ACHIEVEMENT_ID_Two_FrontFlip,SendMessageOptions.DontRequireReceiver);
						//score += 150;	
						//scoreText.text = "SCORE : " + score;					
					}
				
				
					//changing engine sound pitch depending rear wheel rotational speed
					if (accelerate) {

						if (GetComponent<AudioSource> ().pitch < MaxPitch)
							GetComponent<AudioSource> ().pitch += ((Time.deltaTime) / TimeToIncrease);

						/*pitch = rearWheel.velocity.sqrMagnitude / Velocity;
					pitch *= Time.deltaTime * 2;
					pitch = Mathf.Clamp (pitch + 1, 0.5f, 1.8f);	*/
					} else {
						if (GetComponent<AudioSource> ().pitch > StartingPitch)
							GetComponent<AudioSource> ().pitch -= ((Time.deltaTime) / TimeToDecrease);

						/*pitch = audioSource.pitch;
					pitch = Mathf.Clamp (pitch - Time.deltaTime * 2, 0.5f, 1.8f);	*/															
					}
				
					//manipulating engine sound pitch
					//pitch = Mathf.Clamp (pitch - Time.deltaTime * 2, 0.5f, 1.8f);
					//pitch = Mathf.Clamp (pitch + Time.deltaTime * 2, 0.5f, 1.8f);
					//audioSource.pitch = pitch; 
					if (restart) {
						score = 0;
						Application.LoadLevel (Application.loadedLevel);
					}
					//if player is crashed and "R" is pressed or touch is detected on mobile, than restart current level
					if ((Input.GetKeyDown (KeyCode.R) || (Input.touchCount >= 2 && Input.GetTouch (0).phase == TouchPhase.Began)) && crashed) {
						score = 0;
						Application.LoadLevel (Application.loadedLevel);
					}
					/*if ((Input.GetKeyDown (KeyCode.X) || (Input.touchCount >= 2 && Input.GetTouch (0).phase == TouchPhase.Began))) {
				
						handling ("");
					}
					if (Input.GetKeyUp (KeyCode.X)) {

						unhandling ("");

						/*hingeJoints = Body2D.GetComponents<HingeJoint2D>();	
					StartCoroutine(Coroutine(4,0.40f));
					StartCoroutine(Coroutine(3,1.10f));
					StartCoroutine(Coroutine(1,1.50f));

					}*/


					if (pause) {
						{
							isShow = !isShow;
						}
					
						//*** Pause happens here. This code below is exactly what pauses the game.
						//Pause game if panel is shown.
						if (isShow)
							Time.timeScale = 0;
						else
							Time.timeScale = 1;
					}
					/*if (Checkpoint.lastPoint) {
					//if ((Input.GetKeyDown (KeyCode.C) || (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began)) && crashed) {
					if (checkpoint) {
					Checkpoint.Reset ();
					Destroy (gameObject);
					}
				}*/
				}
			
				if (crash && !crashed) { //if player just crashed											
					if (ifnitro) {
						effectnitro.SetActive (false);

					}
					//makeclick Achievement = new makeclick();
					SENDACHIEVEMENT (ACHIEVEMENT_ID_First_Death);

					//AN_PoupsProxy.showMessage ("Achievement unlocked","You Firts Death","Ok");
					//	Reciver.SendMessage ("revealAchievement", ACHIEVEMENT_ID_First_Death,SendMessageOptions.DontRequireReceiver);

					GameObject soul = (GameObject)Resources.Load ("prefabs/CFXM2_Soul", typeof(GameObject));
					Instantiate (soul, CarBody.transform.position, Quaternion.identity);
					GameObject explotion = (GameObject)Resources.Load ("prefabs/CFXM_Explosion+Text NoSmoke", typeof(GameObject));
					Instantiate (explotion, CarBody.transform.position, Quaternion.identity);
					GameObject smoke = (GameObject)Resources.Load ("prefabs/CFXM_GroundSmokeExplosionAlt", typeof(GameObject));
					Instantiate (smoke, CarBody.transform.position, Quaternion.identity);

					AudioSource.PlayClipAtPoint (BodyDeadSound, CarBody.transform.position, 10.0f);

					Camera.main.GetComponent<CameraFollow2D> ().target = CarBody.transform; //make camera to follow biker's hips	
				
					unhandlingToDestroy ();

					CarBody.transform.Rotate (Vector3.right * 180);

				
					isControllable = false;
					crashed = true;
					//update lives
					if (my_game_uGUI) {
						//my_game_uGUI.Update_lives(-1);
						Invoke ("endgui", 2.0f);
						//my_game_uGUI.Update_lives(live);
					}




				}
				if (crashBurn && !crashed) { //if player just crashed		
					if (ifnitro) {
						effectnitro.SetActive (false);
					}
					time = time + 1;
					effectburn.transform.position = CarBody.transform.position;
					if (time == 1) {
						//makeclick Achievement = new makeclick();
						SENDACHIEVEMENT (ACHIEVEMENT_ID_First_Burn);
						//	Reciver.SendMessage ("revealAchievement", ACHIEVEMENT_ID_First_Burn,SendMessageOptions.DontRequireReceiver);
						/*
					GameObject soul = (GameObject)Resources.Load("prefabs/CFXM2_Soul", typeof(GameObject));
					Instantiate(soul, CarBody.transform.position, Quaternion.identity);
					GameObject explotion = (GameObject)Resources.Load("prefabs/CFXM_Explosion+Text NoSmoke", typeof(GameObject));
					Instantiate(explotion, CarBody.transform.position, Quaternion.identity);
					GameObject smoke = (GameObject)Resources.Load("prefabs/CFXM_GroundSmokeExplosionAlt", typeof(GameObject));
					Instantiate(smoke, CarBody.transform.position, Quaternion.identity);
					*/


						CFX_SpawnSystem.Instantiate (effectburn);
						AudioSource.PlayClipAtPoint (BodyDeadBurnSound, CarBody.transform.position, 10.0f);
					
						Camera.main.GetComponent<CameraFollow2D> ().target = CarBody.transform; //make camera to follow biker's hips	
					
						//unhandlingToDestroy ();
					
						//CarBody.transform.Rotate (Vector3.right * 180);
					
					
						//isControllable = false;
						//crashed = true;
						//update lives
						if (my_game_uGUI) {
							//my_game_uGUI.Update_lives(-1);
							Invoke ("endguiburn", 2.0f);

						}
					}
				}
				if (crashDrown && !crashed) { //if player just crashed	
					if (ifnitro) {
						effectnitro.SetActive (false);
					}
					time = time + 1;
					//effectburn.transform.position = CarBody.transform.position;
					if (time == 1) {
						//makeclick Achievement = new makeclick();
						SENDACHIEVEMENT (ACHIEVEMENT_ID_First_Drown);
						//	Reciver.SendMessage ("revealAchievement", ACHIEVEMENT_ID_First_Burn,SendMessageOptions.DontRequireReceiver);
						/*
					GameObject soul = (GameObject)Resources.Load("prefabs/CFXM2_Soul", typeof(GameObject));
					Instantiate(soul, CarBody.transform.position, Quaternion.identity);
					GameObject explotion = (GameObject)Resources.Load("prefabs/CFXM_Explosion+Text NoSmoke", typeof(GameObject));
					Instantiate(explotion, CarBody.transform.position, Quaternion.identity);
					GameObject smoke = (GameObject)Resources.Load("prefabs/CFXM_GroundSmokeExplosionAlt", typeof(GameObject));
					Instantiate(smoke, CarBody.transform.position, Quaternion.identity);
					*/
					
					
						//CFX_SpawnSystem.Instantiate (effectburn);
						AudioSource.PlayClipAtPoint (BodyDeadDrownSound, CarBody.transform.position, 10.0f);
					
						Camera.main.GetComponent<CameraFollow2D> ().target = CarBody.transform; //make camera to follow biker's hips	
					
						//unhandlingToDestroy ();
					
						//CarBody.transform.Rotate (Vector3.right * 180);
					
					
						isControllable = false;
						//crashed = true;
						//update lives
						if (my_game_uGUI) {

							Invoke ("endguidrown", 2.0f);
						
						}
					}
				}
				if (crashSaw && !crashed) { //if player just crashed											
				
					//makeclick Achievement = new makeclick();
					SENDACHIEVEMENT (ACHIEVEMENT_ID_First_Death);

					//	Reciver.SendMessage ("revealAchievement", ACHIEVEMENT_ID_First_Death,SendMessageOptions.DontRequireReceiver);

					GameObject soul = (GameObject)Resources.Load ("prefabs/CFXM2_Soul", typeof(GameObject));
					Instantiate (soul, CarBody.transform.position, Quaternion.identity);
					GameObject explotion = (GameObject)Resources.Load ("prefabs/CFXM_Explosion+Text NoSmoke", typeof(GameObject));
					Instantiate (explotion, CarBody.transform.position, Quaternion.identity);
					GameObject smoke = (GameObject)Resources.Load ("prefabs/CFXM_GroundSmokeExplosionAlt", typeof(GameObject));
					Instantiate (smoke, CarBody.transform.position, Quaternion.identity);
				
					AudioSource.PlayClipAtPoint (BodyDeadSound, CarBody.transform.position, 10.0f);
				
					Camera.main.GetComponent<CameraFollow2D> ().target = CarBody.transform; //make camera to follow biker's hips	

					unhandlingToDestroy ();
				
					CarBody.transform.Rotate (Vector3.right * 180);
				
				
					isControllable = false;
					crashed = true;
					//update lives
					if (my_game_uGUI) {
						//my_game_uGUI.Update_lives(-1);
						Invoke ("endgui", 2.0f);
						//my_game_uGUI.Update_lives(live);
					}
				
				}
				if (crashSawHead && !crashed) { //if player just crashed											
				
					//makeclick Achievement = new makeclick();
					SENDACHIEVEMENT (ACHIEVEMENT_ID_First_Death);
					//Reciver.SendMessage ("revealAchievement", ACHIEVEMENT_ID_First_Death,SendMessageOptions.DontRequireReceiver);

					GameObject soul = (GameObject)Resources.Load ("prefabs/CFXM2_Soul", typeof(GameObject));
					Instantiate (soul, CarBody.transform.position, Quaternion.identity);
					GameObject explotion = (GameObject)Resources.Load ("prefabs/CFXM_Explosion+Text NoSmoke", typeof(GameObject));
					Instantiate (explotion, CarBody.transform.position, Quaternion.identity);
					GameObject smoke = (GameObject)Resources.Load ("prefabs/CFXM_GroundSmokeExplosionAlt", typeof(GameObject));
					Instantiate (smoke, CarBody.transform.position, Quaternion.identity);
				
					AudioSource.PlayClipAtPoint (BodyDeadSound, CarBody.transform.position, 10.0f);
				
					Camera.main.GetComponent<CameraFollow2D> ().target = CarBody.transform; //make camera to follow biker's hips	
				
					unhandlingToDestroySawHead ();
				
					CarBody.transform.Rotate (Vector3.right * 180);
				
				
					isControllable = false;
					crashed = true;
					//update lives
					if (my_game_uGUI) {
						//my_game_uGUI.Update_lives(-1);
						Invoke ("endgui", 2.0f);
						//my_game_uGUI.Update_lives(live);
					}
				
				}
			} else {
			//	brake = true;
			}
			
		} else {
			//brake=true;
		}
	

	
		/*
		Vector3 temp = SmokeEmmiter.force;
		temp.y = (SmokeEmmiter.force.y) * 0.5f;
		SmokeEmmiter.force = temp;*/
		//	transform.Translate(Input.acceleration.x, 0, -Input.acceleration.y);
		//SmokeEmmiter.force.y = Velocity * 20f;
	}