コード例 #1
0
 public void setCharacterButton(CharacterSelectButton characterButton)
 {
     this.characterButton = characterButton;
 }
コード例 #2
0
    void Update()
    {
#if !UNITY_IOS
//####MOBILE exit button. IOS don't have an exit button
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            setPause(!gamePaused);
        }
#endif

#if UNITY_ANDROID || UNITY_WP8 || UNITY_IOS
//####MOBILE
        if (Input.touchCount == 1 && !pinching)
        {
            if (clickableArea.Contains(Input.GetTouch(0).position))
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    touchStarted = true;
                }

                if (touchStarted)
                {
                    dragTimePassed += Time.deltaTime;
                }

                //move camera mobile
                if (Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    touchMoved = true;
                    /*if(dragTimePassed >= dragThresholdTime){*/
                    cameraManager.DragCamera(DragMovement(Input.GetTouch(0)));
                    /*}*/
                }

                //move character mobile after threshold time

                /*
                 * if (touchStarted && !touchMoved && dragTimePassed >= dragThresholdTime) {
                 *      charactersManager.CheckClickedPoint(Input.GetTouch(0).position);
                 * }
                 */

                //move character mobile
                if (Input.GetTouch(0).phase == TouchPhase.Ended && !touchMoved /*&& dragTimePassed < dragThresholdTime*/)
                {
                    charactersManager.CheckClickedPoint(Input.GetTouch(0).position);
                }
            }
            else
            {
                //start selecting buttons
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    CharacterSelectButton buttonTouched = CheckButtonsTouched(Input.GetTouch(0).position);
                    if (buttonTouched != null)
                    {
                        buttonTouched.DeselectAllCharacters();
                        buttonTouched.SelectCharacterWithoutDeselectingOthers();
                    }
                }

                //drag buttons
                if (Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    CharacterSelectButton buttonTouched = CheckButtonsTouched(Input.GetTouch(0).position);
                    if (buttonTouched != null)
                    {
                        if (!buttonTouched.selected)
                        {
                            buttonTouched.SelectCharacterWithoutDeselectingOthers();
                        }
                    }
                }
            }
        }
        //Zoom mobile
        if (Input.touchCount == 2)
        {
            if (clickableArea.Contains(Input.GetTouch(0).position) && clickableArea.Contains(Input.GetTouch(1).position))
            {
                pinching = true;
                // Store both touches.
                Touch touchZero = Input.GetTouch(0);
                Touch touchOne  = Input.GetTouch(1);

                cameraManager.ZoomCamera(PinchMovement(touchZero, touchOne));
            }
        }
        if (Input.touchCount == 0)
        {
            pinching = false;

            //Drag variables
            dragTimePassed = 0f;
            touchStarted   = false;
            touchMoved     = false;
        }
#endif
#if UNITY_EDITOR || (!UNITY_ANDROID && !UNITY_WP8 && !UNITY_IOS)
        //####DESKTOP
        //move character desktop
        if (Input.GetAxis("Horizontal") != 0f || Input.GetAxis("Vertical") != 0f)
        {
            cameraManager.DragCamera(new Vector2(-Input.GetAxis("Horizontal"), -Input.GetAxis("Vertical")));
        }
        if (clickableArea.Contains(Input.mousePosition))
        {
            if (Input.GetMouseButtonDown(0))
            {
                charactersManager.CheckClickedPoint(Input.mousePosition);
            }

            if (Input.GetMouseButton(0))
            {
                dragTimePassed += Time.deltaTime;
            }

            if (Input.GetMouseButtonUp(0))
            {
                dragTimePassed = 0f;
            }
        }
#endif
    }
コード例 #3
0
 public void setAllButtons(CharacterSelectButton[] allButtons)
 {
     this.allButtons = allButtons;
 }
コード例 #4
0
 public void setCharacterButton(CharacterSelectButton characterButton)
 {
     this.characterButton = characterButton;
 }